/apollo-gql-server

GraphQL server with multiple backends: SQL, MongoDB and REST endpoint.

Primary LanguageJavaScriptMIT LicenseMIT

Apollo GraphQL Server

GraphQL server that connects to multiple backends: a SQL database, a MongoDB database and a REST endpoint.

Server for a basic blog app with authors, posts and views.

Adapted from the following tutorial with updates for Apollo 2: How to build a GraphQL server.

Getting started

npm install
npm start

Then open http://localhost:3000/graphql

When you paste this on the left side of the page:

query {
  author(firstName: "Edmond", lastName: "Jones") {
    firstName
    lastName
    posts {
      title
      views
    }
  }
  getFortuneCookie
}

Hit the play button (cmd-return), then you should get a response like this:

{
  "data": {
    "author": {
      "firstName": "Edmond",
      "lastName": "Jones",
      "posts": [
        {
          "title": "A post by Edmond",
          "views": 92
        }
      ]
    },
    "getFortuneCookie": "Say what you mean and mean what you say."
  }
}