Registry / web-framework / graphql

graphql

JSON →
library0.0.4jsnpmunverified

GraphQL.js is the JavaScript reference implementation of the GraphQL specification. It provides a robust and flexible GraphQL runtime and query language parser, enabling developers to build GraphQL servers and clients. The current stable version is 16.13.2, with active development on the next major version 17.0.0, which frequently releases alpha versions and introduces breaking changes.

npm install graphql
INSTALL
IMPORT
SIG · GRAPHQL
G
graphql
web-frameworkjavascriptv0.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

graphql
import { graphql } from 'graphql';
const { graphql } = require('graphql');
buildSchema
import { buildSchema } from 'graphql';
const { buildSchema } = require('graphql');

This example demonstrates how to define a simple GraphQL schema, provide a resolver, and execute a basic query using GraphQL.js.

import { graphql, buildSchema } from 'graphql'; // Construct a schema, using GraphQL schema language const schema = buildSchema(` type Query { hello: String } `); // The root provides a resolver function for each API endpoint const root = { hello: () => { return 'Hello world!'; }, }; // Run the GraphQL query '{ hello }' and print out the response graphql({ schema, source: '{ hello }', rootValue: root }).then((response) => { console.log(response); });
Debug
Known issues
deprecatedThe `assertValidExecutionArguments` utility function has been deprecated. While it still works, it's recommended to review its usage and consider more explicit validation within your application.
fix
Review its usage and consider alternative validation methods or direct execution, avoiding reliance on this specific utility.
affects: >=16.13.0
gotchaWhen creating plain JavaScript objects intended purely as hash maps (e.g., for GraphQL values or configurations), using `Object.create(null)` is recommended over `{}` to avoid prototype pollution issues and unintended inherited properties from the default object prototype.
fix
For simple hash map objects where prototype chain methods are not needed, initialize them with `Object.create(null)`.
affects: >=16.13.2
breakingIn v17 alpha releases, the direct `info.abortSignal` property in resolvers for execution cancellation has been replaced by a method `info.getAbortSignal()`. Direct access to the property will no longer work.
fix
Update resolver implementations to call `info.getAbortSignal()` to access the `AbortSignal` for execution cancellation.
affects: >=17.0.0-alpha.10
breakingv17 alpha releases introduce stricter validation rules. This includes forbidding `@skip` and `@include` directives in subscription root selections, new validation for `@stream` directives applied to different instances of the same field, and rejection of deprecated fields when inferring input types.
fix
Review your GraphQL schema and query definitions to ensure they adhere to the updated validation rules for directives and deprecated fields, especially in subscription operations.
affects: >=17.0.0-alpha.9
Errors
Common errors & fixes
Cannot query field "X" on type "Y". Did you mean "Z"?
The requested field 'X' does not exist on the specified type 'Y' in your GraphQL schema. This is often due to a typo in the query or a missing field definition in the schema.
fix
Check your GraphQL schema for the correct field name on type 'Y', or verify your query for typos matching an existing field.
Expected 'RootQueryType' to be an object type, got 'null'.
The schema definition is missing or incorrectly defining one of the root operation types (Query, Mutation, Subscription) as a non-object type or `null`.
fix
Ensure your `buildSchema` or schema definition correctly defines 'Query', 'Mutation', and 'Subscription' as object types (e.g., `type Query { ... }`).
Variable "$variableName" of type "TypeName!" was provided invalid value.
A variable passed to the GraphQL query does not match the expected type defined in the schema, or a non-nullable variable was provided a `null` value.
fix
Check the type definition of `$variableName` in your GraphQL query and schema, and ensure the provided value conforms to that type and nullability constraints.
A field named "fieldName" already exists on type "TypeName"
Your GraphQL schema definition has duplicate field names on the same type, which is not allowed according to the GraphQL specification.
fix
Rename or remove the duplicate field definitions in your GraphQL schema to ensure all fields on a given type have unique names.
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
graphql — npm install graphql · libregistry