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 install graphql
yarn add graphql
pnpm add graphql
Import
import { graphql, buildSchema } from 'graphql';Quick Example
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
| Package | graphql |
| Category | HTTP |
| Weekly Downloads | 8M+ |
| License | MIT |
| Install | npm install graphql |
Related Packages
Apollo Server is the most popular GraphQL server implementation for Node.js, providing a production-…
GraphQL Yoga is a batteries-included, fully-featured GraphQL server built on top of the Fetch API st…
tRPC enables you to build fully typesafe APIs without schemas or code generation by leveraging TypeS…
NestJS is a progressive Node.js framework for building efficient, reliable, and scalable server-side…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.