apollo-server-express

Production-ready Node.js GraphQL server for Express and Connect

The `apollo-server-express` package is part of Apollo Server v2 and v3, which are now deprecated (end-of-life October 22nd 2023 and October 22nd 2024, respectively). This package's functionality is now found in the `@apollo/server` package. See https://www.apollographql.com/docs/apollo-server/previous-versions/ for more details.
Last updated 6 years ago by mdg .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install apollo-server-express 
SYNC missed versions from official npm registry.

title: Express / Connect description: Setting up Apollo Server with Express.js or Connect

npm version Build Status Coverage Status Get on Slack

This is the Express and Connect integration of GraphQL Server. Apollo Server is a community-maintained open-source GraphQL server that works with many Node.js HTTP server frameworks. Read the docs. Read the CHANGELOG.

npm install apollo-server-express@rc

Express

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

// Construct a schema, using GraphQL schema language
const typeDefs = gql`
  type Query {
    hello: String
  }
`;

// Provide resolver functions for your schema fields
const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
};

const server = new ApolloServer({ typeDefs, resolvers });

const app = express();
server.applyMiddleware({ app });

app.listen({ port: 4000 }, () =>
  console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`)
);

Connect

const connect = require('connect');
const { ApolloServer, gql } = require('apollo-server-express');
const query = require('qs-middleware');

// Construct a schema, using GraphQL schema language
const typeDefs = gql`
  type Query {
    hello: String
  }
`;

// Provide resolver functions for your schema fields
const resolvers = {
  Query: {
    hello: () => 'Hello world!',
  },
};

const server = new ApolloServer({ typeDefs, resolvers });

const app = connect();
const path = '/graphql';

server.use(query());
server.applyMiddleware({ app, path });

app.listen({ port: 4000 }, () =>
  console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`)
);

Note; qs-middleware is only required if running outside of Meteor

Principles

GraphQL Server is built with the following principles in mind:

  • By the community, for the community: GraphQL Server's development is driven by the needs of developers
  • Simplicity: by keeping things simple, GraphQL Server is easier to use, easier to contribute to, and more secure
  • Performance: GraphQL Server is well-tested and production-ready - no modifications needed

Anyone is welcome to contribute to GraphQL Server, just read CONTRIBUTING.md, take a look at the roadmap and make your first PR!

Current Tags

  • 3.6.0-alpha.1                                ...           alpha (3 years ago)
  • 3.0.0-lambda.0                                ...           alphalambda (4 years ago)
  • 3.0.0-html.2                                ...           html (3 years ago)
  • 3.13.0                                ...           latest (a year ago)
  • 3.2.0                                ...           next (3 years ago)
  • 3.0.0-alpha.3                                ...           next-v3 (4 years ago)
  • 3.0.0-preview.4                                ...           preview (3 years ago)
  • 3.0.0-rc.1                                ...           rc (3 years ago)
  • 2.23.1-unified2.3                                ...           unified (4 years ago)
  • 2.26.2                                ...           v2 (a year ago)

314 Versions

  • 3.13.0                                ...           a year ago
  • 3.12.1 [deprecated]           ...           a year ago
  • 2.26.2 [deprecated]           ...           a year ago
  • 3.12.0 [deprecated]           ...           2 years ago
  • 3.11.1 [deprecated]           ...           2 years ago
  • 3.11.0 [deprecated]           ...           2 years ago
  • 3.10.4 [deprecated]           ...           2 years ago
  • 2.26.1 [deprecated]           ...           2 years ago
  • 3.10.3 [deprecated]           ...           2 years ago
  • 3.10.2 [deprecated]           ...           2 years ago
  • 2.26.0 [deprecated]           ...           2 years ago
  • 3.10.1 [deprecated]           ...           2 years ago
  • 3.10.0 [deprecated]           ...           2 years ago
  • 3.9.0 [deprecated]           ...           2 years ago
  • 3.8.2 [deprecated]           ...           2 years ago
  • 2.25.4 [deprecated]           ...           2 years ago
  • 3.8.1 [deprecated]           ...           2 years ago
  • 3.8.0 [deprecated]           ...           2 years ago
  • 3.7.0 [deprecated]           ...           3 years ago
  • 3.6.8 [deprecated]           ...           3 years ago
  • 3.6.7 [deprecated]           ...           3 years ago
  • 3.6.6 [deprecated]           ...           3 years ago
  • 3.6.5 [deprecated]           ...           3 years ago
  • 3.6.4 [deprecated]           ...           3 years ago
  • 3.6.3 [deprecated]           ...           3 years ago
  • 3.6.2 [deprecated]           ...           3 years ago
  • 3.6.1 [deprecated]           ...           3 years ago
  • 3.6.0 [deprecated]           ...           3 years ago
  • 3.6.0-alpha.1 [deprecated]           ...           3 years ago
  • 3.6.0-alpha.0 [deprecated]           ...           3 years ago
  • 3.5.0 [deprecated]           ...           3 years ago
  • 3.4.1 [deprecated]           ...           3 years ago
  • 2.25.3 [deprecated]           ...           3 years ago
  • 3.4.0 [deprecated]           ...           3 years ago
  • 3.4.0-alpha.0 [deprecated]           ...           3 years ago
  • 3.3.0 [deprecated]           ...           3 years ago
  • 3.2.0 [deprecated]           ...           3 years ago
  • 3.2.0-alpha.0 [deprecated]           ...           3 years ago
  • 3.1.2 [deprecated]           ...           3 years ago
  • 3.1.1 [deprecated]           ...           3 years ago
  • 3.1.0 [deprecated]           ...           3 years ago
  • 3.1.0-alpha.1 [deprecated]           ...           3 years ago
  • 3.1.0-alpha.0 [deprecated]           ...           3 years ago
  • 3.0.2 [deprecated]           ...           3 years ago
  • 3.0.1 [deprecated]           ...           3 years ago
  • 3.0.0 [deprecated]           ...           3 years ago
  • 3.0.0-rc.1 [deprecated]           ...           3 years ago
  • 3.0.0-rc.0 [deprecated]           ...           3 years ago
  • 3.0.0-preview.4 [deprecated]           ...           3 years ago
  • 3.0.0-preview.3 [deprecated]           ...           3 years ago
  • 2.25.2 [deprecated]           ...           3 years ago
  • 3.0.0-preview.2 [deprecated]           ...           3 years ago
  • 3.0.0-preview.1 [deprecated]           ...           3 years ago
  • 2.25.1 [deprecated]           ...           3 years ago
  • 3.0.0-preview.0 [deprecated]           ...           3 years ago
  • 2.25.0 [deprecated]           ...           3 years ago
  • 2.25.0-alpha.1 [deprecated]           ...           3 years ago
  • 2.25.0-alpha.0 [deprecated]           ...           3 years ago
  • 3.0.0-html.2 [deprecated]           ...           3 years ago
  • 3.0.0-html.0 [deprecated]           ...           3 years ago
  • 2.24.1 [deprecated]           ...           3 years ago
  • 3.0.0-lambda.0 [deprecated]           ...           4 years ago
  • 3.0.0-alpha.4 [deprecated]           ...           4 years ago
  • 2.24.0 [deprecated]           ...           4 years ago
  • 2.24.0-alpha.2 [deprecated]           ...           4 years ago
  • 2.24.0-alpha.1 [deprecated]           ...           4 years ago
  • 2.24.0-alpha.0 [deprecated]           ...           4 years ago
  • 2.23.1-unified2.3 [deprecated]           ...           4 years ago
  • 2.23.1-unified2.2 [deprecated]           ...           4 years ago
  • 2.23.1-unified2.1 [deprecated]           ...           4 years ago
  • 2.23.1-unified2.0 [deprecated]           ...           4 years ago
  • 2.23.1-unified.2 [deprecated]           ...           4 years ago
  • 2.23.1-unified.0 [deprecated]           ...           4 years ago
  • 2.23.0 [deprecated]           ...           4 years ago
  • 2.23.0-alpha.1 [deprecated]           ...           4 years ago
  • 2.23.0-alpha.0 [deprecated]           ...           4 years ago
  • 2.22.2 [deprecated]           ...           4 years ago
  • 2.22.2-alpha.0 [deprecated]           ...           4 years ago
  • 2.22.1 [deprecated]           ...           4 years ago
  • 2.22.0 [deprecated]           ...           4 years ago
  • 2.22.0-alpha.0 [deprecated]           ...           4 years ago
  • 2.21.2 [deprecated]           ...           4 years ago
  • 2.21.2-alpha.0 [deprecated]           ...           4 years ago
  • 2.21.1 [deprecated]           ...           4 years ago
  • 2.21.1-alpha.0 [deprecated]           ...           4 years ago
  • 2.21.0 [deprecated]           ...           4 years ago
  • 2.21.0-alpha.2 [deprecated]           ...           4 years ago
  • 2.21.0-alpha.1 [deprecated]           ...           4 years ago
  • 2.21.0-alpha.0 [deprecated]           ...           4 years ago
  • 2.20.0 [deprecated]           ...           4 years ago
  • 2.20.0-alpha.0 [deprecated]           ...           4 years ago
  • 2.19.2 [deprecated]           ...           4 years ago
  • 2.19.1 [deprecated]           ...           4 years ago
  • 2.19.0 [deprecated]           ...           4 years ago
  • 2.19.0-alpha.1 [deprecated]           ...           4 years ago
  • 2.18.2 [deprecated]           ...           4 years ago
  • 2.19.0-alpha.0 [deprecated]           ...           4 years ago
  • 2.18.1 [deprecated]           ...           4 years ago
  • 2.18.0 [deprecated]           ...           4 years ago
  • 2.18.0-rc.1 [deprecated]           ...           4 years ago
  • 2.18.0-rc.0 [deprecated]           ...           4 years ago
  • 2.17.1-alpha.0 [deprecated]           ...           4 years ago
  • 2.17.0 [deprecated]           ...           4 years ago
  • 3.0.0-alpha.3 [deprecated]           ...           4 years ago
  • 3.0.0-alpha.2 [deprecated]           ...           4 years ago
  • 2.16.1 [deprecated]           ...           4 years ago
  • 2.16.0 [deprecated]           ...           4 years ago
  • 2.15.1 [deprecated]           ...           4 years ago
  • 2.15.0 [deprecated]           ...           4 years ago
  • 2.15.0-alpha.1 [deprecated]           ...           4 years ago
  • 2.14.5 [deprecated]           ...           4 years ago
  • 2.15.0-alpha.0 [deprecated]           ...           4 years ago
  • 2.14.4 [deprecated]           ...           4 years ago
  • 2.14.3 [deprecated]           ...           4 years ago
  • 2.14.2 [deprecated]           ...           4 years ago
  • 2.14.1 [deprecated]           ...           4 years ago
  • 2.14.0 [deprecated]           ...           4 years ago
  • 2.14.0-alpha.2 [deprecated]           ...           4 years ago
  • 2.14.0-alpha.1 [deprecated]           ...           4 years ago
  • 2.14.0-alpha.0 [deprecated]           ...           5 years ago
  • 2.13.1 [deprecated]           ...           5 years ago
  • 2.13.1-alpha.1 [deprecated]           ...           5 years ago
  • 2.13.1-alpha.0 [deprecated]           ...           5 years ago
  • 2.13.0 [deprecated]           ...           5 years ago
  • 2.13.0-alpha.1 [deprecated]           ...           5 years ago
  • 2.13.0-alpha.0 [deprecated]           ...           5 years ago
  • 2.12.0 [deprecated]           ...           5 years ago
  • 2.12.0-alpha.5 [deprecated]           ...           5 years ago
  • 2.12.0-alpha.4 [deprecated]           ...           5 years ago
  • 2.12.0-alpha.3 [deprecated]           ...           5 years ago
  • 2.12.0-alpha.2 [deprecated]           ...           5 years ago
  • 2.12.0-alpha.1 [deprecated]           ...           5 years ago
  • 2.12.0-alpha.0 [deprecated]           ...           5 years ago
  • 2.11.0 [deprecated]           ...           5 years ago
  • 2.11.0-alpha.3 [deprecated]           ...           5 years ago
  • 2.11.0-alpha.2 [deprecated]           ...           5 years ago
  • 2.11.0-alpha.1 [deprecated]           ...           5 years ago
  • 2.10.1 [deprecated]           ...           5 years ago
  • 2.10.0 [deprecated]           ...           5 years ago
  • 2.9.16 [deprecated]           ...           5 years ago
  • 2.9.15 [deprecated]           ...           5 years ago
  • 2.9.14 [deprecated]           ...           5 years ago
  • 2.9.13 [deprecated]           ...           5 years ago
  • 2.9.12 [deprecated]           ...           5 years ago
  • 2.9.11 [deprecated]           ...           5 years ago
  • 2.9.10 [deprecated]           ...           5 years ago
  • 2.9.9 [deprecated]           ...           5 years ago
  • 2.9.8 [deprecated]           ...           5 years ago
  • 2.9.7 [deprecated]           ...           5 years ago
  • 2.9.6 [deprecated]           ...           5 years ago
  • 2.9.5 [deprecated]           ...           5 years ago
  • 2.9.4 [deprecated]           ...           5 years ago
  • 2.9.3 [deprecated]           ...           5 years ago
  • 2.9.2 [deprecated]           ...           5 years ago
  • 2.9.1 [deprecated]           ...           5 years ago
  • 2.9.0 [deprecated]           ...           5 years ago
  • 2.8.2 [deprecated]           ...           5 years ago
  • 2.8.1 [deprecated]           ...           5 years ago
  • 2.8.0 [deprecated]           ...           5 years ago
  • 2.7.2 [deprecated]           ...           5 years ago
  • 2.7.1 [deprecated]           ...           5 years ago
  • 2.7.0 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.14 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.13 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.12 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.9 [deprecated]           ...           5 years ago
  • 2.6.9 [deprecated]           ...           5 years ago
  • 2.6.8 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.8 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.7 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.6 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.5 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.4 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.3 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.2 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.1 [deprecated]           ...           5 years ago
  • 2.7.0-alpha.0 [deprecated]           ...           5 years ago
  • 2.6.7 [deprecated]           ...           5 years ago
  • 2.6.7-alpha.0 [deprecated]           ...           5 years ago
  • 2.6.6 [deprecated]           ...           5 years ago
  • 2.6.5 [deprecated]           ...           5 years ago
  • 2.6.5-alpha.0 [deprecated]           ...           5 years ago
  • 2.6.4 [deprecated]           ...           5 years ago
  • 2.6.3 [deprecated]           ...           5 years ago
  • 2.6.2 [deprecated]           ...           5 years ago
  • 2.6.2-alpha.0 [deprecated]           ...           5 years ago
  • 2.6.1 [deprecated]           ...           5 years ago
  • 2.6.1-alpha.0 [deprecated]           ...           5 years ago
  • 2.6.0 [deprecated]           ...           5 years ago
  • 2.6.0-rc.0 [deprecated]           ...           5 years ago
  • 2.6.0-alpha.9 [deprecated]           ...           5 years ago
  • 2.5.1 [deprecated]           ...           5 years ago
  • 2.5.1-alpha.1 [deprecated]           ...           5 years ago
  • 2.5.1-alpha.0 [deprecated]           ...           5 years ago
  • 2.6.0-alpha.8 [deprecated]           ...           5 years ago
  • 2.6.0-alpha.7 [deprecated]           ...           5 years ago
  • 2.6.0-alpha.6 [deprecated]           ...           5 years ago
  • 2.6.0-alpha.5 [deprecated]           ...           5 years ago
  • 2.6.0-alpha.4 [deprecated]           ...           5 years ago
  • 2.6.0-alpha.3 [deprecated]           ...           5 years ago
  • 2.6.0-alpha.2 [deprecated]           ...           5 years ago
  • 2.6.0-alpha.1 [deprecated]           ...           5 years ago
  • 2.6.0-alpha.0 [deprecated]           ...           6 years ago
  • 2.5.1-alpha.15 [deprecated]           ...           6 years ago
  • 2.5.1-alpha.14 [deprecated]           ...           6 years ago
  • 2.5.0 [deprecated]           ...           6 years ago
  • 2.5.0-rc.0 [deprecated]           ...           6 years ago
  • 2.5.0-alpha.7 [deprecated]           ...           6 years ago
  • 2.5.0-alpha.6 [deprecated]           ...           6 years ago
  • 2.5.0-alpha.5 [deprecated]           ...           6 years ago
  • 2.5.0-alpha.4 [deprecated]           ...           6 years ago
  • 2.5.0-alpha.3 [deprecated]           ...           6 years ago
  • 2.5.0-alpha.2 [deprecated]           ...           6 years ago
  • 2.5.0-alpha.1 [deprecated]           ...           6 years ago
  • 2.5.0-alpha.0 [deprecated]           ...           6 years ago
  • 2.4.8 [deprecated]           ...           6 years ago
  • 2.4.7 [deprecated]           ...           6 years ago
  • 2.4.6 [deprecated]           ...           6 years ago
  • 2.4.5 [deprecated]           ...           6 years ago
  • 2.4.4 [deprecated]           ...           6 years ago
  • 2.4.3 [deprecated]           ...           6 years ago
  • 2.4.2 [deprecated]           ...           6 years ago
  • 2.4.2-rc.0 [deprecated]           ...           6 years ago
  • 2.4.1 [deprecated]           ...           6 years ago
  • 2.4.0 [deprecated]           ...           6 years ago
  • 2.4.0-alpha.4 [deprecated]           ...           6 years ago
  • 2.3.3 [deprecated]           ...           6 years ago
  • 2.3.2 [deprecated]           ...           6 years ago
  • 2.4.0-alpha.3 [deprecated]           ...           6 years ago
  • 2.4.0-alpha.2 [deprecated]           ...           6 years ago
  • 2.4.0-alpha.1 [deprecated]           ...           6 years ago
  • 2.4.0-alpha.0 [deprecated]           ...           6 years ago
  • 2.3.1 [deprecated]           ...           6 years ago
  • 2.3.0 [deprecated]           ...           6 years ago
  • 2.2.7 [deprecated]           ...           6 years ago
  • 2.3.0-alpha.0 [deprecated]           ...           6 years ago
  • 2.2.7-alpha.0 [deprecated]           ...           6 years ago
  • 2.2.6 [deprecated]           ...           6 years ago
  • 2.2.5 [deprecated]           ...           6 years ago
  • 2.2.4 [deprecated]           ...           6 years ago
  • 2.2.3 [deprecated]           ...           6 years ago
  • 2.2.2 [deprecated]           ...           6 years ago
  • 2.2.1 [deprecated]           ...           6 years ago
  • 2.2.0 [deprecated]           ...           6 years ago
  • 2.2.0-alpha.4 [deprecated]           ...           6 years ago
  • 2.2.0-alpha.3 [deprecated]           ...           6 years ago
  • 2.2.0-alpha.2 [deprecated]           ...           6 years ago
  • 2.2.0-alpha.1 [deprecated]           ...           6 years ago
  • 2.2.0-alpha.0 [deprecated]           ...           6 years ago
  • 2.2.0-register.2195 [deprecated]           ...           6 years ago
  • 2.1.0 [deprecated]           ...           6 years ago
  • 2.0.7 [deprecated]           ...           6 years ago
  • 2.0.6 [deprecated]           ...           6 years ago
  • 2.0.5 [deprecated]           ...           6 years ago
  • 2.0.4 [deprecated]           ...           6 years ago
  • 2.0.3 [deprecated]           ...           6 years ago
  • 2.0.2 [deprecated]           ...           6 years ago
  • 2.0.1 [deprecated]           ...           6 years ago
  • 2.1.0-alpha.10 [deprecated]           ...           6 years ago
  • 2.1.0-alpha.9 [deprecated]           ...           6 years ago
  • 2.1.0-alpha.8 [deprecated]           ...           6 years ago
  • 2.1.0-alpha.7 [deprecated]           ...           6 years ago
  • 2.1.0-alpha.6 [deprecated]           ...           6 years ago
  • 2.1.0-alpha.5 [deprecated]           ...           6 years ago
  • 2.0.0 [deprecated]           ...           6 years ago
  • 2.1.0-alpha.2 [deprecated]           ...           6 years ago
  • 2.1.0-alpha.1 [deprecated]           ...           6 years ago
  • 2.0.0-rc.12 [deprecated]           ...           6 years ago
  • 2.1.0-alpha.0 [deprecated]           ...           6 years ago
  • 2.0.0-rc.10 [deprecated]           ...           6 years ago
  • 2.0.0-rc.9 [deprecated]           ...           6 years ago
  • 2.0.0-rc.8 [deprecated]           ...           6 years ago
  • 1.4.0 [deprecated]           ...           6 years ago
  • 2.0.0-rc.7 [deprecated]           ...           6 years ago
  • 2.0.0-rc.6 [deprecated]           ...           6 years ago
  • 2.0.0-rc.5 [deprecated]           ...           6 years ago
  • 2.0.0-rc.4 [deprecated]           ...           6 years ago
  • 2.0.0-rc.3 [deprecated]           ...           6 years ago
  • 2.0.0-rc.2 [deprecated]           ...           6 years ago
  • 2.0.0-rc.1 [deprecated]           ...           6 years ago
  • 2.0.0-rc.0 [deprecated]           ...           6 years ago
  • 2.0.0-beta.11 [deprecated]           ...           6 years ago
  • 2.0.0-beta.10 [deprecated]           ...           6 years ago
  • 2.0.0-beta.9 [deprecated]           ...           6 years ago
  • 2.0.0-beta.8 [deprecated]           ...           6 years ago
  • 2.0.0-beta.7 [deprecated]           ...           6 years ago
  • 2.0.0-beta.6 [deprecated]           ...           6 years ago
  • 2.0.0-beta.5 [deprecated]           ...           6 years ago
  • 2.0.0-beta.3 [deprecated]           ...           6 years ago
  • 2.0.0-beta.2 [deprecated]           ...           6 years ago
  • 2.0.0-beta.1 [deprecated]           ...           6 years ago
  • 2.0.0-beta.0 [deprecated]           ...           7 years ago
  • 1.3.6 [deprecated]           ...           7 years ago
  • 1.3.5 [deprecated]           ...           7 years ago
  • 1.3.4 [deprecated]           ...           7 years ago
  • 1.3.3 [deprecated]           ...           7 years ago
  • 1.3.2 [deprecated]           ...           7 years ago
  • 1.3.1 [deprecated]           ...           7 years ago
  • 1.3.0 [deprecated]           ...           7 years ago
  • 1.2.0 [deprecated]           ...           7 years ago
  • 1.2.0-pre.1 [deprecated]           ...           7 years ago
  • 1.1.7 [deprecated]           ...           7 years ago
  • 1.1.6 [deprecated]           ...           7 years ago
  • 1.1.5 [deprecated]           ...           7 years ago
  • 1.1.3 [deprecated]           ...           7 years ago
  • 1.1.2 [deprecated]           ...           7 years ago
  • 1.1.0 [deprecated]           ...           7 years ago
  • 1.0.5 [deprecated]           ...           7 years ago
  • 1.0.4 [deprecated]           ...           7 years ago
  • 1.0.3-tracing.3 [deprecated]           ...           7 years ago
  • 1.0.3-tracing.2 [deprecated]           ...           7 years ago
  • 1.0.3-tracing.1 [deprecated]           ...           7 years ago
  • 1.0.3-tracing.0 [deprecated]           ...           7 years ago
  • 1.0.2 [deprecated]           ...           7 years ago
Downloads
Total 26
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (14)
Dev Dependencies (10)

© 2010 - cnpmjs.org x YWFE | Home | YWFE