This bundle use the Overblog/GraphQLBundle, first you need to install it.
- Install the bundle:
$ composer require sparklink/graphql-tools-bundle
- In
config/packages/graphql.yaml, add the builders:
overblog_graphql:
# ...
definitions:
#.....
builders:
fields:
- alias: CrudQuery
class: "Sparklink\\GraphQLToolsBundle\\GraphQL\\Builder\\CrudQueryBuilder"
- alias: CrudMutation
class: "Sparklink\\GraphQLToolsBundle\\GraphQL\\Builder\\CrudMutationBuilder"
- alias: CrudEntityId
class: "Sparklink\\GraphQLToolsBundle\\GraphQL\\Builder\\CrudEntityIdBuilder" -
In your project's root query and mutation attach:
In
Query, theCrudQueryandCrudEntityIdbuilders.namespace App\GraphQL\Root; use App\GraphQL\Builder\CrudConfig; use Overblog\GraphQLBundle\Annotation as GQL; #[GQL\Type] #[GQL\FieldsBuilder(name: 'CrudQuery', config: CrudConfig::CONFIG)] #[GQL\FieldsBuilder(name: 'CrudEntityId', config: CrudConfig::CONFIG)] class Query { //... }
In
Mutation, theCrudMutationbuildernamespace App\GraphQL\Root; use App\GraphQL\Builder\CrudConfig; use Overblog\GraphQLBundle\Annotation as GQL; #[GQL\Type] #[GQL\FieldsBuilder(name: 'CrudMutation', config: CrudConfig::CONFIG)] class Mutation { //... }
-
Configure the builders (see here for more information)