No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 65047c4 Nov 1, 2016
Permalink
Failed to load latest commit information.
app docker support Oct 31, 2016
bin add app core Oct 31, 2016
docker/php docker support Oct 31, 2016
src add app core Oct 31, 2016
tests/AppBundle/Controller add app core Oct 31, 2016
var add app core Oct 31, 2016
web add app core Oct 31, 2016
.gitignore add app core Oct 31, 2016
README.md fix in readme Nov 1, 2016
composer.json add app core Oct 31, 2016
composer.lock add app core Oct 31, 2016
docker-compose.yml docker support Oct 31, 2016
phpunit.xml.dist add app core Oct 31, 2016

README.md

GraphQL Demo App

This project was created to show how we use GraphQLBundle in our projects.

To ilustrate this we created simple backend application witch provide API endpoint for React Example TODO app (source code and how to run it you can see here).

How to run

To run backend you need clone this repo and:

  • If you have docker installed, just type this in project root:

    docker-compose up -d

    This command will run containers and exposed port will be 8500.

    API endpoint: http://localhost:8500/graphql

  • If you have web stack installed, run:

    php bin/console server:start

    API endpoint: http://localhost:8000/graphql

Sending requests

Now you can easily send request to endpoint, for example:

$ curl -XPOST 'http://127.0.0.1:8000/graphql'

Response:

{
    "errors": [
        {
            "message": "Must provide an operation."
        }
    ]
}

Now let's specify query in request content:

$ curl -XPOST 'http://127.0.0.1:8000/graphql' -F 'query={ todos { id } }'

Response:

{
    "data": {
        "todos": [
          {
            "id": 129
          }
        ]
    }
}

GraphiQL extension

To run GraphiQL extension, just open endpoint + /explorer in your browser, for example http://localhost:8000/graphql/explorer.

Configuration for React example Todo app

If you have installed React Example TODO application and want to use our endpoint, you need to change endpoint in server.js on line 10:

Example