{"id":10393,"library":"graphql","title":"GraphQL.js","description":"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.","status":"active","version":"16.13.2","language":"javascript","source_language":"en","source_url":"https://github.com/graphql/graphql-js","tags":["javascript","graphql","graphql-js","typescript"],"install":[{"cmd":"npm install graphql","lang":"bash","label":"npm"},{"cmd":"yarn add graphql","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphql","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"wrong":"const { graphql } = require('graphql');","symbol":"graphql","correct":"import { graphql } from 'graphql';"},{"wrong":"const { buildSchema } = require('graphql');","symbol":"buildSchema","correct":"import { buildSchema } from 'graphql';"}],"quickstart":{"code":"import { graphql, buildSchema } from 'graphql';\n\n// Construct a schema, using GraphQL schema language\nconst schema = buildSchema(`\n  type Query {\n    hello: String\n  }\n`);\n\n// The root provides a resolver function for each API endpoint\nconst root = {\n  hello: () => {\n    return 'Hello world!';\n  },\n};\n\n// Run the GraphQL query '{ hello }' and print out the response\ngraphql({ schema, source: '{ hello }', rootValue: root }).then((response) => {\n  console.log(response);\n});","lang":"typescript","description":"This example demonstrates how to define a simple GraphQL schema, provide a resolver, and execute a basic query using GraphQL.js."},"warnings":[{"fix":"Review its usage and consider alternative validation methods or direct execution, avoiding reliance on this specific utility.","message":"The `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.","severity":"deprecated","affected_versions":">=16.13.0"},{"fix":"For simple hash map objects where prototype chain methods are not needed, initialize them with `Object.create(null)`.","message":"When 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.","severity":"gotcha","affected_versions":">=16.13.2"},{"fix":"Update resolver implementations to call `info.getAbortSignal()` to access the `AbortSignal` for execution cancellation.","message":"In 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.","severity":"breaking","affected_versions":">=17.0.0-alpha.10"},{"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.","message":"v17 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.","severity":"breaking","affected_versions":">=17.0.0-alpha.9"}],"env_vars":null,"last_verified":"2026-04-18T00:00:00.000Z","next_check":"2026-07-17T00:00:00.000Z","problems":[{"fix":"Check your GraphQL schema for the correct field name on type 'Y', or verify your query for typos matching an existing field.","cause":"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.","error":"Cannot query field \"X\" on type \"Y\". Did you mean \"Z\"?"},{"fix":"Ensure your `buildSchema` or schema definition correctly defines 'Query', 'Mutation', and 'Subscription' as object types (e.g., `type Query { ... }`).","cause":"The schema definition is missing or incorrectly defining one of the root operation types (Query, Mutation, Subscription) as a non-object type or `null`.","error":"Expected 'RootQueryType' to be an object type, got 'null'."},{"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.","cause":"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.","error":"Variable \"$variableName\" of type \"TypeName!\" was provided invalid value."},{"fix":"Rename or remove the duplicate field definitions in your GraphQL schema to ensure all fields on a given type have unique names.","cause":"Your GraphQL schema definition has duplicate field names on the same type, which is not allowed according to the GraphQL specification.","error":"A field named \"fieldName\" already exists on type \"TypeName\""}],"ecosystem":"npm"}