Registry / devops / graphql-tools

graphql-tools

JSON →
library9.0.28jsnpmunverified

GraphQL Tools is a set of utility functions and classes for building and manipulating GraphQL schemas, creating executable schemas from type definitions, and stitching schemas together. Version 9.x is the current stable release with a moderate release cadence, supporting GraphQL.js ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 and requiring Node >=16. It ships TypeScript types. Key differentiators: it provides a cohesive toolkit that complements graphql-js with features like schema stitching, mock generation, and operation transformation, widely used in the Apollo ecosystem.

npm install graphql-tools
INSTALL
IMPORT
SIG · GRAPHQL-TOOLS
G
graphql-tools
devopsjavascriptv9.0.28
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

makeExecutableSchema
import { makeExecutableSchema } from '@graphql-tools/schema'
import { makeExecutableSchema } from 'graphql-tools'
In v7+, the function is exported from the @graphql-tools/schema subpackage, not from the main graphql-tools package.
stitchSchemas
import { stitchSchemas } from '@graphql-tools/stitch'
import { stitchSchemas } from 'graphql-tools'
In v7+, stitching is in @graphql-tools/stitch subpackage.
GraphQLSchema
import { GraphQLSchema } from 'graphql'
import { GraphQLSchema } from 'graphql-tools'
GraphQLSchema is from graphql-js, not from graphql-tools.
default
import graphqlTools from 'graphql-tools'
The default export is deprecated in v7+; prefer named exports from subpackages.

Creates an executable schema from type definitions and resolvers, then adds mocks to the schema.

import { makeExecutableSchema } from '@graphql-tools/schema'; import { addMocksToSchema } from '@graphql-tools/mock'; import { graphql } from 'graphql'; const typeDefs = ` type Query { hello: String } `; const resolvers = { Query: { hello: () => 'world', }, }; const schema = makeExecutableSchema({ typeDefs, resolvers }); const query = `{ hello }`; graphql({ schema, source: query }).then((result) => { console.log(result); }); const schemaWithMocks = addMocksToSchema({ schema }); graphql({ schema: schemaWithMocks, source: query }).then((result) => { console.log(result); });
Debug
Known issues
breakingIn v7, the main graphql-tools package was split into multiple subpackages (e.g., @graphql-tools/schema, @graphql-tools/stitch). Old imports from 'graphql-tools' will break.
fix
Use imports from specific subpackages like @graphql-tools/schema.
affects: >=7.0.0 <8.0.0
gotchaThe default export from 'graphql-tools' is deprecated and may be removed in future versions.
fix
Use named imports from subpackages.
affects: >=7.0.0
deprecatedThe `mergeSchemas` function is deprecated; use `stitchSchemas` from @graphql-tools/stitch instead.
fix
Replace mergeSchemas with stitchSchemas.
affects: >=8.0.0
gotchaWhen using `makeExecutableSchema`, the `resolvers` option must match the schema type names exactly; otherwise, no resolver is applied.
fix
Ensure resolver keys match type names and field names exactly.
affects: >=9.0.0
gotchaThe `addMocksToSchema` function does not preserve custom resolvers automatically. Mock resolvers override all fields.
fix
Use the `resolvers` option in addMocksToSchema to preserve some resolvers.
affects: >=8.0.0
Errors
Common errors & fixes
Cannot find module 'graphql-tools'
In v7+, the main package is deprecated; the package may not be installed if only subpackages are installed.
fix
Install the required subpackage, e.g., `npm install @graphql-tools/schema`.
TypeError: (0 , _schema.makeExecutableSchema) is not a function
Importing from the wrong path (e.g., 'graphql-tools' instead of '@graphql-tools/schema').
fix
Change import to `import { makeExecutableSchema } from '@graphql-tools/schema'`.
Error: Unknown type "XYZ". Did you mean "ABC"?
Type definition mismatch or missing type in the schema.
fix
Check that all types referenced in the schema are defined and correctly spelled.
Error: Schema must contain uniquely named types but contains multiple types named "Query".
Duplicate type definitions in the merged or stitched schemas.
fix
Ensure each type is defined only once unless using schema extension syntax.
Upgrade
Version history
9.0.28latest on npm
Audit
Dependencies
graphqlrequiredpeer dependency - required to work with GraphQL schemas
Agent activity
8 hits · last 30 days
node
8
Resources
graphql-tools — npm install graphql-tools · libregistry