Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

GraphQL · Class

ApolloServer

ApolloServer is Apollo’s JavaScript GraphQL server. Construct it with schema definitions and resolvers, then run it standalone or connect it to a Node.js HTTP framework.

How it works

ApolloServer creates a GraphQL server from a schema definition and resolver map. The standalone starter attaches it to a built-in HTTP server; integrations are also available for Node.js frameworks and serverless environments.

Syntax

new ApolloServer({ typeDefs, resolvers })

Parameters

NameTypeDescription
typeDefsstringGraphQL schema written as a schema definition string.
resolversobjectMap of resolver functions that return field data.

Returns

An ApolloServer instance that can be started with a standalone server or connected through a framework integration.

Key points

  • Apollo Server is a JavaScript GraphQL server designed to run with Node.js HTTP frameworks.
  • Its setup begins by declaring the GraphQL schema, such as a Query type and its fields.
  • Resolvers are supplied as a map of functions that produce values for schema fields.
  • Create the server by passing the schema definitions and resolver map to the ApolloServer constructor.
  • The platform exposes a plugin API for extending server behavior.
  • Documented operational features include caching, automatic persisted queries, and CSRF prevention.

Common mistakes

  • The standalone starter is convenient for a basic server, but applications using other HTTP frameworks or serverless environments should use an appropriate integration.

Example: Minimal Apollo Server

import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";

const typeDefs = `#graphql
  type Query {
    hello: String
  }
`;

const resolvers = {
  Query: { hello: () => "Hello, world!" }
};

const server = new ApolloServer({ typeDefs, resolvers });
const { url } = await startStandaloneServer(server);
console.log(`Server ready at ${url}`);

Defines a schema and resolver, creates Apollo Server with them, and starts its standalone HTTP server.

When to use it

Standalone GraphQL service

Building a small Node.js GraphQL API without selecting an HTTP framework.

Framework integration

Embedding GraphQL in an existing Node.js web application.

Performance and security features

Improving API operations and protection.

Interview questions

QWhat inputs does ApolloServer need to serve a GraphQL API?

ApolloServer is constructed with schema definitions and resolvers. The schema describes the available GraphQL operations, while resolvers provide the functions that return field data.

Follow-up: How would you adapt it to an existing web application? Use Apollo Server's framework integration API instead of relying on the built-in standalone HTTP server.

QHow do you start an Apollo Server instance?

After construction, the server can be passed to startStandaloneServer, which starts Apollo Server's built-in HTTP server and returns its URL. The server can also work with Node.js HTTP frameworks through integrations.

Follow-up: What additional capabilities are documented? Apollo Server provides a plugin API, Apollo Studio integration, caching, automatic persisted queries, and CSRF prevention.

QWhat ecosystem does Apollo Server target?

Apollo Server is a JavaScript GraphQL server that works with any Node.js HTTP framework. Its basic setup uses the @apollo/server package together with graphql.

Follow-up: What does the standalone example demonstrate? It installs both packages, declares a Query type, supplies a resolver, constructs ApolloServer, and starts the server.

  • GraphQL schema
  • resolvers
  • startStandaloneServer
  • Express
  • Apollo Client
  • Apollo Router
  • Apollo Studio
  • plugin API

Source: Tools and Libraries. Checked 2026-10-15.