🌐
HTTP8M+/wkMIT

graphql

GraphQL is the JavaScript reference implementation of the GraphQL specification, a query language for APIs originally developed by Facebook. This package provid

Installation

npm
npm install graphql
yarn
yarn add graphql
pnpm
pnpm add graphql

Import

ESM
import { graphql, buildSchema } from 'graphql';

Quick Example

usage
import { graphql, buildSchema } from 'graphql';

const schema = buildSchema(`
  type Query { hello: String }
`);

const result = await graphql({
  schema,
  source: '{ hello }',
  rootValue: { hello: () => 'Hello world' },
});

About graphql

GraphQL is the JavaScript reference implementation of the GraphQL specification, a query language for APIs originally developed by Facebook. This package provides the core functionality for building GraphQL schemas, parsing and validating GraphQL queries, and executing those queries against a schema. The library includes type constructors for defining GraphQL schemas programmatically (GraphQLObjectType, GraphQLSchema, GraphQLString, etc.), a parser for converting GraphQL query strings into abstract syntax trees, a validator for checking queries against a schema, and an executor for resolving queries into results. The package serves as the foundation for all JavaScript GraphQL tools and frameworks including Apollo Server, GraphQL Yoga, and schema-building libraries like Nexus and TypeGraphQL. GraphQL enables clients to request exactly the data they need in a single request, eliminating over-fetching and under-fetching common with REST APIs. The library also includes utilities for schema introspection, query formatting, and error handling. Understanding this core package is essential for working with any GraphQL tool in the JavaScript ecosystem.

Quick Facts

Packagegraphql
CategoryHTTP
Weekly Downloads8M+
LicenseMIT
Installnpm install graphql

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.