Grafast plugin
Experimental Package
This package is currently experimental and will have breaking changes in the near future.
This plugin currently does not work with MOST other Pothos plugins.
Many plugins depend on wrapping resolvers to add runtime functionality to your schema, which will not work with grafast.
Install
Setup
Usage
For documentation on how to write plans, see the Grafast documentation.
Adding plans to fields
Using resolvers
Pothos and Grafast will still allow you to write resolvers when using grafast,
but you will not have access to the 4th GraphqlResolveInfo
argument:
Resolvers should not be used to load data, but can make it easier to define a field
that would otherwise use a simple lambda
plan.
Abstract types
Abstract types (Unions and Interfaces) may require defining a plan to resolve to the correct type. For more details on how polymorphic types work in Grafast, see the Grafast documentation.
Interfaces
To implement an interface, you can implement it as you normally would in Pothos, and then call the
.withPlan
method on the interface ref to provide a plan for resolving the correct type.
You can now define a query to resolve this interface:
Unions
Unions can be implemented just like interfaces:
planForType
When planning polymorphic types, Grafast allows you to provide a planForType
function that
allows you to load the correct data for the current type.
This also enables changing the type of plan required for fields that return the abstract type:
planForType
is not entirely type-safe, and will allow plans that resolve to data for the wrong type.
This API is likely to change in the future.