All free skills / Other majors

graphql 16.x

Validate and execute typed schemas with variables and explicit error handling.

For
graphql@16.13.1
Verified
2026-10-10, 8 examples executed
Skill package
@modootoday/pmcp-graphql@16.0.0

Use this skill for free

No PMCP login or subscription is required. Download the original instructions, or install the content-only archive with your project's package manager.

Download SKILL.md · Download package archive

npm install --save-dev https://pmcp.build/skills/graphql/16/package.tgz

PMCP discovers the installed package's instructions. Connect your runtime after installation.

Archive integritysha512-sDOaVUMEC8HD5oMfxfqLrTJWVkSCQvyytfNXFzrAfseT8Xji6ZwvjnrstRnClYTgCucNVnLNeF77yQQAGugfWg==

Complete instructions

GraphQL.js 16

Inspect the installed version, schema construction, server adapter and test commands first. Preserve the project's package manager, module mode and validation policy. This line targets graphql@16.13.1; it does not establish compatibility with GraphQL 17.

Validate and execute

Call validateSchema(schema) before exposing a newly constructed schema. Checking only that a query type exists misses invalid names and other schema errors.

graphql({ schema, source, variableValues, contextValue }) parses, validates and executes. Await its result so asynchronous resolvers are supported. graphqlSync is suitable only when execution is synchronous.

import assert from "node:assert/strict";
import { buildSchema, graphql, validateSchema } from "graphql";

const schema = buildSchema("type Query { greeting(name: String!): String! }");
assert.deepEqual(validateSchema(schema), []);
const result = await graphql({
  schema,
  source: "query Greeting($name: String!) { greeting(name: $name) }",
  variableValues: { name: "Ada" },
  rootValue: { greeting: ({ name }: { name: string }) => `Hello ${name}` },
});
assert.equal(result.errors, undefined);
assert.equal(result.data?.greeting, "Hello Ada");

For pre-parsed documents, use parse(source), then validate(schema, document), and call execute only after the validation errors are empty. execute does not replace document validation. A cached document's validation depends on the schema and validation rules as well as the document.

Pass request identity and dependencies through contextValue; do not store request state in global resolver objects.

Test the failure boundary

  • A numeric value for a String! variable must produce an error before operation execution. Verify errors and absent data for variable coercion failure.
  • An unknown field must fail document validation. Do not call execute on that invalid document.
  • Resolver failures can return partial data with errors. Non-null propagation can make a parent field or all data null; inspect both fields.
  • GraphQL.js does not choose HTTP status or mask sensitive resolver details. Test those through the actual server adapter.

Execution result objects may have a null prototype. Assert relevant fields or normalize through an actual JSON serialization boundary rather than assuming deep equality with an ordinary object literal.

Integrate without another schema

Pothos builder.toSchema() produces a standard GraphQLSchema. Validate it, then pass that same schema to GraphQL.js or Yoga createYoga({ schema }). Inspect peer dependency ranges before changing the GraphQL major.

The companion fixture targets schema validation, invalid variables/documents, typed Pothos resolvers, execution, request context and Yoga masking. Its HTTP requests are in process; it does not test a listener, deployment or WebSocket. Record successful execution separately from the selected version target.

Primary sources