Version: 1.0

SchemaCRUD Plugin

The SchemaCRUDPlugin plugin creates your GraphQL schema with all input types, Query, Mutation and Subscription fields following recommended patterns from GraphQL CRUD. The plugin also creates your CRUD resolvers to use with your GraphQL schema.

Installation#

yarn add @graphback/codegen-schema

Usage#

To use the plugin, add it to the plugins array in buildGraphbackAPI.

const { schema, resolvers } = buildGraphbackAPI(modelDefs, {
dataProviderCreator: createKnexDbProvider(db),
plugins: [
new SchemaCRUDPlugin({
outputPath: './src/schema/schema.graphql'
})
]
});

Or if you are invoking the plugin with graphback generate:

.graphqlrc
schema: './src/schema.graphql'
documents: './client/src/graphql/**/*.graphql'
extensions:
graphback:
# path to data mode file(s)
model: './model/datamodel.graphql'
plugins:
graphback-schema:
outputPath: './src/schema/schema.graphql'
info

Unless you need the schema to be output to a file you don't need to install or configure it as Graphback will automatically execute it as the default plugin.

Configuration#

Below is a full list of the available configuration options for this plugin.

ArgumentDescriptionTypeDefault
pluginConfig.outputPathOptional relative path to the schema file.
Example: "/path/to/schema/schema.graphql"
stringundefined