@graphql-tools/mock@10.1.0
Minor Changes
-
#8570
171adc3Thanks @ardatan! - 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 distinguish
user(id: "1")fromuser(id: "2"). Use theresolversoption ofaddMocksToSchemawhen you need
context,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. -
#8566
2e28f6cThanks @ardatan! - Lists generated by the mock store can set a length withdefaultListLength, 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. -
#8568
822a0c7Thanks @ardatan! -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
-
#8565
8c50a7dThanks @ardatan! - 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. -
Updated dependencies [
7fbc6e7,fe44242,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/schema@11.0.6
@graphql-tools/executor@4.1.4
Patch Changes
-
#8576
e0115d8Thanks @ardatan! - Abort listeners on a requestAbortSignalare removed when query/mutation execution finishes, not only when the signal aborts.addEventListener('abort', listener, { once: true })drops the listener only when abort fires. A successful request never aborts, so the function stayed on the signal. A newAbortControllerper request hid this. Reusing one signal (YogauseExecutionCancellation()plus a stitchedbuildHTTPExecutor({ fetch: yoga.fetch })path) left one listener per finished query. Heap snapshots then grew with request count.const signal = controller.signal; await execute({ schema, document, signal }); await execute({ schema, document, signal }); // the first request's abort listener is now removed
Subscriptions still keep the listener until abort, so cancel can close the stream.
-
Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
@graphql-tools/executor-apollo-link@3.0.6
Patch Changes
@graphql-tools/executor-envelop@5.0.6
Patch Changes
@graphql-tools/executor-legacy-ws@2.0.6
Patch Changes
@graphql-tools/executor-urql-exchange@2.0.6
Patch Changes
@graphql-tools/executor-yoga@4.0.6
Patch Changes
- Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/executor-envelop@5.0.6
@graphql-tools/graphql-tag-pluck@9.0.7
Patch Changes
graphql-tools@10.0.6
Patch Changes
- Updated dependencies [
fe44242]:- @graphql-tools/schema@11.0.6
@graphql-tools/import@8.0.6
Patch Changes
-
#8577
f5b0a19Thanks @ardatan! -processImportkeeps the AST nodes collected from#importinstead of printing every definition to SDL and parsing that string again.A type that many other types depend on is stored in each of those sets, so the same node was printed over and over. Two files can also carry identical SDL (for example the same
type Queryafter a field import). Those are still de-duplicated: skip a node already seen, and skip a second node that prints to the same SDL. The first node is kept. Leading comments stay on that node (for example# eslint-disable-next-lineabove a query).const document = processImport('./schema.graphql'); // document.definitions are the nodes parsed from the imported files
-
Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
@graphql-tools/jest-transform@3.0.1
Patch Changes
- Updated dependencies [
8bbb097]:- @graphql-tools/webpack-loader@8.0.1
@graphql-tools/links@11.0.6
Patch Changes
@graphql-tools/load@9.0.6
Patch Changes
- Updated dependencies [
7fbc6e7,fe44242,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/schema@11.0.6
@graphql-tools/load-files@8.0.6
Patch Changes
@graphql-tools/apollo-engine-loader@9.0.6
Patch Changes
@graphql-tools/code-file-loader@9.0.7
Patch Changes
- Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/graphql-tag-pluck@9.0.7
- @graphql-tools/load-files@8.0.6
@graphql-tools/external-fragment-loader@1.0.7
Patch Changes
- Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/graphql-tag-pluck@9.0.7
- @graphql-tools/load-files@8.0.6
@graphql-tools/git-loader@9.0.7
Patch Changes
- Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/graphql-tag-pluck@9.0.7
@graphql-tools/github-loader@10.0.7
Patch Changes
- Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/graphql-tag-pluck@9.0.7
@graphql-tools/graphql-file-loader@9.0.6
Patch Changes
- Updated dependencies [
7fbc6e7,f5b0a19,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/import@8.0.6
- @graphql-tools/load-files@8.0.6
@graphql-tools/json-file-loader@9.0.6
Patch Changes
- Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/load-files@8.0.6
@graphql-tools/module-loader@9.0.6
Patch Changes
@graphql-tools/url-loader@10.0.6
Patch Changes
- Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/executor-legacy-ws@2.0.6
@graphql-tools/merge@10.0.6
Patch Changes
@graphql-tools/node-require@8.0.6
Patch Changes
- Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/load@9.0.6
- @graphql-tools/graphql-file-loader@9.0.6
@graphql-tools/relay-operation-optimizer@8.0.6
Patch Changes
@graphql-tools/resolvers-composition@8.0.6
Patch Changes
@graphql-tools/schema@11.0.6
Patch Changes
-
#8564
fe44242Thanks @ardatan! -requireResolversForArgs(and the other resolver-presence checks) now look forsubscribeon the schema's subscription type.On subscriptions,
subscribeis required andresolveis optional. The validator used to look only atfield.resolve, so a subscription with arguments was reported as missing even whensubscribewas present. Query and mutation fields still requireresolve. -
Updated dependencies [
7fbc6e7,5ceed9d]:- @graphql-tools/utils@13.1.3
- @graphql-tools/merge@10.0.6
@graphql-tools/utils@13.1.3
Patch Changes
-
#8575
7fbc6e7Thanks @ardatan! -mapSchemanow remaps directive argument defaults the same way it already remaps field argument defaults.Use case:
UserRoleis remapped to internal ids, and@authdefaults toUSER.const schema = mapSchema(originalSchema, { [MapperKind.ENUM_VALUE]: (valueConfig, typeName, _schema, externalValue) => { if (typeName === 'UserRole' && externalValue === 'USER') { return { ...valueConfig, value: '3user' }; } return valueConfig; }, }); // directive @auth(role: UserRole = USER) schema.getDirective('auth').args.find(arg => arg.name === 'role').defaultValue; // before: "USER" // after: "3user"
mapSchemaserializes the stored default with the source type before parsing with the remapped type, so an internal value that matches another enum name (USER->"ADMIN") stays"ADMIN"instead of being parsed as that name.forEachDefaultValuewalks directive arguments too, somakeExecutableSchemaenum resolvers get the same result. -
#8574
5ceed9dThanks @ardatan! - PublishedExecutortypes include/// <reference lib="esnext.disposable" preserve="true" />so consumers do not needskipLibCheckor a fullesnextlib just to import this package.Use case: an app with
"lib": ["es2022"]or["es2024"]andskipLibCheck: falsethat imports@graphql-tools/utils:import type { Executor } from '@graphql-tools/utils'; export const executor: Executor = async request => { // ... };
Executorcan return aDisposable/AsyncIterableresult. Those names live in TypeScript'sesnext.disposablelib, which is not part ofes2022/es2024. Without the preserved reference,tscreportsCannot find name 'Disposable'. With it, the published.d.tspulls in that lib for the consumer automatically.