Create Basic GraphQL Server

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:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s