Skip to content

Latest commit

 

History

History
57 lines (49 loc) · 1.69 KB

File metadata and controls

57 lines (49 loc) · 1.69 KB

Installation

This bundle use the Overblog/GraphQLBundle, first you need to install it.

  1. Install the bundle:
    $ composer require sparklink/graphql-tools-bundle
  2. 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"      
  1. In your project's root query and mutation attach:

    In Query, the CrudQuery and CrudEntityId builders.

        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, the CrudMutation builder

        namespace 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
        {
            //...
        }   
  2. Configure the builders (see here for more information)