GraphQL Apollo Server

Till now we have been using a simple graphql-express middleware as a gql server. 

Apollo-Server provides a full feature gql server which is production ready and should be used for most applications.

Let’s move our code base to apollo-server

First install via

$ npm install --save apollo-server graphql

Also we don’t need graphql-tools anymore as it is inbuilt in apollo-server

So final code looks like this

const { ApolloServer } = require('apollo-server');

import { typeDefs, resolvers } from "./schema"

// var app = express();

const server = new ApolloServer({
    mocks: true,
    mockEntireSchema: false,


Here is the full source

After apollo-server is running your playground looks like this

There is another feature with apollo-server the ‘gql’ literal tag.

The main reason for this for syntax highlighting of gql. If you using vscode, you can install graphql-prisma extension and if use the gql tag your code will get highlighted.


syntax is highlighter in this due to ‘gql’ literal.

syntax is not highlighted

this is also a cool feature!

There are many more things which can be done with apollo-server which you can read on there official docs