gitmyhub

graphql-js

TypeScript ★ 20k updated 16h ago

A reference implementation of GraphQL for JavaScript

Official JavaScript implementation of GraphQL, a query language that lets clients request exactly the data they need from a server in a single query.

TypeScriptJavaScriptNode.jssetup: easycomplexity 3/5

GraphQL.js is the official JavaScript reference implementation of GraphQL, the query language for APIs originally created by Facebook. GraphQL itself is a way for client applications to ask a server for exactly the data they need — no more, no less — in a single request. Rather than calling multiple different REST endpoints and stitching responses together, a GraphQL client sends one query describing the exact shape of data it wants, and the server responds with just that structure.

This library is the JavaScript/TypeScript engine that makes that possible on the server side. Using it, a developer first defines a "type schema" — a description of all the data types their application exposes and how they relate to each other. The README demonstrates this with a minimal example: a schema with a single "hello" field that returns the string "world." Once the schema is defined, the library handles parsing incoming GraphQL queries, validating them against the schema (catching errors like requesting a field that does not exist), and executing them by calling "resolver" functions that retrieve or compute the actual data.

GraphQL.js is a general-purpose library that works both in Node.js server environments and in the browser. Higher-level GraphQL server frameworks (like Apollo Server) are built on top of it. You would interact with GraphQL.js directly when building a custom GraphQL server or when you need low-level control; most application developers use it indirectly through a higher-level framework. It is distributed as an npm package and is written in TypeScript.

Where it fits