
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
graphql-server
Advanced tools
Apollo Server is a community-maintained open-source GraphQL server. It works with all Node.js HTTP server frameworks: Express, Connect, Hapi and Koa.
Apollo Server is built with the following principles in mind:
Anyone is welcome to contribute to Apollo Server, just read CONTRIBUTING.md, take a look at the roadmap and make your first PR!
Apollo Server is super-easy to set up. Just npm-install apollo-server, write a GraphQL schema, and then use one of the following snippets to get started. For more info, read the Apollo Server docs.
If you want to build your GraphQL server using TypeScript, Apollo Server is the project for you. NOTE: All typings mentioned below must be included in your project in order for it to compile.
npm install apollo-server
typings i -SG dt~express dt~express-serve-static-core dt~serve-static dt~mime dt~hapi dt~boom dt~cookies dt~koa
For using the project in JavaScript, just run npm install --save apollo-server and you're good to go!
import express from 'express';
import { apolloExpress } from 'apollo-server';
const myGraphQLSchema = // ... define or import your schema here!
const PORT = 3000;
var app = express();
app.use('/graphql', bodyParser.json(), apolloExpress({ schema: myGraphQLSchema }));
app.listen(PORT);
import connect from 'connect';
import { apolloConnect } from 'apollo-server';
const PORT = 3000;
var app = connect();
app.use('/graphql', bodyParser.json(), apolloConnect({ schema: myGraphQLSchema }));
app.listen(PORT);
Now with the Hapi plugins apolloHapi and graphiqlHapi you can pass a route object that includes options to be applied to the route. The example below enables CORS on the /graphql route.
import hapi from 'hapi';
import { apolloHapi } from 'apollo-server';
const server = new hapi.Server();
const HOST = 'localhost';
const PORT = 3000;
server.connection({
host: HOST,
port: PORT,
});
server.register({
register: apolloHapi,
options: {
path: '/graphql',
apolloOptions: {
schema: myGraphQLSchema,
},
route: {
cors: true
}
},
});
server.start((err) => {
if (err) {
throw err;
}
console.log(`Server running at: ${server.info.uri}`);
});
import koa from 'koa';
import koaRouter from 'koa-router';
import { apolloKoa } from 'apollo-server';
const app = new koa();
const router = new koaRouter();
const PORT = 3000;
app.use(koaBody());
router.post('/graphql', apolloKoa({ schema: myGraphQLSchema }));
app.use(router.routes());
app.use(router.allowedMethods());
app.listen(PORT);
Apollo Server can be configured with an options object with the the following fields:
All options except for schema are optional.
The formatParams function can be used in combination with the OperationStore to enable whitelisting.
const store = new OperationStore(Schema);
store.put('query testquery{ testString }');
apolloOptions = {
schema: Schema,
formatParams(params) {
params['query'] = store.get(params.operationName);
return params;
},
};
Apollo Server and express-graphql are more or less the same thing (GraphQL middleware for Node.js), but there are a few key differences:
OperationStore to easily manage whitelistingDespite express-graphql being a reference implementation, Apollo Server is actually easier to understand and more modular than express-graphql.
That said, Apollo Server is heavily inspired by express-graphql (it's the reference implementation after all). Rather than seeing the two as competing alternatives, we think that they both have separate roles in the GraphQL ecosystem: express-graphql is a reference implementation, and Apollo Server is a GraphQL server to be used in production and evolve quickly with the needs of the community. Over time, express-graphql can adopt those features of Apollo Server that have proven their worth and become established more widely.
If you want to develop apollo server locally you must follow the following instructions:
Fork this repository
Install the Apollo Server project in your computer
git clone https://github.com/[your-user]/apollo-server
cd apollo-server
npm install -g typescript live-server
npm install
npm run typings
npm run compile
npm link
cd ~/myApp
npm link apollo-server
FAQs
Production-ready Node.js GraphQL server for Express, Hapi, Koa
The npm package graphql-server receives a total of 19 weekly downloads. As such, graphql-server popularity was classified as not popular.
We found that graphql-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.