Add GraphQL plugin
This plugin makes it easy to integrate GraphQL types from existing schemas into your Pothos API
It can be used for incremental migrations from nexus, graphql-tools, or any other JS/TS executable schema.
Install
Setup
Usage
There are 2 ways you can reference existing types.
- Adding types (or a whole external schema) when setting up the builder
- Adding types as Refs using new builder methods
Adding types when creating your builder
Adding types to the builder will automatically include the types in your schema when it's built. Types will only be added if no existing type of the same name is added to the builder before building the schema.
Adding types recursively adds any other types that the added type depends in it's fields, interfaces, or union members.
Adding types by themselves isn't very useful, so you'll probably want to be able to reference them when defining fields in your schema. To do this, you can add them to the builders generic Types.
This currently only works for Object
, Interface
, and Scalar
types. For other types, use the
builder methods below to create refs to the added types.
Adding types using builder methods
Objects
You can then use the returned references when defining fields:
Interfaces
Unions
Enums
Input objects
Scalars
This plugin does not add a new method for scalars, because Pothos already has a method for adding existing scalar types.