graphql vs graphql-yoga vs express-graphql vs apollo-server
GraphQL Server Bibliotheken
graphqlgraphql-yogaexpress-graphqlapollo-serverÄhnliche Pakete:

GraphQL Server Bibliotheken

GraphQL Server Bibliotheken bieten eine strukturierte Möglichkeit, GraphQL APIs zu erstellen und zu verwalten. Diese Bibliotheken ermöglichen es Entwicklern, Datenabfragen und -mutationen effizient zu definieren und zu verarbeiten, indem sie eine flexible und leistungsstarke Schnittstelle bereitstellen, die es Frontend-Anwendungen ermöglicht, genau die Daten zu erhalten, die sie benötigen. Jede dieser Bibliotheken hat ihre eigenen Stärken und Anwendungsfälle, die sie für verschiedene Projekte geeignet machen.

npm-Download-Trend

3 Jahre

GitHub Stars Ranking

Statistik-Detail

Paket
Downloads
Stars
Größe
Issues
Veröffentlichung
Lizenz
graphql68,849,95120,3436.52 MB107vor 4 MonatenMIT
graphql-yoga2,676,5288,535364 kB143vor 11 TagenMIT
express-graphql437,2366,250-54vor 6 JahrenMIT
apollo-server177,68213,95826.6 kB89vor 3 JahrenMIT

Funktionsvergleich: graphql vs graphql-yoga vs express-graphql vs apollo-server

Einfachheit der Einrichtung

  • graphql:

    GraphQL selbst ist kein Server, sondern eine Abfragesprache. Daher erfordert die Verwendung von GraphQL eine eigene Implementierung, was die Einrichtung komplexer machen kann, insbesondere für Anfänger.

  • graphql-yoga:

    GraphQL Yoga ist sehr benutzerfreundlich und ermöglicht eine schnelle Einrichtung eines GraphQL-Servers mit minimalem Aufwand. Es bietet eine sofort einsatzbereite Lösung mit vielen integrierten Funktionen.

  • express-graphql:

    Express-GraphQL ist ebenfalls einfach einzurichten, erfordert jedoch ein gewisses Verständnis von Express.js. Es ermöglicht die Integration von GraphQL in bestehende Express-Anwendungen, was es zu einer flexiblen Wahl für Entwickler macht, die bereits mit Express vertraut sind.

  • apollo-server:

    Apollo Server bietet eine einfache Möglichkeit, einen GraphQL-Server einzurichten, mit minimalem Konfigurationsaufwand. Es unterstützt verschiedene Middleware-Integrationen und ermöglicht eine schnelle Implementierung von GraphQL-Schemas und -Resolvern.

Leistungsfähigkeit

  • graphql:

    Die Leistungsfähigkeit von GraphQL hängt stark von der Implementierung ab. Es bietet eine hohe Flexibilität, aber die Verantwortung für die Optimierung der Abfragen liegt beim Entwickler.

  • graphql-yoga:

    GraphQL Yoga bietet eine gute Leistung und ist für die meisten Anwendungen optimiert. Es unterstützt auch WebSockets für Echtzeit-Updates, was die Leistung bei Echtzeitanwendungen verbessert.

  • express-graphql:

    Express-GraphQL ist leichtgewichtig und bietet eine solide Leistung, kann jedoch bei sehr komplexen Abfragen oder großen Datenmengen an seine Grenzen stoßen, da es keine integrierten Optimierungen bietet.

  • apollo-server:

    Apollo Server ist leistungsstark und optimiert für die Verarbeitung komplexer Abfragen und Mutationen. Es bietet Funktionen wie Caching und Batch-Requests, die die Leistung bei großen Datenmengen verbessern können.

Erweiterbarkeit

  • graphql:

    Die Erweiterbarkeit von GraphQL hängt von der Implementierung ab. Entwickler können ihre eigenen Lösungen erstellen, aber es erfordert mehr Aufwand, um zusätzliche Funktionen hinzuzufügen.

  • graphql-yoga:

    GraphQL Yoga ist ebenfalls erweiterbar und ermöglicht es Entwicklern, Anpassungen vorzunehmen und zusätzliche Middleware zu integrieren, um die Funktionalität zu erweitern.

  • express-graphql:

    Express-GraphQL ist ebenfalls erweiterbar, da es auf Express basiert. Entwickler können Middleware hinzufügen, um die Funktionalität zu erweitern, und es gibt viele verfügbare Middleware-Pakete, die die Integration erleichtern.

  • apollo-server:

    Apollo Server ist hochgradig erweiterbar und bietet eine Vielzahl von Plugins und Integrationen, die es Entwicklern ermöglichen, zusätzliche Funktionen hinzuzufügen, wie z.B. Authentifizierung, Logging und mehr.

Community und Unterstützung

  • graphql:

    GraphQL hat eine wachsende Community, die viele Ressourcen und Unterstützung bietet. Da es sich um eine Abfragesprache handelt, ist die Unterstützung jedoch breiter gefächert und nicht auf eine bestimmte Implementierung beschränkt.

  • graphql-yoga:

    GraphQL Yoga hat eine engagierte Community und bietet viele Ressourcen, um Entwicklern den Einstieg zu erleichtern. Es ist eine beliebte Wahl für neue Projekte und hat eine gute Dokumentation.

  • express-graphql:

    Express-GraphQL hat ebenfalls eine starke Community, da es Teil des Express-Ökosystems ist. Es gibt viele Ressourcen und Beispiele, die Entwicklern helfen, die Bibliothek effektiv zu nutzen.

  • apollo-server:

    Apollo Server hat eine große und aktive Community, die eine Vielzahl von Ressourcen, Tutorials und Unterstützung bietet. Dies erleichtert es Entwicklern, Hilfe zu finden und Best Practices zu lernen.

