graphql vs express-graphql vs apollo
GraphQL Libraries for Node.js Comparison
1 Year
graphqlexpress-graphqlapolloSimilar Packages:
What's GraphQL Libraries for Node.js?

GraphQL libraries for Node.js provide tools and frameworks to build GraphQL APIs, allowing developers to define a schema, handle queries, and manage data fetching in a more efficient manner compared to traditional REST APIs. These libraries facilitate the creation of flexible and powerful APIs that enable clients to request exactly the data they need, reducing over-fetching and under-fetching issues. They also support features like real-time updates and subscriptions, making them suitable for modern web applications that require dynamic data handling.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
graphql16,120,68120,2001.37 MB16515 days agoMIT
express-graphql308,6016,313-554 years agoMIT
apollo127,1483,043288 kB382-MIT
Feature Comparison: graphql vs express-graphql vs apollo

Integration

  • graphql:

    The GraphQL package is the core library that implements the GraphQL specification. It does not provide any specific integration features but allows developers to build their own GraphQL server from scratch, giving them the freedom to customize the implementation as needed.

  • express-graphql:

    Express-GraphQL is designed to work directly with the Express framework, allowing developers to easily add GraphQL capabilities to their existing Express applications. It provides a simple middleware that can be integrated into any Express app, making it straightforward to set up and use.

  • apollo:

    Apollo provides seamless integration with various front-end frameworks and libraries, such as React, Angular, and Vue. It offers a complete suite of tools, including Apollo Client, which simplifies data fetching and state management on the client side, making it easier to build responsive applications.

Complexity

  • graphql:

    The GraphQL library is the most basic option, requiring developers to handle all aspects of the GraphQL server implementation. This can lead to increased complexity as developers need to manage everything from schema definition to resolver functions without any built-in conveniences.

  • express-graphql:

    Express-GraphQL is relatively simple and easy to use, making it a good choice for developers who want to get started with GraphQL quickly. It requires minimal configuration and is straightforward to set up, making it suitable for small to medium-sized applications.

  • apollo:

    Apollo introduces additional complexity due to its extensive features and ecosystem. While it offers powerful capabilities, developers need to understand its caching mechanisms, state management, and how to effectively use its tools to fully leverage its potential.

Performance

  • graphql:

    The performance of a GraphQL server built with the GraphQL library depends heavily on how it is implemented. Developers have full control over optimizations, but this also means they must be diligent in writing efficient resolvers and managing data fetching to avoid performance bottlenecks.

  • express-graphql:

    Express-GraphQL is lightweight and performs well for most use cases. However, performance can depend on how well the resolvers are implemented and the complexity of the queries being executed. Developers need to be mindful of optimizing their resolvers to ensure good performance.

  • apollo:

    Apollo Client includes advanced caching strategies that optimize data fetching and minimize network requests, improving the overall performance of applications. It intelligently manages data and updates the UI efficiently, which is particularly beneficial for applications with complex data requirements.

Community and Ecosystem

  • graphql:

    The GraphQL library is the foundation of the GraphQL ecosystem and has a strong community backing. However, since it is a lower-level library, developers may need to rely on additional libraries and tools to build a complete solution, which can lead to fragmentation.

  • express-graphql:

    Express-GraphQL has a smaller community compared to Apollo but benefits from the larger Express community. It is well-documented and has a straightforward approach, making it easy for developers to find resources and support for basic GraphQL implementations.

  • apollo:

    Apollo has a large and active community, providing extensive documentation, tutorials, and third-party tools. The ecosystem includes various libraries and integrations that enhance its capabilities, making it a popular choice for developers looking for robust support and resources.

Learning Curve

  • graphql:

    The GraphQL library requires a solid understanding of GraphQL concepts and principles. While it offers flexibility, the learning curve can be steep for those unfamiliar with building GraphQL servers from scratch.

  • express-graphql:

    Express-GraphQL is easy to learn, especially for developers already familiar with Express. Its straightforward setup and minimal configuration make it accessible for those new to GraphQL, allowing for a quicker onboarding process.

  • apollo:

    Apollo has a steeper learning curve due to its extensive features and concepts like caching, state management, and subscriptions. Developers may need to invest time in understanding how to effectively use Apollo's tools to maximize their benefits.

