apollo-server vs graphql-compose vs graphql-modules vs graphql-tools vs nexus vs type-graphql
GraphQL Server Libraries
apollo-servergraphql-composegraphql-modulesgraphql-toolsnexustype-graphqlSimilar Packages:

GraphQL Server Libraries

These libraries provide various tools and frameworks for building GraphQL servers in Node.js. They simplify the process of creating a GraphQL API by offering features like schema definition, resolvers, and middleware integration. Each library has its own strengths and use cases, catering to different developer preferences and project requirements.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
apollo-server013,93426.6 kB842 years agoMIT
graphql-compose01,210909 kB85a year agoMIT
graphql-modules0-207 kB-3 months agoMIT
graphql-tools05,4252.61 kB1585 days agoMIT
nexus03,4292.17 MB254-MIT
type-graphql08,088351 kB1143 months agoMIT

Feature Comparison: apollo-server vs graphql-compose vs graphql-modules vs graphql-tools vs nexus vs type-graphql

Schema Definition

  • apollo-server:

    Apollo Server allows you to define your schema using SDL or programmatically, providing flexibility in how you structure your GraphQL API. It supports both query and mutation types out of the box.

  • graphql-compose:

    GraphQL Compose enables you to build your schema programmatically with a focus on type composition, allowing for complex types and relationships to be defined in a more dynamic way.

  • graphql-modules:

    GraphQL Modules promotes a modular approach to schema definition, allowing you to encapsulate types, resolvers, and other related functionalities within individual modules, enhancing maintainability.

  • graphql-tools:

    GraphQL Tools offers a schema-first approach using SDL, along with utilities for merging and extending schemas, making it easy to manage complex GraphQL APIs.

  • nexus:

    Nexus provides a code-first approach to schema definition, allowing you to define your types and fields using a fluent API, which integrates well with TypeScript for type safety.

  • type-graphql:

    TypeGraphQL uses decorators to define your schema, allowing you to create resolvers and types in a more declarative manner, which can significantly reduce boilerplate code.

Type Safety

  • apollo-server:

    Apollo Server does not enforce type safety out of the box, but it can be integrated with TypeScript for type definitions, providing some level of type safety when used with TypeScript.

  • graphql-compose:

    GraphQL Compose is flexible but does not inherently provide type safety; however, it can be used alongside TypeScript to enhance type definitions and validation.

  • graphql-modules:

    GraphQL Modules does not focus on type safety directly but can be integrated with TypeScript to ensure type safety across your modular GraphQL setup.

  • graphql-tools:

    GraphQL Tools does not provide type safety features by itself, but it can be used in conjunction with TypeScript to create type-safe schemas and resolvers.

  • nexus:

    Nexus is designed with TypeScript in mind, providing full type safety for your GraphQL schema, ensuring that your types are consistent and reducing runtime errors.

  • type-graphql:

    TypeGraphQL fully embraces TypeScript, allowing you to define your GraphQL schema with strong type safety, ensuring that your resolvers and types are correctly typed.

Modularity

  • apollo-server:

    Apollo Server is not inherently modular; it is more of a standalone server solution. However, you can structure your codebase to be modular by organizing resolvers and types separately.

  • graphql-compose:

    GraphQL Compose allows for modular schema design by enabling the composition of types and resolvers, making it easier to manage complex schemas.

  • graphql-modules:

    GraphQL Modules is explicitly designed for modularity, allowing you to encapsulate related functionality into modules, which enhances code organization and reusability.

  • graphql-tools:

    GraphQL Tools does not provide a modular architecture by itself but can be used to stitch together multiple schemas, allowing for a modular approach to API design.

  • nexus:

    Nexus supports modularity through its code-first approach, allowing you to define types and resolvers in a structured manner, promoting better organization in larger projects.

  • type-graphql:

    TypeGraphQL can be organized modularly, but it does not enforce a modular structure; however, you can create modules by grouping related resolvers and types.

Ease of Use

  • apollo-server:

    Apollo Server is known for its ease of use, with a straightforward setup process and extensive documentation, making it accessible for beginners and experienced developers alike.

  • graphql-compose:

    GraphQL Compose has a steeper learning curve due to its programmatic nature, but it offers powerful features for those willing to invest time in learning its API.

  • graphql-modules:

    GraphQL Modules requires some understanding of modular architecture, which may add complexity for beginners, but it greatly benefits larger applications.

  • graphql-tools:

    GraphQL Tools is relatively easy to use, especially for those familiar with SDL, and provides a clear way to define and manage schemas.

  • nexus:

    Nexus is user-friendly for TypeScript developers, offering a clear API that simplifies schema creation, but it may require some learning for those unfamiliar with its patterns.

  • type-graphql:

    TypeGraphQL is designed to be intuitive for TypeScript users, leveraging decorators to simplify schema definition, making it easy to use for those familiar with TypeScript.

Community and Ecosystem

  • apollo-server:

    Apollo Server has a large and active community, with extensive resources, tutorials, and integrations available, making it a popular choice for many developers.

  • graphql-compose:

    GraphQL Compose has a smaller community compared to Apollo, but it is well-documented and has a dedicated user base, especially among those who need advanced schema composition features.

  • graphql-modules:

    GraphQL Modules has a niche community focused on modular architecture, with growing resources and examples available for developers looking to adopt this approach.

  • graphql-tools:

    GraphQL Tools is widely used and has a strong community, providing many resources and plugins to enhance its functionality.

  • nexus:

    Nexus is gaining popularity, especially among TypeScript developers, and has a growing ecosystem of plugins and tools to support its use.

  • type-graphql:

    TypeGraphQL has a passionate community of TypeScript developers, with a wealth of resources and examples available, making it a solid choice for TypeScript-centric projects.

How to Choose: apollo-server vs graphql-compose vs graphql-modules vs graphql-tools vs nexus vs type-graphql

  • apollo-server:

    Choose Apollo Server if you need a straightforward and robust solution for building a GraphQL server with features like built-in support for subscriptions, caching, and performance tracing. It is ideal for developers looking for an easy setup and integration with Apollo Client.

  • graphql-compose:

    Select GraphQL Compose if you want a powerful and flexible way to build your GraphQL schema programmatically. It allows for advanced schema composition and is great for projects that require dynamic schema generation and complex type definitions.

  • graphql-modules:

    Opt for GraphQL Modules if you are building a large-scale application that requires modular architecture. It helps organize your GraphQL code into modules, making it easier to manage and scale your application over time.

  • graphql-tools:

    Use GraphQL Tools if you want to create a schema using SDL (Schema Definition Language) and need utilities for schema stitching and mocking. It is particularly useful for projects that require merging multiple schemas or creating a mock server for testing.

  • nexus:

    Choose Nexus if you prefer a type-safe approach to building your GraphQL schema using TypeScript. It provides a code-first approach that integrates seamlessly with TypeScript, making it ideal for developers who prioritize type safety and developer experience.

  • type-graphql:

    Select TypeGraphQL if you want to leverage decorators and TypeScript to define your GraphQL schema. It simplifies the process of creating resolvers and types, making it suitable for developers who enjoy using TypeScript and want to minimize boilerplate code.

README for apollo-server

Apollo Server

A TypeScript GraphQL Server for Express, Koa, Hapi, Lambda, and more.

npm version Build Status Join the community forum Read CHANGELOG

Apollo Server is a community-maintained open-source GraphQL server. It works with many Node.js HTTP server frameworks, or can run on its own with a built-in Express server. Apollo Server works with any GraphQL schema built with GraphQL.js--or define a schema's type definitions using schema definition language (SDL).

Read the documentation for information on getting started and many other use cases and follow the CHANGELOG for updates.

Principles

Apollo Server is built with the following principles in mind:

  • By the community, for the community: Its development is driven by the needs of developers.
  • Simplicity: By keeping things simple, it is more secure and easier to implement and contribute.
  • Performance: It is well-tested and production-ready.

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

Getting started

To get started with Apollo Server:

  • Install with npm install apollo-server-<integration> graphql
  • Write a GraphQL schema
  • Use one of the following snippets

