Load Your Schema and Resolvers
There are multiple ways to load your schema, and GraphQL Modules tries to make it easy for you.
sonar
in graphql-toolkit
#
Using You can use graphql-toolkit
, it has a powerful mechanism for finding and loading your schema and resolvers files.
Along with graphql-toolkit
's sonar
, you can separate your GraphQL schema definition and resolvers to smaller parts, and load them without directly specifying files.
For example, given the following structure:
You can easily load all of your .graphql
files and .ts
resolvers files like below:
This way, you don't have to specify each file and each resolver; the tools will do it for you.
graphql-import-node
#
Using imports and You can also write your schema and resolvers in different files and then import them using graphql-import-node:
modules/my-module/index.ts
modules/my-module/resolvers.ts
modules/my-module/schema.graphql
#
As a stringThe simplest way to load your schema and resolvers into a module is to write them directly on your GraphQLModule
definition: