Type Definitions
Type Definitions — GraphQL Modules documentation.
GraphQL Schema is built out of types, enums, interfaces and so on. Defining or extending them in GraphQL Modules is fairly simple.
Just like GraphQL Schema, GraphQL Modules follow the same rules of writing SDL (Schema Definition Language), a single definition per type and multiple extensions. This way we force a good pattern and clarify ownership of each type.
To get started with type definitions in your module, make sure to use gql (you can import it from graphql-modules) or parse (from graphql) to convert your string SDL definition into a DocumentNode object.
Storing SDL in .graphql Files
If you wish to write your GraphQL SDL in a .graphql file, you need to make sure you can load it correctly in a Node.js environment.
To do so, use graphql-import-node to make this process easier:
Start by installing it, and follow the installation instructions, based on your environment and your setup.
Now, store your SDL in a .graphql file(s), and load it this way, with import or require:
Dynamically Load SDL Files
If you have too many SDL files, and you wish to load them dynamically, you can use loaders from @graphql-tools/load-files!
Start by installing this package:
Next, use it to load your files dynamically: