NOTE: The crux of the implementation is to define a schema for your data that defines the
Query type AND to use the GraphQL.js to respond to the client’s GraphQL Query. To use GraphQL for an API server over HTTP, check out Running an Express GraphQL Server. Once server is ready, The next step is to learn how to issue GraphQL queries from client code.
The GraphQL module contains the GraphQL technical preview, which allows us to compose our server schema and process GraphQL requests against it. Body-parser is a simple Express middleware that we use to grab the GraphQL request being sent.
Any POST requests to
/graphql will now be executed against our GraphQL schema. We enforce a new content type for these requests — this isn’t part of the GraphQL spec, but may be a good pattern for servers that mix GraphQL with existing code.
You can view the source (each commit is a new step) here: https://github.com/clayallsopp/graphql-intro