How to Choose: graphql vs express-graphql vs apollo
  • graphql:

    Choose GraphQL if you are looking for the core library to implement GraphQL specifications and want to build your own custom server without any framework constraints. It is best for developers who want complete control over their GraphQL implementation and are comfortable with more manual setup.

  • express-graphql:

    Choose Express-GraphQL if you are looking for a lightweight and straightforward way to integrate GraphQL into your existing Express application. It is suitable for developers who prefer minimal setup and want to quickly get started with GraphQL without additional overhead.

  • apollo:

    Choose Apollo if you need a comprehensive solution that includes client and server capabilities, advanced caching, and state management features. Apollo is ideal for applications that require complex data interactions and want to leverage its extensive ecosystem, including tools for testing and performance monitoring.

README for graphql

GraphQLConf 2025 Banner: September 08-10, Amsterdam. Hosted by the GraphQL Foundation

GraphQL.js

The JavaScript reference implementation for GraphQL, a query language for APIs created by Facebook.

npm version Build Status Coverage Status

See more complete documentation at https://graphql.org/ and https://graphql.org/graphql-js/.

Looking for help? Find resources from the community.

Getting Started

A general overview of GraphQL is available in the README for the Specification for GraphQL. That overview describes a simple set of GraphQL examples that exist as tests in this repository. A good way to get started with this repository is to walk through that README and the corresponding tests in parallel.

Using GraphQL.js

Install GraphQL.js from npm

With npm:

npm install --save graphql

or using yarn:

yarn add graphql

GraphQL.js provides two important capabilities: building a type schema and serving queries against that type schema.

First, build a GraphQL type schema which maps to your codebase.

import {
  graphql,
  GraphQLSchema,
  GraphQLObjectType,
  GraphQLString,
} from 'graphql';

var schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'RootQueryType',
    fields: {
      hello: {
        type: GraphQLString,
        resolve() {
          return 'world';
        },
      },
    },
  }),
});

This defines a simple schema, with one type and one field, that resolves to a fixed value. The resolve function can return a value, a promise, or an array of promises. A more complex example is included in the top-level tests directory.

Then, serve the result of a query against that type schema.

var source = '{ hello }';

graphql({ schema, source }).then((result) => {
  // Prints
  // {
  //   data: { hello: "world" }
  // }
  console.log(result);
});

This runs a query fetching the one field defined. The graphql function will first ensure the query is syntactically and semantically valid before executing it, reporting errors otherwise.

var source = '{ BoyHowdy }';

graphql({ schema, source }).then((result) => {
  // Prints
  // {
  //   errors: [
  //     { message: 'Cannot query field BoyHowdy on RootQueryType',
  //       locations: [ { line: 1, column: 3 } ] }
  //   ]
  // }
  console.log(result);
});

Note: Please don't forget to set NODE_ENV=production if you are running a production server. It will disable some checks that can be useful during development but will significantly improve performance.

Want to ride the bleeding edge?

The npm branch in this repository is automatically maintained to be the last commit to main to pass all tests, in the same form found on npm. It is recommended to use builds deployed to npm for many reasons, but if you want to use the latest not-yet-released version of graphql-js, you can do so by depending directly on this branch:

npm install graphql@git://github.com/graphql/graphql-js.git#npm

Experimental features

Each release of GraphQL.js will be accompanied by an experimental release containing support for the @defer and @stream directive proposal. We are hoping to get community feedback on these releases before the proposal is accepted into the GraphQL specification. You can use this experimental release of GraphQL.js by adding the following to your project's package.json file.

"graphql": "experimental-stream-defer"

Community feedback on this experimental release is much appreciated and can be provided on the issue created for this purpose.

Using in a Browser

GraphQL.js is a general-purpose library and can be used both in a Node server and in the browser. As an example, the GraphiQL tool is built with GraphQL.js!

Building a project using GraphQL.js with webpack or rollup should just work and only include the portions of the library you use. This works because GraphQL.js is distributed with both CommonJS (require()) and ESModule (import) files. Ensure that any custom build configurations look for .mjs files!

Contributing

We actively welcome pull requests. Learn how to contribute.

This repository is managed by EasyCLA. Project participants must sign the free (GraphQL Specification Membership agreement before making a contribution. You only need to do this one time, and it can be signed by individual contributors or their employers.

To initiate the signature process please open a PR against this repo. The EasyCLA bot will block the merge if we still need a membership agreement from you.

You can find detailed information here. If you have issues, please email operations@graphql.org.

If your company benefits from GraphQL and you would like to provide essential financial support for the systems and people that power our community, please also consider membership in the GraphQL Foundation.

Changelog

Changes are tracked as GitHub releases.

License

GraphQL.js is MIT-licensed.