Version: 0.15.x

ClientCRUD Plugin

The ClientCRUDPlugin plugin uses your GraphQL schema to generate queries, mutations, subscriptions and fragments for use in your client-side application. The generated documents are compatible with all major GraphQL providers, such as Apollo GraphQL and urql.


yarn add @graphback/codegen-client

To execute this plugin on-demand, you will use the Graphback CLI. Install it as a devDependency in your project.

yarn add -D graphback-cli


It is recommended to use the Graphback CLI for certain Graphback plugins, such as those that can modify files which your application depends on. This will prevent hidden accidental file modifications that would otherwise happen during start-up, which might cause issues in your application.

To load the ClientCRUDPlugin plugin, it should be configuration in a .graphqlrc GraphQL Config file. The Grahback CLI can dynamically load and execute plugins from a .graphqlrc file.

schema: './src/schema.graphql'
documents: './client/src/graphql/**/*.graphql'
# path to data mode file(s)
model: './model/datamodel.graphql'
outputPath: './src/schema/schema.graphql'
outputFile: './client/src/graphql/graphback.graphql'

The SchemaCRUDPlugin should be defined before ClientCRUDPlugin as graphback-schema to ensure the latest schema is used to generate client documents.

See SchemaCRUDPlugin for an installation and configuration guide.

Run yarn graphback generate to execute plugins from the .graphqlrc config file on-demand.

$ yarn graphback generate
Generation successful!
Done in 0.74s.

The client documents will be created in a file called ./client/src/graphql/graphback.graphql.


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

pluginConfig.outputFileRelative path to the GraphQL documents to be created.

Example: "/path/to/documents.graphql".

Supported file extensions: .ts, .graphql
pluginConfig.fragmentOnlyOptional. When true Graphback generates only creates fragments, and skips creating queries, mutations and subscriptions.boolean