Create your own Graphback plugin
You can build your own custom Graphback plugin to:
- automate additional customisations to the final generated schema
- build dynamic resolvers
- create file resources such as client-side queries.
To create your own plugin, start by creating a class that extends
GraphbackPlugin has a number of methods for performing different extensions to your Graphback API.
For the rest of this documentation, we will be using the following business model:
transformSchema lets you make modifications to the current iteration of the GraphQL schema object. In here you can create or modify any type or field in the schema.
GraphQLSchema and its types are immutable we highly recommend you to install and use the amazing GraphQL Compose to modify the schema.
transformSchema hook adds a new query field to the schema for each of the data models to retrieve all archived models.
createResolvers hook you can create and return resolvers using the
createResolvers you will first need to install
createResolvers is creating a new query resolver for each query field added to the schema in
Since Graphback is primarily a runtime framework, you probably won't use
createResources too often. However it is a very useful method if you ever need to output something to a file, such as your schema.
createResources is creating a GraphQL schema file from the schema generated by Graphback.
Returns a unique name of the plugin. The will be used by plugin registry to uniquely identify the plugin.
#At application start-up
To use the plugin, add it to the
plugins array in
Comments can be retrieved by the following query:
Some plugins are designed to be invoked through the Graphback CLI, such as those that output files to the local project. See Plugin Overview.
graphback generate dynamically loads the plugin package by its name defined in the
.graphqlrc. For plugin packages that begin with
@, due to a limitation where keys in a YAML object cannot begin with
@, your plugin documentation should explicitly specify the package name with the
packageName configuration value.