There are two ways to install Apollo Server:

  • Standalone: For applications that do not require an existing web framework, use the apollo-server package.
  • Integrations: For applications with a web framework (e.g. express, koa, hapi, etc.), use the appropriate Apollo Server integration package.

For more info, please refer to the Apollo Server docs.

Installation: Standalone

In a new project, install the apollo-server and graphql dependencies using:

npm install apollo-server graphql

Then, create an index.js which defines the schema and its functionality (i.e. resolvers):

const { ApolloServer, gql } = require('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}`);
});

Due to its human-readability, we recommend using schema-definition language (SDL) to define a GraphQL schema--a GraphQLSchema object from graphql-js can also be specified instead of typeDefs and resolvers using the schema property:

const server = new ApolloServer({
  schema: ...
});

Finally, start the server using node index.js and go to the URL returned on the console.

For more details, check out the Apollo Server Getting Started guide and the fullstack tutorial.

For questions, the Apollo community forum is a great place to get help.

Installation: Integrations

While the standalone installation above can be used without making a decision about which web framework to use, the Apollo Server integration packages are paired with specific web frameworks (e.g. Express, Koa, hapi).

The following web frameworks have Apollo Server integrations, and each of these linked integrations has its own installation instructions and examples on its package README.md:

Context

A request context is available for each request. When context is defined as a function, it will be called on each request and will receive an object containing a req property, which represents the request itself.

By returning an object from the context function, it will be available as the third positional parameter of the resolvers:

new ApolloServer({
  typeDefs,
  resolvers: {
    Query: {
      books: (parent, args, context, info) => {
        console.log(context.myProperty); // Will be `true`!
        return books;
      },
    }
  },
  context: async ({ req }) => {
    return {
      myProperty: true
    };
  },
})

Documentation

The Apollo Server documentation contains additional details on how to get started with GraphQL and Apollo Server.

The raw Markdown source of the documentation is available within the docs/ directory of this monorepo--to contribute, please use the Edit on GitHub buttons at the bottom of each page.

Development

If you wish to develop or contribute to Apollo Server, we suggest the following:

  • Fork this repository

  • Install Direnv (a tool that automatically sets up environment variables in project directories) or nvm. We use nvm to ensure we're running the expected version of Node (and we use Direnv to install and run nvm automatically).

  • Install the Apollo Server project on your computer

git clone https://github.com/[your-user]/apollo-server
cd apollo-server
direnv allow  # sets up nvm for you; if you installed nvm yourself, try `nvm install` instead
  • Build and test
npm install
npm test
  • To run individual test files, run npm run pretest && npx jest packages/apollo-server-foo/src/__tests__/bar.test.ts. Note that you do need to re-compile TypeScript before each time you run a test, or changes across packages may not be picked up. Instead of running npm run pretest from scratch before each test run, you can also run tsc --build tsconfig.json --watch in another shell, or use the VSCode Run Build Task to run that for you.

Community

Are you stuck? Want to contribute? Come visit us in the Apollo community forum!

Maintainers

Who is Apollo?

Apollo builds open-source software and a graph platform to unify GraphQL across your apps and services. We help you ship faster with:

  • Apollo Studio โ€“ A free, end-to-end platform for managing your GraphQL lifecycle. Track your GraphQL schemas in a hosted registry to create a source of truth for everything in your graph. Studio provides an IDE (Apollo Explorer) so you can explore data, collaborate on queries, observe usage, and safely make schema changes.
  • Apollo Federation โ€“ The industry-standard open architecture for building a distributed graph. Use Apolloโ€™s gateway to compose a unified graph from multiple subgraphs, determine a query plan, and route requests across your services.
  • Apollo Client โ€“ The most popular GraphQL client for the web. Apollo also builds and maintains Apollo iOS and Apollo Android.
  • Apollo Server โ€“ A production-ready JavaScript GraphQL server that connects to any microservice, API, or database. Compatible with all popular JavaScript frameworks and deployable in serverless environments.

Learn how to build with Apollo

Check out the Odyssey learning platform, the perfect place to start your GraphQL journey with videos and interactive code challenges. Join the Apollo Community to interact with and get technical help from the GraphQL community.