@graphql-tools/mock
10.1.1 · 23 Oct 2026MIT688k / weekRepositoryHomepagenpmAtom feed
137 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 10.x · latest line
10.1.1
23 Oct 2026dependencies updates:
Use
fakePromise/fakeRejectPromisefor iteratorreturn/throw/asyncDisposeinstead of unnecessaryasync
10.1.0
22 Oct 2026Query and Mutation mocks now receive the field's resolved arguments. Subscription mocks receive the same map when resolve runs (an event is yielded); the default subscriber does not yield.
A mock is a type factory, not a resolver. The value that identifies an operation field is its argument map after GraphQL coercion:
user(id: ID!)always hasid, whether the client sent a literal or a variable. That is what you assert on (jest.fn()/toHaveBeenCalledWith) and what you use to return the right mock.contextis the same request-wide object for every field (auth, loaders). It does not distinguishuser(id: "1")fromuser(id: "2"). Use theresolversoption ofaddMocksToSchemawhen you needcontext,info, or the mock store; the rest of the fields can still come from mocks.mocks.Query = jest.fn(() => ({ ... }))is called with{ id: 'user-1' }whenuser(id:)is resolved. Nested type mocks such asUserstay factories with no arguments.Lists generated by the mock store can set a length with
defaultListLength, andMockListnow passes each item's index to its mock function.Without an explicit list mock the store always produced two items.
addMocksToSchema({ schema, defaultListLength: 0 })(orcreateMockStore) now controls that length. Auto-generated list items pass their index to scalar mocks, andnew MockList(n, (index) => ...)receivesindexso items can vary by position.MockStoregetandsetnow accept GraphQL input object types.Input types were rejected as "not an object or interface", so mutation inputs could not be stored for later CRUD-style mocks. The store now treats input objects like other named object types.
Minor Changes
Query and Mutation mocks now receive the field's resolved arguments. Subscription mocks receive the same map when resolve runs (an event is yielded); the default subscriber does not yield.
A mock is a type factory, not a resolver. The value that identifies an operation field is its argument map after GraphQL coercion:
user(id: ID!)always hasid, whether the client sent a literal or a variable. That is what you assert on (jest.fn()/toHaveBeenCalledWith) and what you use to return the right mock.contextis the same request-wide object for every field (auth, loaders). It does not distinguishuser(id: "1")fromuser(id: "2"). Use theresolversoption ofaddMocksToSchemawhen you needcontext,info, or the mock store; the rest of the fields can still come from mocks.mocks.Query = jest.fn(() => ({ ... }))is called with{ id: 'user-1' }whenuser(id:)is resolved. Nested type mocks such asUserstay factories with no arguments.Lists generated by the mock store can set a length with
defaultListLength, andMockListnow passes each item's index to its mock function.Without an explicit list mock the store always produced two items.
addMocksToSchema({ schema, defaultListLength: 0 })(orcreateMockStore) now controls that length. Auto-generated list items pass their index to scalar mocks, andnew MockList(n, (index) => ...)receivesindexso items can vary by position.MockStoregetandsetnow accept GraphQL input object types.Input types were rejected as "not an object or interface", so mutation inputs could not be stored for later CRUD-style mocks. The store now treats input objects like other named object types.
Patch Changes
Mocks set on list items now apply to fields that take arguments.
The store keys a field with its arguments (
membership:{"param":"test"}). Nested mocks such as{ membership: null }were stored under the bare field name, so a query that passed arguments generated a new default instead of using the override. Lookups now fall back to the un-argued field when the exact argument key is missing.
10.0.1 – 10.0.54 releases that only update dependencies@graphql-tools/utils 13.1.2@graphql-tools/schema 11.0.5Show each
10.0.0
19 Oct 2026- breaking
Drop GraphQL v14/v15 support and require Node.js >= 22.18.
On Node.js ≥26.1 (and ≥24.16 where backported),
fs.globfollowSymlinksis used.On older engines, symlink directories are discovered only under each pattern’s literal prefix (not the whole
cwd) and patterns are re-rooted.
Major Changes
- breaking
Drop GraphQL v14/v15 support and require Node.js >= 22.18.
graphqlpeer range is now^16.0.0 || ^17.0.0.engines.nodeis now>=22.18.0(Nodefs.glob+ Babel 8).Dev tooling and
@graphql-tools/graphql-tag-pluckmove to Babel 8 (@babel/core/ parser / traverse / types).The standalone
cross-inspectpackage is discontinued. Useinspectfrom@graphql-tools/utilsinstead (Nodeutil.inspectviaprocess.getBuiltinModule, with a smallJSON.stringify/Stringfallback).
Removed
@graphql-tools/utilsexportsRemoved Use instead getArgumentValuesimport { getArgumentValues } from 'graphql'coerceInputs/graphqlJSCompatgraphql@16+ APIs ( getArgumentValues, etc.)createDeferred/createDeferredPromiseconst { promise, resolve, reject } = Promise.withResolvers()createGraphQLErrornew GraphQLError(message, options)fromgraphqlmapMaybePromisehandleMaybePromisefrom@whatwg-node/promise-helpersisPromise/fakePromise/mapAsyncIterator/MaybePromise@whatwg-node/promise-helpersregisterAbortSignalListener/getAbortPromiseAbortSignalAPIs (throwIfAborted,addEventListener('abort', …, { once: true }),AbortSignal.any, …)withCancel/getAsyncIterableWithCancel/getAsyncIteratorWithCancelHandle cancellation on the async iterator’s return()(or your transport abort path)debugTimerStart/debugTimerEndYour own timing / console.timeif neededPromiseWithResolvers(type)Built-in PromiseWithResolvers<T>/ return type ofPromise.withResolvers()inspectand the WeakMapmemoize1…memoize2of5helpers remain on@graphql-tools/utils(inspect is no longer re-exported fromcross-inspect).File matching (
globby→fs.glob)Loaders and
@graphql-tools/load-filesnow use Node’sfs.globthrough:import { matchFiles, matchFilesSync } from '@graphql-tools/load-files';Directory symlinks are followed for recursive (
**) patterns:On Node.js ≥26.1 (and ≥24.16 where backported),
fs.globfollowSymlinksis used.On older engines, symlink directories are discovered only under each pattern’s literal prefix (not the whole
cwd) and patterns are re-rooted.Non-recursive / literal patterns skip the symlink walk entirely.
@graphql-tools/executorhot-path caches (collectSubfields, argument coercion,@streamdetection) usememoize2/memoize3from utils.collectSubFieldsin utils stays unmemoized so the executor can own a single memoize3 layer.Errors and other cleanup
Prefer
new GraphQLError(message, options)fromgraphql. Experimental schemacoordinatesupport remains onlocatedError/relocatedError/getSchemaCoordinate.Removed GraphQL versions older than 16 compatibility branches (error construction, validation rule name suffixes,
URL.canParsefallback).Promise helpers should be imported from
@whatwg-node/promise-helpers(handleMaybePromise,isPromise,fakePromise,mapAsyncIterator,MaybePromise) rather than re-exported from utils.
Patch Changes
dependencies updates:
Updated dependency
graphql@^16.0.0 || ^17.0.0↗︎ (from^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0, inpeerDependencies)
- 9.x
9.1.18
15 Oct 2026dependencies updates:
Patch Changes
dependencies updates:
Updated dependency
@graphql-tools/schema@^10.1.4↗︎ (from^10.1.3, independencies)Updated dependency
@graphql-tools/utils@^12.0.4↗︎ (from^12.0.3, independencies)
9.1.16 – 9.1.172 releases that only update dependencies@graphql-tools/utils 12.0.4@graphql-tools/schema 10.1.4Show each
9.1.15
30 Sep 2026- security
Fix prototype pollution in
mergeIncrementalResultPath segments are now rejected unless they are primitive strings or numbers, and keys named
__proto__,constructororprototypeare still blocked. Previously a non-primitive segment such as["__proto__"]bypassed the string equality guard and was coerced into a write onObject.prototype.Also exports shared
isSafeObjectKey/isDangerousObjectKeyhelpers used by this path walker and other package call sites.@graphql-tools/mergeand@graphql-tools/mockare patched so they ship with the new imports;updateInternalDependenciesraises their utils floor when12.0.2is versioned.
Patch Changes
- security
Fix prototype pollution in
mergeIncrementalResultPath segments are now rejected unless they are primitive strings or numbers, and keys named
__proto__,constructororprototypeare still blocked. Previously a non-primitive segment such as["__proto__"]bypassed the string equality guard and was coerced into a write onObject.prototype.Also exports shared
isSafeObjectKey/isDangerousObjectKeyhelpers used by this path walker and other package call sites.@graphql-tools/mergeand@graphql-tools/mockare patched so they ship with the new imports;updateInternalDependenciesraises their utils floor when12.0.2is versioned.
9.1.14
7 Sep 2026Pass
resolverValidationOptionsthrough fromaddMocksToSchematoaddResolversToSchema.
Patch Changes
Pass
resolverValidationOptionsthrough fromaddMocksToSchematoaddResolversToSchema.
9.1.13
12 Aug 2026Only updates dependencies:@graphql-tools/schema 10.1.0@graphql-tools/utils 12.0.0
9.1.12
17 Jul 2026Reading the note…
9.1.11
17 Jul 2026Reading the note…
9.1.10
8 Jul 2026Reading the note…
9.1.9
6 Jul 2026Reading the note…
9.1.8
28 Jun 2026Reading the note…
9.1.7
23 Apr 2026Reading the note…
9.1.6
9 Apr 2026Reading the note…
9.1.5
7 Jan 2026Reading the note…
9.1.4
28 Nov 2025Reading the note…
9.1.3
12 Nov 2025Reading the note…
9.1.2
11 Nov 2025Reading the note…
9.1.1
4 Nov 2025Reading the note…
9.1.0
30 Oct 2025Reading the note…
9.0.25
21 Jul 2025Reading the note…
9.0.24
17 Jul 2025Reading the note…
9.0.23
22 May 2025Reading the note…
9.0.22
13 Mar 2025Reading the note…
9.0.21
13 Mar 2025Reading the note…
9.0.20
3 Mar 2025Reading the note…
9.0.19
25 Feb 2025Reading the note…
9.0.18
21 Feb 2025Reading the note…
9.0.17
10 Feb 2025Reading the note…
9.0.16
10 Feb 2025Reading the note…
9.0.15
16 Jan 2025Reading the note…
9.0.14
6 Jan 2025Reading the note…
9.0.13
2 Jan 2025Reading the note…
9.0.12
24 Dec 2024Reading the note…
9.0.11
14 Dec 2024Reading the note…
9.0.10
13 Dec 2024Reading the note…
9.0.9
4 Dec 2024Reading the note…
9.0.8
27 Nov 2024Reading the note…
9.0.7
22 Nov 2024Reading the note…
9.0.6
13 Nov 2024Reading the note…
9.0.5
15 Oct 2024Reading the note…
9.0.4
23 Jul 2024Reading the note…
9.0.3
27 May 2024Reading the note…
9.0.2
23 Feb 2024Reading the note…