# JavaScript GraphQL libraries

JavaScript GraphQL libraries define a schema for an API and execute GraphQL operations against it. A server library accepts each request over HTTP or WebSocket, then validates and runs the operation through the schema's resolvers. These libraries serve the APIs behind web and mobile apps, partner integrations, and AI agents that query structured data.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [GraphQL.js](#graphql-js) | 270.5M | 20.3K | Nov 2026 | MIT |
| [@graphql-tools/schema](#graphql-tools-schema) | 94.5M | 5.4K | Nov 2026 | MIT |
| [graphql-ws](#graphql-ws) | 63.9M | 1.9K | Nov 2026 | MIT |
| [Envelop](#envelop-core) | 45.8M | 8.5K | Nov 2026 | MIT |
| [Apollo Server](#apollo-server) | 15.2M | 14.0K | Nov 2026 | MIT |
| [GraphQL Yoga](#graphql-yoga) | 11.1M | 8.5K | Nov 2026 | MIT |
| [graphql-http](#graphql-http) | 9.1M | 366 | Sep 2026 | MIT |
| [Mercurius](#mercurius) | 1.3M | 2.5K | Nov 2026 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[GraphQL.js](#graphql-js) has the most monthly downloads in this comparison, at 270.5M.

## Capabilities

| Library | HTTP request handler | Subscription transport | SDL schema building |
| --- | --- | --- | --- |
| [GraphQL.js](#graphql-js) | No | No | Yes |
| [@graphql-tools/schema](#graphql-tools-schema) | No | No | Yes |
| [graphql-ws](#graphql-ws) | No | Yes | No |
| [Envelop](#envelop-core) | No | No | No |
| [Apollo Server](#apollo-server) | Yes | Via plugin | Yes |
| [GraphQL Yoga](#graphql-yoga) | Yes | Yes | Yes |
| [graphql-http](#graphql-http) | Yes | No | No |
| [Mercurius](#mercurius) | Yes | Yes | Yes |

## Libraries

### GraphQL.js

[GitHub](https://github.com/graphql/graphql-js) · [npm](https://www.npmjs.com/package/graphql) · [Docs](https://www.graphql-js.org/api-v17/graphql/)

Builds schemas and executes GraphQL operations as the reference JavaScript runtime.

- Downloads / mo: 270.5M
- Stars: 20.3K
- Last release: 17.1.0
- License: MIT
- Capabilities: [From the GraphQL.js docs](https://www.graphql-js.org/api-v17/graphql/)

**Strengths**

- **Validates queries before execution.** The graphql function validates the query before running its resolvers.
- **Builds schemas directly in code.** Define object types and field resolvers with the schema constructors.

**Watch out for**

- **Subscriptions need a transport layer.** Connect subscription execution to an event system and network transport.
- **Custom pipelines need validation.** Run operation validation separately when building a low-level execution pipeline.

```sh
npm install graphql
```

**keystonejs/keystone** (10.0K stars)

[keystonejs/keystone](https://github.com/keystonejs/keystone) 

```typescript
export function makeContextQueryFn(
  schema: GraphQLSchema,
  operation: 'query' | 'mutation',
  field: GraphQLField<any, unknown>
) {
  const { argumentNodes, variableDefinitions } = getVariablesForGraphQLField(field)
  const rootName = getRootTypeName(field.type)
  const exec = async (args: Record<string, any>, query: string, context: KeystoneContext) => {
    const selectionSet = (
      parse(`fragment x on ${rootName} {${query}}`).definitions[0] as FragmentDefinitionNode
    ).selectionSet

    const document: DocumentNode = {
      kind: Kind.DOCUMENT,
      definitions: [
        {
          kind: Kind.OPERATION_DEFINITION,
          // OperationTypeNode is an ts enum where the values are 'query' | 'mutation' | 'subscription'
          operation: operation as OperationTypeNode,
          selectionSet: {
            kind: Kind.SELECTION_SET,
            selections: [
              {
                kind: Kind.FIELD,
                name: { kind: Kind.NAME, value: field.name },
                arguments: argumentNodes,
                selectionSet: selectionSet,
              },
            ],
          },
          variableDefinitions,
        },
      ],
    }

    const validationErrors = validate(schema, document)

    if (validationErrors.length > 0) {
      throw validationErrors[0]
    }

    const result = await execute({
      schema,
      document,
      contextValue: context,
      variableValues: Object.fromEntries(
        // GraphQL for some reason decides to make undefined values in args
        // skip defaulting for some reason
        // this ofc doesn't technically fully fix it (bc nested things)
        // but for the cases where we care, it does
        Object.entries(args).filter(([, val]) => val !== undefined)
      ),
      rootValue: {},
    })
    if (result.errors?.length) {
      throw result.errors[0]
    }
    return result.data![field.name]
  }

  return (
    _args: {
      query?: string
    } & Record<string, unknown> = {}, // WARNING: sometimes this is undefined somewhere
    context: KeystoneContext
  ) => {
    const { query, ...args } = _args
    return exec(args, query ?? 'id', context) as Promise<any>
  }
}

```

[packages/core/src/lib/context/graphql.ts](https://github.com/keystonejs/keystone/blob/3101ebcf7f1e24db30a6fbf63f2d1ae9fdd20aaa/packages/core/src/lib/context/graphql.ts#L272-L341) · [More projects using GraphQL.js →](https://dashboard.exa.ai/playground/search?q=TypeScript%20applications%20using%20graphql%20to%20build%20GraphQL%20schemas%2C%20validate%20requests%2C%20execute%20operations%20and%20integrate%20server%20hosts&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import { buildSchema, graphql } from 'graphql';

const schema = buildSchema('type Query { hello: String }');
const result = await graphql({ schema, source: '{ hello }', rootValue: { hello: () => 'world' } });

```

From [README.md](https://www.graphql-js.org/api-v17/graphql/)

### @graphql-tools/schema

[GitHub](https://github.com/ardatan/graphql-tools) · [npm](https://www.npmjs.com/package/@graphql-tools/schema) · [Docs](https://the-guild.dev/graphql/tools/docs/generate-schema)

Builds an executable GraphQL.js schema from type definitions and a resolver map.

- Downloads / mo: 94.5M
- Stars: 5.4K
- Last release: 11.0.9
- License: MIT
- Capabilities: [From the @graphql-tools/schema docs](https://the-guild.dev/graphql/tools/docs/generate-schema)

**Strengths**

- **Combines types from many files.** Split type definitions and resolvers across files and merge them into one schema.
- **Extends existing types.** Add fields to the root Query and Mutation types with the extend keyword.

```sh
npm install @graphql-tools/schema graphql
```

**nestjs/graphql** (1.6K stars)

[nestjs/graphql](https://github.com/nestjs/graphql) 

```javascript
async generateSchema<T extends GqlModuleOptions>(
  options: T = { typeDefs: [] } as T,
): Promise<GraphQLSchema> {
  if (options.directiveResolvers) {
    this.logger.warn(
      'The "directiveResolvers" option is ignored (it has had no effect since v9.2.0): the directive resolvers passed through it are never called. Apply the directives with "transformSchema" instead (for example, with "mapSchema()" from "@graphql-tools/utils").',
    );
  }
  const resolvers = this.resolversExplorerService.explore();
  const rawResolvers = extend(
    this.scalarsExplorerService.explore(),
    resolvers,
  );

  const typesResolvers = options.transformResolvers
    ? await options.transformResolvers(rawResolvers)
    : rawResolvers;
  /**
   * Merge field by field, so that an entry of the "resolvers" option does
   * not replace the field resolvers discovered for the same type
   */
  const executableResolvers: IResolvers = mergeResolvers(
    [typesResolvers, options.resolvers].flat(),
  );

  const transformSchema = async (schema: GraphQLSchema) =>
    options.transformSchema ? await options.transformSchema(schema) : schema;

  if (options.autoSchemaFile) {
    const autoGeneratedSchema: GraphQLSchema =
      await this.gqlSchemaBuilder.build(
        options.autoSchemaFile,
        options,
        this.resolversExplorerService.getAllCtors(),
      );
    const executableSchema = makeExecutableSchema({
      resolvers: executableResolvers,
      typeDefs: gql`
        ${printSchema(autoGeneratedSchema)}
      `,
      resolverValidationOptions: {
        ...(options.resolverValidationOptions || {}),
        requireResolversForResolveType: 'ignore',
      },
      inheritResolversFromInterfaces: options.inheritResolversFromInterfaces,
    });
    let schema = options.schema
      ? mergeSchemas({
          schemas: [options.schema, executableSchema],
        })
      : executableSchema;

    const autoGeneratedSchemaConfig = autoGeneratedSchema.toConfig();
    const schemaConfig = this.overrideOrExtendResolvers(
      schema.toConfig(),
      autoGeneratedSchemaConfig,
      executableSchema,
      executableResolvers,
      options.buildSchemaOptions?.fieldMiddleware ?? [],
    );

    schema = new GraphQLSchema(schemaConfig);
    schema = await transformSchema(schema);
    schema = options.sortSchema ? lexicographicSortSchema(schema) : schema;
    return schema;
  }
  if (this.isEmptyValue(options.typeDefs)) {
    const schema = await transformSchema(options.schema);
    return schema;
  }
  const executableSchemaConfig = {
    resolvers: executableResolvers,
    typeDefs: gql`
      ${options.typeDefs}
    `,
    resolverValidationOptions: options.resolverValidationOptions,
    inheritResolversFromInterfaces: options.inheritResolversFromInterfaces,
  };
  /**
   * Merge the type definitions themselves (rather than a schema made
   * executable from them) into the "schema" option, so that a scalar or an
   * enum that both declare keeps the implementation of the "schema" option,
   * unless one is registered on the Nest side
   */
  let schema = options.schema
    ? mergeSchemas({
        schemas: [options.schema],
        ...executableSchemaConfig,
      })
    : makeExecutableSchema(executableSchemaConfig);

  if (options.inheritResolversFromInterfaces) {
    inheritResolversFromInterfaces(
      schema,
      options.schema
        ? mergeResolvers([
            getResolversFromSchema(options.schema),
            executableResolvers,
          ])
        : executableResolvers,
    );
  }
  removeTempField(schema);
  schema = await transformSchema(schema);
  schema = options.sortSchema ? lexicographicSortSchema(schema) : schema;
  return schema;
}

```

[packages/graphql/lib/graphql.factory.ts](https://github.com/nestjs/graphql/blob/c36721932e6bd2114ab3c15779ad870dcd9703cd/packages/graphql/lib/graphql.factory.ts#L42-L148) · [More projects using @graphql-tools/schema →](https://dashboard.exa.ai/playground/search?q=%40graphql-tools/schema%20GitHub%20projects)

**Quickstart**

```javascript
import { makeExecutableSchema } from '@graphql-tools/schema';

const schema = makeExecutableSchema({
  typeDefs: 'type Query { hello: String }',
  resolvers: { Query: { hello: () => 'world' } },
});

```

From [generate-schema](https://the-guild.dev/graphql/tools/docs/generate-schema)

### graphql-ws

[GitHub](https://github.com/enisdenjo/graphql-ws) · [npm](https://www.npmjs.com/package/graphql-ws) · [Docs](https://github.com/enisdenjo/graphql-ws/blob/master/README.md)

Implements the GraphQL over WebSocket Protocol as a server and a client.

- Downloads / mo: 63.9M
- Stars: 1.9K
- Last release: 6.4.3
- License: MIT
- Capabilities: [From the graphql-ws docs](https://github.com/enisdenjo/graphql-ws/blob/master/README.md)

**Strengths**

- **Runs many operations on one socket.** Separate operation IDs let several operations share one connection at the same time.

**Watch out for**

- **Needs graphql-ws on both sides.** Run graphql-ws on the server and the client rather than mixing it with subscriptions-transport-ws.

```sh
npm install graphql-ws graphql ws
```

**prisma/prisma-examples** (6.7K stars)

[prisma/prisma-examples](https://github.com/prisma/prisma-examples) 

```javascript
async function start() {
  /** Create WS Server */
  const wsServer = new WebSocketServer({
    server: httpServer,
    path: '/graphql',
  })

  /** hand-in created schema and have the WS Server start listening */
  const serverCleanup = useServer({ schema, context }, wsServer)

  const server = new ApolloServer<Context>({
    schema,
    plugins: [
      ApolloServerPluginDrainHttpServer({ httpServer }),
      {
        async serverWillStart() {
          return {
            async drainServer() {
              await serverCleanup.dispose()
            },
          }
        },
      },
    ],
  })

  await server.start()
  app.use('/graphql', cors<cors.CorsRequest>(), express.json(), expressMiddleware(server, { context: async () => context }));

  httpServer.listen(PORT, () => {
    console.log(`🚀 Server ready at http://localhost:${PORT}/graphql`)
    console.log(`⏰ Subscriptions ready at http://localhost:${PORT}/graphql`)
    console.log(
      `⭐️ See sample queries: http://pris.ly/e/ts/graphql-subscriptions#using-the-graphql-api`,
    )
  })
}

```

[orm/graphql-subscriptions/src/server.ts](https://github.com/prisma/prisma-examples/blob/45d6bf6193c66bc869240df90c75b2e4b45d008f/orm/graphql-subscriptions/src/server.ts) · [More projects using graphql-ws →](https://dashboard.exa.ai/playground/search?q=graphql-ws%20GitHub%20projects)

**Quickstart**

```javascript
import { GraphQLObjectType, GraphQLSchema, GraphQLString } from "graphql";
import { WebSocketServer } from "ws";
import { useServer } from "graphql-ws/use/ws";
const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: "Query", fields: { hello: { type: GraphQLString, resolve: () => "Hello" } } }) });
useServer({ schema }, new WebSocketServer({ port: 4000 }));

```

From [ws.ts](https://registry.npmjs.org/graphql-ws/latest)

### Envelop

[GitHub](https://github.com/graphql-hive/graphql-yoga) · [npm](https://www.npmjs.com/package/@envelop/core) · [Docs](https://the-guild.dev/graphql/envelop/docs/getting-started)

Wraps the GraphQL parse, validate, execute, and subscribe functions in a plugin system.

- Downloads / mo: 45.8M
- Stars: 8.5K
- Last release: 6.0.1
- License: MIT
- Capabilities: [From the Envelop docs](https://the-guild.dev/graphql/envelop/docs/getting-started)

**Strengths**

- **Adds features as plugins.** Register each feature, such as a parser cache, as a plugin on the base setup.

**Watch out for**

- **No HTTP server included.** Pair Envelop with an HTTP framework or server for production traffic.

```sh
npm install @envelop/core graphql
```

**graphile/crystal** (12.9K stars)

[graphile/crystal](https://github.com/graphile/crystal) 

```javascript
async function getExecutionConfig(ctx) {
          const config = await originalGetExecutionConfig.call(this, ctx);
          const getEnveloped = envelop({
            plugins: [
              // PERF: memoize argument if it makes any difference
              useEngine({
                ...graphql,
                execute: config.execute,
                subscribe: config.subscribe,
                specifiedRules: event.validationRules,
              }),
              useSchema(config.schema),
              useEnvelop(userGetEnveloped),
            ],
          });
          const {
            schema,
            execute,
            subscribe,
            contextFactory,
            parse: envelopedParse,
            validate: envelopedValidate,
          } = getEnveloped(ctx);
          const parseAndValidate = (query: string) => {
            const source = new graphql.Source(query, "GraphQL HTTP Request");
            let document;
            try {
              document = envelopedParse(source);
            } catch (e) {
              return { errors: [e] };
            }
            const errors = envelopedValidate(schema, document);
            return errors.length ? { errors } : { document };
          };

          return {
            ...config,
            contextValue: contextFactory(ctx),
            schema,
            execute,
            subscribe,
            parseAndValidate,
          };
        }

```

[grafast/grafserv/src/envelop/index.ts](https://github.com/graphile/crystal/blob/b3f732391cc2a32d547fb0fdf708b2622a512e01/grafast/grafserv/src/envelop/index.ts#L44-L87) · [More projects using Envelop →](https://dashboard.exa.ai/playground/search?q=%40envelop/core%20GitHub%20projects)

**Quickstart**

```javascript
import * as graphql from 'graphql';
import { envelop, useEngine, useSchema } from '@envelop/core';

const getEnveloped = envelop({ plugins: [
  useEngine(graphql),
  useSchema(graphql.buildSchema('type Query { hello: String }')),
] });
const { schema, parse, execute, contextFactory } = getEnveloped();
const result = await execute({ schema, document: parse('{ __typename }'), contextValue: await contextFactory() });

```

From [getting-started](https://the-guild.dev/graphql/envelop/docs/getting-started)

### Apollo Server

[GitHub](https://github.com/apollographql/apollo-server) · [npm](https://www.npmjs.com/package/@apollo/server) · [Docs](https://www.apollographql.com/docs/apollo-server/api/apollo-server)

Provides a GraphQL request pipeline with standalone and framework-integrated server options.

- Downloads / mo: 15.2M
- Stars: 14.0K
- Last release: 5.5.2
- License: MIT
- Capabilities: [From the Apollo Server docs](https://www.apollographql.com/docs/apollo-server/api/apollo-server)

**Strengths**

- **Includes a standalone HTTP server.** Start a GraphQL endpoint with CORS and body parsing already handled.
- **Caches parsed and validated operations.** Reuse validated documents across requests without caching their query results.

**Watch out for**

- **Standalone HTTP customization is limited.** Use a framework integration for custom middleware, CORS, or other endpoints.
- **Subscriptions need an additional transport.** Add graphql-ws for subscriptions in a non-federated graph.

```sh
npm install @apollo/server 'graphql@^16.11.0'
```

**nestjs/graphql** (1.6K stars)

[nestjs/graphql](https://github.com/nestjs/graphql) 

```typescript
protected async registerExpress(
  options: T,
  { preStartHook }: { preStartHook?: () => void } = {},
) {
  const { expressMiddleware } = await loadPackage(
    '@as-integrations/express5',
    'GraphQLModule',
    () => import('@as-integrations/express5'),
  );

  const { path, typeDefs, resolvers, schema } = options;

  const httpAdapter = this.httpAdapterHost.httpAdapter;

  // Workaround: the landing page requires body to be present
  // otherwise, it shows the "req.body is not set; this probably means you forgot to set up the json middleware before the Apollo Server middleware." error.
  // The latest version of "body-parser" does not set the body if there is no payload.
  // @see https://github.com/nestjs/graphql/issues/3451
  // @see https://github.com/nestjs/nest/pull/14443
  httpAdapter.use(path, (req: any, _: any, next: () => void) => {
    req.body = req.body ?? {};
    next();
  });

  const app = httpAdapter.getInstance();
  const drainHttpServerPlugin = ApolloServerPluginDrainHttpServer({
    httpServer: httpAdapter.getHttpServer(),
  });

  preStartHook?.();

  const server = new ApolloServer({
    typeDefs,
    resolvers,
    schema,
    ...options,
    plugins: [
      ...(options.plugins ?? []),
      drainHttpServerPlugin,
      this.createRejectSubscriptionsPlugin(),
    ],
  });

  await server.start();

  // Register an exact route, as Nest does for its own routes (and as
  // "registerFastify" does): "app.use(path, ...)" would also serve
  // "/graphql/<anything>", out of reach of the middleware the application
  // binds to "path" with "MiddlewareConsumer#forRoutes({ path, method })".
  app.all(
    path,
    expressMiddleware(server, {
      context: options.context,
    }),
  );

  this.apolloServer = server;
}

```

[packages/apollo/lib/drivers/apollo-base.driver.ts](https://github.com/nestjs/graphql/blob/72e4116cde00e619b1021242aeacf91d8221b546/packages/apollo/lib/drivers/apollo-base.driver.ts#L311-L368) · [More projects using Apollo Server →](https://dashboard.exa.ai/playground/search?q=TypeScript%20applications%20using%20%40apollo/server%20to%20build%20GraphQL%20schemas%2C%20validate%20requests%2C%20execute%20operations%20and%20integrate%20server%20hosts&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import { ApolloServer } from '@apollo/server';

const server = new ApolloServer({
  typeDefs: 'type Query { hello: String }',
  resolvers: { Query: { hello: () => 'world' } },
});
await server.start();
const result = await server.executeOperation({ query: '{ hello }' });
await server.stop();

```

From [README.md](https://www.apollographql.com/docs/apollo-server/api/apollo-server)

### GraphQL Yoga

[GitHub](https://github.com/graphql-hive/graphql-yoga) · [npm](https://www.npmjs.com/package/graphql-yoga) · [Docs](https://github.com/graphql-hive/graphql-yoga/blob/237065ae3deda3abec58f69bcc58521652a77328/packages/graphql-yoga/README.md)

Serves GraphQL through a Fetch-based handler with built-in subscription transport.

- Downloads / mo: 11.1M
- Stars: 8.5K
- Last release: 6.1.0
- License: MIT
- Capabilities: [From the GraphQL Yoga docs](https://github.com/graphql-hive/graphql-yoga/blob/237065ae3deda3abec58f69bcc58521652a77328/packages/graphql-yoga/README.md)

**Strengths**

- **Includes subscriptions over server events.** Serve subscriptions through the built-in Server-Sent Events transport.
- **Supports Fetch-based deployment hosts.** Use the Fetch handler across Node, serverless, and worker environments.

**Watch out for**

- **WebSockets need an additional integration.** Add graphql-ws when clients require the WebSocket subscription protocol.
- **Subscription clients must support SSE.** Use a compatible GraphQL-over-SSE client for the default subscription transport.

```sh
npm install graphql-yoga graphql
```

**redwoodjs/graphql** (17.6K stars)

[redwoodjs/graphql](https://github.com/redwoodjs/graphql) 

```typescript
export const createGraphQLYoga = ({
  healthCheckId,
  loggerConfig,
  context,
  getCurrentUser,
  onException,
  generateGraphiQLHeader,
  extraPlugins,
  authDecoder,
  cors,
  services,
  sdls,
  directives = [],
  armorConfig,
  allowedOperations,
  allowIntrospection,
  allowGraphiQL,
  defaultError = 'Something went wrong.',
  graphiQLEndpoint = '/graphql',
  schemaOptions,
  realtime,
  trustedDocuments,
  openTelemetryOptions,
  includeScalars,
}: GraphQLYogaOptions) => {
  let schema: GraphQLSchema
  let redwoodDirectivePlugins = [] as Plugin[]
  const logger = loggerConfig.logger

  const isDevEnv = process.env.NODE_ENV === 'development'

  try {
    // @NOTE: Directives are optional
    const projectDirectives = makeDirectivesForPlugin(directives)

    if (projectDirectives.length > 0) {
      ;(redwoodDirectivePlugins as useRedwoodDirectiveReturn[]) =
        projectDirectives.map((directive) =>
          useRedwoodDirective(directive as DirectivePluginOptions),
        )
    }

    // @NOTE: Subscriptions are optional and only work in the context of a server
    let projectSubscriptions = [] as RedwoodSubscription[]

    if (realtime?.subscriptions?.subscriptions) {
      projectSubscriptions = makeSubscriptions(
        realtime.subscriptions.subscriptions,
      )
    }

    schema = makeMergedSchema({
      sdls,
      services,
      directives: projectDirectives,
      subscriptions: projectSubscriptions,
      schemaOptions,
      includeScalars,
    })
  } catch (e) {
    logger.fatal(e as Error, '\n ⚠️ GraphQL server crashed \n')

    if (onException) {
      onException()
    }

    // Forcefully crash the graphql server
    // so users know that a misconfiguration has happened
    process.exit(1)
  }

  try {
    // Important: Plugins are executed in order of their usage, and inject functionality serially,
    // so the order here matters
    const plugins: Plugin<any>[] = []

    const { disableIntrospection } = configureGraphQLIntrospection({
      allowIntrospection,
    })

    if (disableIntrospection) {
      plugins.push(useDisableIntrospection())
    }

    // Custom Redwood plugins
    plugins.push(useRedwoodAuthContext(getCurrentUser, authDecoder))
    plugins.push(useRedwoodGlobalContextSetter())

    if (context) {
      plugins.push(useRedwoodPopulateContext(context))
    }

    // Custom Redwood plugins
    plugins.push(...redwoodDirectivePlugins)

    // Custom Redwood OpenTelemetry plugin
    if (openTelemetryOptions !== undefined) {
      plugins.push(useRedwoodOpenTelemetry(openTelemetryOptions))
    }

    // Secure the GraphQL server
    plugins.push(useArmor(logger, armorConfig))

    // Only allow execution of specific operation types
    const defaultAllowedOperations = [
      OperationTypeNode.QUERY,
      OperationTypeNode.MUTATION,
    ]

    // allow subscriptions if using them (unless you override)
    if (realtime?.subscriptions?.subscriptions) {
      defaultAllowedOperations.push(OperationTypeNode.SUBSCRIPTION)
    }

    plugins.push(
      useFilterAllowedOperations(allowedOperations || defaultAllowedOperations),
    )

    if (trustedDocuments && !trustedDocuments.disabled) {
      plugins.push(useRedwoodTrustedDocuments(trustedDocuments))
    }

    // App-defined plugins
    if (extraPlugins && extraPlugins.length > 0) {
      plugins.push(...extraPlugins)
    }

    plugins.push(useRedwoodError(logger))

    plugins.push(
      useReadinessCheck({
        endpoint: graphiQLEndpoint + '/readiness',
        check: async ({ request }) => {
          try {
            // if we can reach the health check endpoint ...
            const response = await yoga.fetch(
              new URL(graphiQLEndpoint + '/health', request.url),
            )

            const expectedHealthCheckId = healthCheckId || 'yoga'

            // ... and the health check id's match the request and response's
            const status =
              response.headers.get('x-yoga-id') === expectedHealthCheckId &&
              request.headers.get('x-yoga-id') === expectedHealthCheckId

            // then we're good to go (or not)
            return status
          } catch (err) {
            logger.error(err)
            return false
          }
        },
      }),
    )

    // Must be "last" in plugin chain, but before error masking
    // so can process any data added to results and extensions
    plugins.push(useRedwoodLogger(loggerConfig))

    const yoga = createYoga({
      id: healthCheckId,
      landingPage: isDevEnv,
      schema,
      plugins,
      maskedErrors: {
        errorMessage: defaultError,
        isDev: isDevEnv,
      },
      logging: logger,
      healthCheckEndpoint: graphiQLEndpoint + '/health',
      graphqlEndpoint: graphiQLEndpoint,
      graphiql: configureGraphiQLPlayground({
        allowGraphiQL,
        generateGraphiQLHeader,
      }),
      cors: (request: Request) => {
        const requestOrigin = request.headers.get('origin')
        return mapRwCorsOptionsToYoga(cors, requestOrigin)
      },
    })

    return { yoga, logger }
  } catch (e) {
    if (onException) {
      onException()
    }
    throw e
  }
}

```

[packages/graphql-server/src/createGraphQLYoga.ts](https://github.com/redwoodjs/graphql/blob/a7852fb92d0e4ac2bcce1d9a755717ba6cf53ffd/packages/graphql-server/src/createGraphQLYoga.ts#L32-L221) · [More projects using GraphQL Yoga →](https://dashboard.exa.ai/playground/search?q=TypeScript%20applications%20using%20graphql-yoga%20to%20build%20GraphQL%20schemas%2C%20validate%20requests%2C%20execute%20operations%20and%20integrate%20server%20hosts&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import { createYoga, createSchema } from 'graphql-yoga';

const yoga = createYoga({ schema: createSchema({
  typeDefs: 'type Query { hello: String }',
  resolvers: { Query: { hello: () => 'world' } },
}) });
const response = await yoga.fetch('http://localhost/graphql?query={hello}');

```

From [README.md](https://github.com/graphql-hive/graphql-yoga/blob/main/packages/graphql-yoga/src/server.ts)

### graphql-http

[GitHub](https://github.com/graphql/graphql-http) · [npm](https://www.npmjs.com/package/graphql-http) · [Docs](https://github.com/graphql/graphql-http/blob/main/README.md)

Implements the GraphQL over HTTP spec as a server handler, a client, and an audit suite.

- Downloads / mo: 9.1M
- Stars: 366
- Last release: 1.23.1
- License: MIT
- Capabilities: [From the graphql-http docs](https://github.com/graphql/graphql-http/blob/main/README.md)

**Strengths**

- **Plugs into Node.js HTTP servers.** createHandler returns a request handler for a Node.js HTTP server.

**Watch out for**

- **No subscriptions.** Add graphql-ws or graphql-sse for subscriptions.

```sh
npm install graphql-http graphql express
```

**marmelab/json-graphql-server** (1.9K stars)

[marmelab/json-graphql-server](https://github.com/marmelab/json-graphql-server) 

```javascript
(data: Data) => {
    const graphqlHandler = createHandler({
        schema: schemaBuilder(data),
    });

    const expressMiddleware: Handler = (req, res, next) => {
        if (req.is('application/json')) {
            return graphqlHandler(req, res, next);
        }

        return graphiqlHandler(req, res, next);
    };

    return expressMiddleware;
}

```

[src/jsonGraphqlExpress.ts](https://github.com/marmelab/json-graphql-server/blob/0affaa2bebdbd0053a4aeb2ae20d2680162712ad/src/jsonGraphqlExpress.ts#L51-L65) · [More projects using graphql-http →](https://dashboard.exa.ai/playground/search?q=graphql-http%20GitHub%20projects)

**Quickstart**

```javascript
import express from 'express';
import { buildSchema } from 'graphql';
import { createHandler } from 'graphql-http/lib/use/express';

const schema = buildSchema('type Query { hello: String }');
const app = express();
app.all('/graphql', createHandler({ schema, rootValue: { hello: () => 'world' } }));
app.listen(4000);

```

From [README.md](https://github.com/graphql/graphql-http/blob/main/README.md)

### Mercurius

[GitHub](https://github.com/mercurius-js/mercurius) · [npm](https://www.npmjs.com/package/mercurius) · [Docs](https://github.com/mercurius-js/mercurius/blob/master/docs/api/options.md)

Adds GraphQL execution, endpoints, and subscriptions to a Fastify application.

- Downloads / mo: 1.3M
- Stars: 2.5K
- Last release: 16.12.2
- License: MIT
- Capabilities: [From the Mercurius docs](https://github.com/mercurius-js/mercurius/blob/master/docs/api/options.md)

**Strengths**

- **Combines repeated resolver data requests.** Loaders combine resolver requests into bulk queries and can cache results.
- **Caches query parsing and validation.** Reuse cached query parsing and validation work.

**Watch out for**

- **Requires a Fastify application.** Integrate GraphQL through the Fastify host rather than a standalone runtime.
- **Deferred responses exclude JIT compilation.** Choose deferred responses or JIT compilation; they cannot run together.

```sh
npm install mercurius fastify graphql
```

**marcoturi/fastify-boilerplate** (476 stars)

[marcoturi/fastify-boilerplate](https://github.com/marcoturi/fastify-boilerplate) 

```typescript
export default async function findUsersResolver(fastify: FastifyRouteInstance) {
  fastify.graphql.defineResolvers({
    Query: {
      findUsers: async (_, args) => {
        const result = await fastify.queryBus.execute(findUsersQuery(validateArgs(args)));
        return mapPage(result, fastify.diContainer.cradle.userMapper.toResponse);
      },
    },
  });
}

```

[src/modules/user/queries/find-users/find-users.resolver.ts](https://github.com/marcoturi/fastify-boilerplate/blob/db4f86d5691da005e5619e3628e7012b33df9634/src/modules/user/queries/find-users/find-users.resolver.ts#L8-L17) · [More projects using Mercurius →](https://dashboard.exa.ai/playground/search?q=TypeScript%20applications%20using%20mercurius%20to%20build%20GraphQL%20schemas%2C%20validate%20requests%2C%20execute%20operations%20and%20integrate%20server%20hosts&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import Fastify from 'fastify';
import mercurius from 'mercurius';

const app = Fastify();
app.register(mercurius, {
  schema: 'type Query { hello: String }',
  resolvers: { Query: { hello: () => 'world' } },
});
await app.ready();
const result = await app.graphql('{ hello }');
await app.close();

```

From [README.md](https://github.com/mercurius-js/mercurius/blob/master/docs/api/options.md)

## FAQ

### Which JavaScript GraphQL library should I use?

GraphQL.js supplies the schema and execution runtime that the server libraries build on. For a full HTTP server, Apollo Server and GraphQL Yoga wrap that runtime with request handling and plugins. Mercurius fits an app that already runs on Fastify.

### What is Apollo Server?

Apollo Server is a GraphQL server for Node.js with a standalone web server that handles CORS and body parsing. A framework integration replaces the standalone server when an app needs custom middleware or other endpoints.

### What does GraphQL Tools do?

The @graphql-tools/schema package builds an executable GraphQL.js schema from type definitions in the GraphQL schema language and a resolver object, through the makeExecutableSchema function.

### What is graphql-ws?

graphql-ws implements the GraphQL over WebSocket Protocol as both a server and a client. The server and the client both need graphql-ws, because it does not work with the deprecated subscriptions-transport-ws protocol.

### GraphQL Yoga vs Apollo Server: which should I use?

GraphQL Yoga serves GraphQL through a Fetch handler that runs in Node.js, serverless, and worker environments, with subscriptions over Server-Sent Events built in. Apollo Server includes a standalone HTTP server and needs graphql-ws added for subscriptions in a non-federated graph.

### How do Apollo Server subscriptions work?

Apollo Server does not carry subscriptions on its own. A non-federated graph adds the graphql-ws library to the server for the subscription transport.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript GraphQL libraries GraphQL.js Apollo Server Yoga Mercurius code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