Fehlerbehandlung

  • graphql:

    Die Fehlerbehandlung in GraphQL hängt von der Implementierung ab. Entwickler müssen sicherstellen, dass ihre Resolver Fehler korrekt behandeln und geeignete Fehlermeldungen zurückgeben.

  • graphql-yoga:

    GraphQL Yoga bietet eine einfache und effektive Fehlerbehandlung, die es Entwicklern ermöglicht, Fehler in ihren Abfragen und Mutationen leicht zu identifizieren und zu behandeln.

  • express-graphql:

    Express-GraphQL bietet grundlegende Fehlerbehandlung, erfordert jedoch möglicherweise zusätzliche Middleware für erweiterte Funktionen. Entwickler müssen möglicherweise eigene Fehlerbehandlungslogik implementieren.

  • apollo-server:

    Apollo Server bietet integrierte Fehlerbehandlungsmechanismen, die es Entwicklern ermöglichen, Fehler effektiv zu protokollieren und zu verwalten. Es unterstützt auch benutzerdefinierte Fehlerformate und -meldungen.

Wie man wählt: graphql vs graphql-yoga vs express-graphql vs apollo-server

  • graphql:

    Wählen Sie GraphQL, wenn Sie die Kernfunktionen von GraphQL selbst implementieren möchten, ohne eine vollständige Serverlösung. Dies ist nützlich für Entwickler, die eine benutzerdefinierte Implementierung benötigen oder die Flexibilität wünschen, ihre eigene Middleware zu erstellen.

  • graphql-yoga:

    Wählen Sie GraphQL Yoga, wenn Sie eine benutzerfreundliche und sofort einsatzbereite GraphQL-Serverlösung suchen, die auf Express basiert und viele nützliche Funktionen wie einfache Konfiguration und Unterstützung für WebSockets bietet. Es ist ideal für Entwickler, die schnell mit GraphQL beginnen möchten.

  • express-graphql:

    Wählen Sie Express-GraphQL, wenn Sie bereits Express.js verwenden und eine einfache, leichtgewichtige Lösung für die Integration von GraphQL in Ihre bestehende Anwendung benötigen. Es ist ideal für kleinere Projekte oder wenn Sie die Kontrolle über die Middleware-Implementierung behalten möchten.

  • apollo-server:

    Wählen Sie Apollo Server, wenn Sie eine umfassende Lösung mit vielen integrierten Funktionen wie Caching, Fehlerbehandlung und Unterstützung für Subscriptions benötigen. Es ist ideal für komplexe Anwendungen, die eine robuste GraphQL-Implementierung erfordern.

README für graphql

GraphQL.js

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

npm version Build 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

With yarn:

yarn add graphql

With bun:

bun 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);
});

Want to ride the bleeding edge?

The npm branch in this repository is automatically maintained to be the last commit to 17.x.x 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

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. The exports map within the project package.json should direct runtimes and bundlers to the appropriate files. Tools that do not support exports will find the CommonJS and ESModule builds side by side, with the CommonJS code packaged in files with the .js extension and the ESModule build within .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 [email protected].

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.

Version Support

GraphQL.JS follows Semantic Versioning (SemVer) for its releases. Our version support policy is as follows:

  • Latest Major Version: We provide full support, including bug fixes and security updates, for the latest major version of GraphQL.JS.
  • Previous Major Version: We offer feature support for the previous major version for 12 months after the release of the newest major version. This means that for 12 months we can backport features for specification changes if they don't cause any breaking changes. We'll continue supporting the previous major version with bug and security fixes.
  • Older Versions: Versions older than the previous major release are considered unsupported. While the code remains available, we do not actively maintain or provide updates for these versions. One exception to this rule is when the older version has been released < 1 year ago, in that case we will treat it like the "Previous Major Version".

Long-Term Support (LTS)

We do not currently offer a Long-Term Support version of GraphQL.JS. Users are encouraged to upgrade to the latest stable version to receive the most up-to-date features, performance improvements, and security updates.

End-of-Life (EOL) Schedule

We will announce the EOL date for a major version at least 6 months in advance. After a version reaches its EOL, it will no longer receive updates, even for critical security issues.

Upgrade Assistance

To assist users in upgrading to newer versions:

  • We maintain detailed release notes for each version, highlighting new features, breaking changes, and deprecations.
  • Our documentation includes migration guides for moving between major versions.
  • The community forum (Discord channel #graphql-js) is available for users who need additional assistance with upgrades.

Security Updates

We prioritize the security of GraphQL.JS:

  • Critical security updates will be applied to both the current and previous major version.
  • For versions that have reached EOL, we strongly recommend upgrading to a supported version to receive security updates.

Community Contributions

We welcome community contributions for all versions of GraphQL.JS. However, our maintainers will primarily focus on reviewing and merging contributions for supported versions.