This set of helpers facilitates the use of GraphQL and Apollo, it allows you to define schemas splits based on domain elements (queries, mutations, resolvers)
This package allows for modular definition of GraphQL schema. Modular definition can reflect the strucutre of your Domain Elements. The advantage of this approach is that you can keep your queries and mutations close to your domain element. A graphQL module contains following properties:
Please see the section Examples examples on how to use the domain element schema and also how to use server helpers:
To use modules in your code you need to do following:
;;;// import all your modulesconst modules =
Following are the available methods from this package.
addModules(definition: IApolloQueryDefinition): void: compiles schema of several domain elements (Example: Generating schemas)
createServer(apolloOptions?: ApolloOptions, executableSchema?: any): (req: any) => IApolloOptionsprovides easy initialisation of the Apollo server.
ioSchema: generates your defined schema type as both input and ouput type. This is used, when you want to be sending whole documents to GraphQL server and probably is not the best practice. When defining the IO type all you need to do is to append the $Input after the type name. (Example: Advanced Schema)
List of examples of common uses of our helpers
Creating apollo server
In this example we load several modules and initialise a new server instance
;;;;;;// init expressapp.use'/graphql', apollo.apolloExpresscreateServergraphqlOptions;
In this example we initialise a simple schema that modifies the context upon each request.