Skip to content

Conversation

mcg-web
Copy link
Contributor

@mcg-web mcg-web commented Jan 25, 2018

Q A
Bug fix? no
New feature? yes
BC breaks? yes
Deprecations? no
Tests pass? yes
Documented? yes
Fixed tickets #254, #12
License MIT

Quick start

  1. Install the bundle
composer require 'overblog/graphql-bundle:dev-master#9437757d' --update-with-dependencies
  1. Configure the bundle to accept graphql format
# 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

# config/packages/graphql.yaml
overblog_graphql:
    definitions:
        schema:
            # ...
            resolver_maps:
                - App\Resolver\MyResolverMap
<?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!

@mcg-web mcg-web force-pushed the graphql-schema-language-configuration branch from e7a83cd to c0a0f6a Compare January 25, 2018 07:48
@mcg-web mcg-web changed the title Graphql schema language configuration GraphQL schema language configuration Jan 25, 2018
@Kocal
Copy link
Contributor

Kocal commented Jan 25, 2018

That would be awesome 😍

@mcg-web mcg-web added this to the v0.11 milestone Jan 26, 2018
@mcg-web mcg-web merged commit 5d25197 into overblog:master Jan 26, 2018
@mcg-web mcg-web deleted the graphql-schema-language-configuration branch January 26, 2018 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants