Registry / web-framework / apollo-server

apollo-server

JSON →
library3.13.0jsnpmunverified

Apollo Server is a community-maintained open-source GraphQL server that works with many Node.js HTTP server frameworks or can run standalone. Version 3.13.0 is the final stable release of this package, which has since been superseded by the `@apollo/server` package (v4+). Active development and new features are now released under the `@apollo/server` package, which follows a rapid release cadence.

npm install apollo-server
INSTALL
IMPORT
SIG · APOLLO-SERVER
A
apollo-server
web-frameworkjavascriptv3.13.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ApolloServer
import { ApolloServer } from 'apollo-server';
const { ApolloServer } = require('apollo-server');
While `apollo-server` v3 supports both CommonJS and ESM, ESM is the modern recommendation. The successor package, `@apollo/server` v4+, is ESM-only.
gql
import { gql } from 'apollo-server';
const { gql } = require('apollo-server');
While `apollo-server` v3 supports both CommonJS and ESM, ESM is the modern recommendation. The successor package, `@apollo/server` v4+, is ESM-only.

Basic Apollo Server setup with a 'hello world' GraphQL query that starts a standalone server.

import { ApolloServer, gql } from 'apollo-server'; // The GraphQL schema const typeDefs = gql` type Query { "A simple type for getting started!" hello: String } `; // A map of functions which return data for the schema. const resolvers = { Query: { hello: () => 'world', }, }; const server = new ApolloServer({ typeDefs, resolvers, }); server.listen().then(({ url }) => { console.log(`🚀 Server ready at ${url}`); });
Debug
Known issues
breakingThe `apollo-server` package (v3) has been superseded by the `@apollo/server` package (v4+). Future development and active maintenance are focused on the new package, which introduces breaking changes and a new API structure.
fix
Migrate your application to use `@apollo/server`. Refer to the official Apollo Server migration guide for details.
affects: >=3.0.0
gotchaThe `graphql` package is a peer dependency. Ensure you have a compatible version installed, as `apollo-server` v3.13.0 requires `^15.3.0 || ^16.0.0`.
fix
Install a compatible version of `graphql`: `npm install graphql@^16.0.0` or `npm install graphql@^15.3.0`.
affects: >=3.0.0
gotchaWhen migrating to the successor `@apollo/server` (v4+), note that it is ESM-only. Code using CommonJS `require()` will need to be updated to `import` statements and your project configured for ESM.
fix
Refactor your project to use ES modules. For example, change `const { ApolloServer } = require('apollo-server');` to `import { ApolloServer } from '@apollo/server';` and ensure your `package.json` specifies `"type": "module"`.
affects: >=3.0.0
Errors
Common errors & fixes
TypeError: ApolloServer is not a constructor
Attempting to use `require('apollo-server')` to import a version or package (e.g., `@apollo/server` v4+) that is ESM-only, or a misconfigured `package.json`.
fix
Ensure you are importing the correct package for your module system. If using `apollo-server` v3, ensure you're using compatible CJS/ESM. If migrating to `@apollo/server` v4+, update your project to use ESM `import` statements.
Error: Cannot find module 'graphql'
The `graphql` package is a peer dependency and must be explicitly installed alongside `apollo-server`.
fix
Run `npm install graphql` to add the necessary peer dependency.
Syntax Error: Expected Name, found <EOF>
The `typeDefs` string passed to `ApolloServer` contains an incomplete or malformed GraphQL schema definition.
fix
Carefully review your `gql` template literal for any syntax errors in your schema definition (e.g., missing curly braces, incorrect type names, etc.).
Upgrade
Version history
3.13.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources
apollo-server — npm install apollo-server · libregistry