Skip to content

GraphQL.js

JavaScript reference implementation of GraphQL, a query language for APIs.

Stars
20.3k
Forks
2.1k
Licence
MIT
Language
TypeScript
Last update
4 days ago
Type
Library

What it is

GraphQL.js is the official JavaScript implementation of GraphQL, a query language for APIs originally created by Facebook. It lets developers define a typed schema that maps to their code, then run queries against that schema, with validation of queries before they execute. It works in both Node.js servers and browsers.

  • Define a GraphQL schema with object types and fields in JavaScript
  • Serve a query against a schema and get a structured result or validation errors
  • Bundle only the parts of the library you use with webpack or rollup

Great for

  • JavaScript or TypeScript developers building a GraphQL API on Node.js
  • Developers who want the reference implementation that other GraphQL tools are built on
  • Teams building browser-side tools that work with GraphQL schemas

Not ideal for

  • People who only want to call an existing GraphQL API and do not write server code; a client library would fit better
  • Non-developers, since the README assumes familiarity with JavaScript and schemas
Step-by-step guide: how to use GraphQL.jsInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js

    Install with npm

    npm install --save graphql

    Install with yarn

    yarn add graphql

    Install with bun

    bun add graphql
  2. 2

    Run it

    • Install the graphql package with npm, yarn, or bun
    • Create a GraphQLSchema with a query type and at least one field
    • Call graphql({ schema, source }) with a query string like '{ hello }'
    • Check the returned result for data or errors
  3. 3

    Get the most out of it

    • Read the tests in src/__tests__ alongside the GraphQL specification overview, as the README suggests
    • Use the browser support described in the README with webpack or rollup to include only needed code
    • Follow the migration guides on the project documentation site when moving between major versions
    • Use the npm branch if you want the latest unreleased build, with the caveat that the README recommends npm releases

Downloads

Strengths

  • Maintained as the reference implementation of the GraphQL specification for JavaScript
  • Ships both CommonJS and ES module builds, so it works with most bundlers
  • Released under the permissive MIT license

Trade-offs

  • The README's getting-started material is brief; fuller documentation is on external sites
  • Building a full API typically needs additional libraries not covered in this README
  • Contributions require signing a GraphQL Specification Membership agreement

How it compares

ProjectStarsTypeLevelUpdatedBest for
graphql-js (this)20.3kLibraryintermediate4 days agoJavaScript or TypeScript developers building a GraphQL API on Node.js
apollo-server14kLibraryintermediate5 days agoNode.js developers who want to add a GraphQL API to an existing Express, Koa or Hapi app
yoga18.9kLibraryadvanced4 days agoDevelopers embedding flexbox-style layout into a native or cross-platform app
crystal12.9kFrameworkadvanced4 days agoDevelopers who have a PostgreSQL database and want an auto-generated GraphQL API
query50.5kLibraryintermediate4 days agoFrontend developers building apps that load data from a server
apollo-client19.8kLibraryintermediate5 days agoDevelopers building React apps that query a GraphQL API

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.