Skip to content

Latest commit

 

History

History
58 lines (45 loc) · 1.25 KB

quick-start.md

File metadata and controls

58 lines (45 loc) · 1.25 KB

Quick start

  1. Install the bundle (more details)
composer require overblog/graphql-bundle
  1. Configure the bundle to accept graphql format (more details)
# config/packages/graphql.yaml
overblog_graphql:
    definitions:
        schema:
            query: Query
        mappings:
            auto_discover: false
            types:
                -
-                   type: yaml
+                   type: graphql
                    dir: "%kernel.project_dir%/config/graphql/types"
                    suffix: ~
  1. Define schema using GraphQL schema language in files config/graphql/types/*.graphql

  2. Define schema Resolvers (more details)

<?php

// src/Resolver/MyResolverMap.php
namespace App\Resolver;

use Overblog\GraphQLBundle\Resolver\ResolverMap;

class MyResolverMap extends ResolverMap
{
   protected function map()
   {
      // return your resolver map
   }
}
  1. Test your schema using GraphiQL or with curl
curl 'http://127.0.0.1:8000/' \
 -H 'Content-Type: application/json' \
 --data-binary '{"query":"{ humans {id name direwolf {id name} } }","variables":{}}'

This is it!