Graphback generates a CRUD API for each model in your GraphQL schema. This gives you queries, mutations and subscriptions that can be instantly be used perform queries and mutations on your data.
Graphback provides an implementation of GraphQLCRUD for a standardised CRUD API using common data access patterns.
Queries, mutations and subscriptions that you add to your model files will be included in the generated schema. These require manual implementation and merging with the resolvers generated by Graphback.
Your custom operations can utilize the input types and filters created by Graphback. This lets you control the schema as you would when building it from scratch, while significantly reducing the amount of boilerplate required to set up it from your data.
To tell Graphback to create a CRUD API for your type, add a
This will add queries, mutations and subscriptions to the schema for
Note. It will also create corresponding CRUD resolvers which are configured to access the data from your data source.
Graphback will override custom queries, mutations and subscriptions from model files which have the same name as Graphback CRUD queries, mutations and subscriptions. Either change the name of your custom definitions or disable generation of the CRUD operation(s) for the model(s).
Graphback can be configured to enable/disable CRUD generation per GraphQL type, or globally across the entire application.
See the table below for the full list of CRUD configuration options that can be applied to the application or models.
|find||Specifies whether a ||true|
|findOne||Specifies whether a ||true|
|create||Specifies whether a ||true|
|update||Specifies whether a ||true|
|delete||Specifies whether a ||true|
|subCreate||Specifies whether a ||true|
|subUpdate||Specifies whether a ||true|
|subDelete||Specifies whether a ||true|
You can configure different CRUD methods to be enabled or disabled across all data models in
buildGraphbackAPI through the
crud config option.
In this example, generation of the
delete mutation for all models is disabled.
CRUD configuration set on an individual type with the
@model annotation will override the application-wide CRUD configuration.
CRUD can be enabled/disabled individually for each model in your schema with the
deleteNote generation for
CRUD configuration set with
@model will override the application-wide CRUD configuration value for that type only.