af7be09
Thanks @ardatan! - Hotfix: do not use nullable and nonNullable prefixes if field names don't match
-
#6091
9bca9e0
Thanks @User, @User! - If the gateway receives a query with an overlapping fields for the subschema, it uses aliases to resolve it correctly.Let's say subschema A has the following schema;
type Query { } interface User { id: ID! name: String! } type Admin implements User { id: ID! name: String! role: String! } type Customer implements User { id: ID! name: String email: String }
And let's say the gateway has the following schema instead;
type Query { } interface User { id: ID! name: String! } type Admin implements User { id: ID! name: String! role: String! } type Customer implements User { id: ID! name: String! email: String! }
In this case, the following query is fine for the gateway but for the subschema, it's not;
query { user { ... on Admin { id name # This is nullable in the subschema role } ... on Customer { id name # This is non-nullable in the subschema email } } }
So the subgraph will throw based on this rule OverlappingFieldsCanBeMerged
To avoid this, the gateway will use aliases to resolve the query correctly. The query will be transformed to the following;
query { user { ... on Admin { id name # This is nullable in the subschema role } ... on Customer { id name: _nullable_name # This is non-nullable in the subschema email } } }
-
#6092
243c353
Thanks @ardatan! - If one of the subgraphs are already able to resolve a nested field as inparent-entity-call
example'sCategory.details
from C'sProduct
, resolve it from there instead of using type merging.query { product { category { details { # This is coming from C's Product, so resolve it from there instead of Type Merging id name } } } }
-
#5913
83c0af0
Thanks @enisdenjo! - dependencies updates:- Updated dependency
@graphql-tools/schema@^10.0.2
↗︎ (from^10.0.0
, independencies
) - Updated dependency
@graphql-tools/utils@^10.0.13
↗︎ (from^10.0.5
, independencies
)
- Updated dependency
-
#5913
83c0af0
Thanks @enisdenjo! - No unnecessary inline fragment spreads for union types -
Updated dependencies [
83c0af0
,83c0af0
,83c0af0
]:- @graphql-tools/batch-execute@9.0.4
- @graphql-tools/executor@1.2.1
- @graphql-tools/schema@10.0.3
-
#5477
cfd47827
Thanks @ardatan! - dependencies updates:- Removed dependency
value-or-promise@^1.0.12
↗︎ (fromdependencies
)
- Removed dependency
-
a59fb765
Thanks @ardatan! - Optimizations to get better performance in query planning -
Updated dependencies [
a59fb765
]:- @graphql-tools/batch-execute@9.0.1
- @graphql-tools/utils@10.0.5
-
Updated dependencies [
944a68e8
,944a68e8
]:- @graphql-tools/batch-execute@9.0.0
- @graphql-tools/executor@1.0.0
- @graphql-tools/schema@10.0.0
- @graphql-tools/utils@10.0.0
-
Updated dependencies [
88244048
,8e80b689
]:- @graphql-tools/executor@0.0.20
- @graphql-tools/batch-execute@8.5.22
-
2f342e43
Thanks @ardatan! - Do not use promises if not async -
Updated dependencies [
2f342e43
]:- @graphql-tools/batch-execute@8.5.21
- Updated dependencies
[
05c97eb8
,05c97eb8
,05c97eb8
,f24f018a
]:- @graphql-tools/batch-execute@8.5.20
- @graphql-tools/executor@0.0.19
- @graphql-tools/schema@9.0.19
- Updated dependencies
[
91a895be
]:- @graphql-tools/executor@0.0.18
- Updated dependencies
[
1c95368a
]:- @graphql-tools/batch-execute@8.5.19
- @graphql-tools/executor@0.0.17
- @graphql-tools/schema@9.0.18
- Updated dependencies
[
828fbf93
]:- @graphql-tools/executor@0.0.16
- #5131
f26392a6
Thanks @neumark! - Create symbols with Symbol.for() because multiple copies of delegate cause stitching bugs otherwise.
- #5067
492220cb
Thanks @n1ru4l! - dependencies updates:- Updated dependency
@graphql-tools/batch-execute@^8.5.18
↗︎ (from8.5.18
, independencies
) - Updated dependency
@graphql-tools/executor@^0.0.14
↗︎ (from0.0.14
, independencies
) - Updated dependency
@graphql-tools/schema@^9.0.16
↗︎ (from9.0.16
, independencies
) - Updated dependency
@graphql-tools/utils@^9.2.1
↗︎ (from9.2.1
, independencies
) - Updated dependency
dataloader@^2.2.2
↗︎ (from2.2.2
, independencies
) - Updated dependency
tslib@^2.5.0
↗︎ (from~2.5.0
, independencies
) - Updated dependency
value-or-promise@^1.0.12
↗︎ (from1.0.12
, independencies
)
- Updated dependency
- Updated dependencies
[
77c1002e
]:- @graphql-tools/executor@0.0.15
- #5055
30bd4d0c
Thanks @renovate! - dependencies updates:- Updated dependency
dataloader@2.2.2
↗︎ (from2.2.1
, independencies
)
- Updated dependency
- Updated dependencies
[
30bd4d0c
]:- @graphql-tools/batch-execute@8.5.18
- #5025
b09ea282
Thanks @renovate! - dependencies updates:- Updated dependency
dataloader@2.2.1
↗︎ (from2.1.0
, independencies
)
- Updated dependency
- Updated dependencies
[
b09ea282
,b5c8f640
]:- @graphql-tools/batch-execute@8.5.17
- @graphql-tools/utils@9.2.1
- @graphql-tools/executor@0.0.14
- @graphql-tools/schema@9.0.16
- Updated dependencies
[
a94217e9
,62d074be
]:- @graphql-tools/utils@9.2.0
- @graphql-tools/batch-execute@8.5.16
- @graphql-tools/executor@0.0.13
- @graphql-tools/schema@9.0.15
- #4995
772b948a
Thanks @renovate! - dependencies updates:- Updated dependency
tslib@~2.5.0
↗︎ (from~2.4.0
, independencies
)
- Updated dependency
- Updated dependencies []:
- @graphql-tools/schema@9.0.14
- #4943
a4d36fcc
Thanks @renovate! - dependencies updates:- Updated dependency
value-or-promise@1.0.12
↗︎ (from1.0.11
, independencies
)
- Updated dependency
- Updated dependencies
[
a4d36fcc
,a4d36fcc
,a4d36fcc
,e3ec35ed
]:- @graphql-tools/batch-execute@8.5.15
- @graphql-tools/executor@0.0.12
- @graphql-tools/schema@9.0.13
- @graphql-tools/utils@9.1.4
-
#4890
eb6cd8b6
Thanks @ardatan! - Transform provided argument values properly -
#4890
eb6cd8b6
Thanks @ardatan! - Handle argument definitions correctly during delegation and transformations
-
Updated dependencies [
904fe770
]:- @graphql-tools/utils@9.1.3
- @graphql-tools/batch-execute@8.5.14
- @graphql-tools/executor@0.0.11
- @graphql-tools/schema@9.0.12
-
13c24883
Thanks @ardatan! - Fix handling argument values in gateway request -
b5e6459f
Thanks @ardatan! - Show warning only if DEBUG env var is present -
Updated dependencies [
13c24883
]:- @graphql-tools/utils@9.1.2
- @graphql-tools/batch-execute@8.5.13
- @graphql-tools/executor@0.0.10
- @graphql-tools/schema@9.0.11
- Updated dependencies
[
7411a5e7
]:- @graphql-tools/utils@9.1.1
- @graphql-tools/batch-execute@8.5.12
- @graphql-tools/executor@0.0.9
- @graphql-tools/schema@9.0.10
- Updated dependencies
[
1d3856dc
]:- @graphql-tools/executor@0.0.8
- Updated dependencies
[
c0639dd0
]:- @graphql-tools/utils@9.1.0
- @graphql-tools/batch-execute@8.5.11
- @graphql-tools/executor@0.0.7
- @graphql-tools/schema@9.0.9
- Updated dependencies
[
d83b1960
]:- @graphql-tools/utils@9.0.1
- @graphql-tools/batch-execute@8.5.10
- @graphql-tools/executor@0.0.6
- @graphql-tools/schema@9.0.8
- Updated dependencies
[
f47f3559
]:- @graphql-tools/executor@0.0.4
-
#4796
80836fa7
Thanks @saihaj! - updatecollectFields
to support collecting deffered values -
Updated dependencies [
80836fa7
,80836fa7
,8f6d3efc
,80836fa7
,80836fa7
,80836fa7
,80836fa7
]:- @graphql-tools/executor@0.0.3
- @graphql-tools/utils@9.0.0
- @graphql-tools/batch-execute@8.5.9
- @graphql-tools/schema@9.0.7
- Updated dependencies
[
f7daf777
]:- @graphql-tools/utils@8.13.1
- @graphql-tools/batch-execute@8.5.8
- @graphql-tools/executor@0.0.2
- @graphql-tools/schema@9.0.6
- #4778
df5848b8
Thanks @saihaj! - dependencies updates:- Added dependency
@graphql-tools/executor@0.0.0
↗︎ (todependencies
)
- Added dependency
- Updated dependencies
[
df5848b8
,df5848b8
,df5848b8
,df5848b8
]:- @graphql-tools/utils@8.13.0
- @graphql-tools/executor@0.0.1
- @graphql-tools/batch-execute@8.5.7
- @graphql-tools/schema@9.0.5
00c4a1a4
Thanks @ardatan! - If type is a list but the provided value isn't, do not fail and resolve that value as the member of that list type
- Updated dependencies
[
43c736bd
]:- @graphql-tools/utils@8.12.0
- @graphql-tools/batch-execute@8.5.6
- @graphql-tools/schema@9.0.4
- Updated dependencies
[
71cb4fae
,403ed450
]:- @graphql-tools/utils@8.11.0
- @graphql-tools/batch-execute@8.5.5
- @graphql-tools/schema@9.0.3
- Updated dependencies
[
4fe3d9c0
]:- @graphql-tools/utils@8.10.1
- @graphql-tools/batch-execute@8.5.4
- @graphql-tools/schema@9.0.2
- Updated dependencies
[
2609d71f
]:- @graphql-tools/utils@8.10.0
- @graphql-tools/schema@9.0.1
- @graphql-tools/batch-execute@8.5.3
-
#4566
d8dc67aa
Thanks @ardatan! - ## Breaking changesSchema generation optimization by removing
transfomedSchema
parameterPreviously we were applying the transforms multiple times. We needed to introduced some breaking changes to improve the initial wrapped/stitched schema generation performance;
Transform.transformSchema
no longer acceptstransformedSchema
which can easily be created withapplySchemaTransforms(schema, subschemaConfig)
instead.- Proxying resolver factory function that is passed as
createProxyingResolver
toSubschemaConfig
no longer takestransformedSchema
which can easily be created withapplySchemaTransforms(schema, subschemaConfig)
instead.
stitchSchemas
doesn't take nested arrays of subschemasstitchSchemas
no longer accepts an array of arrays of subschema configuration objects. Instead, it accepts an array of subschema configuration objects or schema objects directly.stitchSchemas
no longer prunes the schema withpruningOptions
You can use
pruneSchema
from@graphql-tools/utils
to prune the schema instead.stitchSchemas
no longer respect "@computed" directive if stitchingDirectivesTransformer isn't appliedAlso
@graphql-tools/stitch
no longer exportscomputedDirectiveTransformer
anddefaultSubschemaConfigTransforms
. Instead, use@graphql-tools/stitching-directives
package for@computed
directive. Learn more about setting it upcomputedFields
has been removed from the merged type configurationMergeTypeConfig.computedFields
setting has been removed in favor of new computed field configuration written as:merge: { MyType: { fields: { myComputedField: { selectionSet: '{ weight }', computed: true, } } } }
A field-level
selectionSet
specifies field dependencies while thecomputed
setting structures the field in a way that assures it is always selected with this data provided. TheselectionSet
is intentionally generic to support possible future uses. This new pattern organizes all field-level configuration (includingcanonical
) into a single structure.
-
#4624
e3167edc
Thanks @n1ru4l! - Fix CommonJS TypeScript resolution withmoduleResolution
node16
ornodenext
-
Updated dependencies [
8cc8721f
,e3167edc
]:- @graphql-tools/schema@9.0.0
- @graphql-tools/batch-execute@8.5.2
- @graphql-tools/utils@8.9.1
- Updated dependencies [2a3b45e3]
- @graphql-tools/utils@8.9.0
- @graphql-tools/batch-execute@8.5.1
- @graphql-tools/schema@8.5.1
- d76a299c: Support TypeScript module resolution.
- Updated dependencies [a0abbbcd]
- Updated dependencies [d76a299c]
- @graphql-tools/utils@8.8.0
- @graphql-tools/batch-execute@8.5.0
- @graphql-tools/schema@8.5.0
- 6df204de: Remove graphql-executor to have smaller bundle size
- Updated dependencies [4914970b]
- @graphql-tools/schema@8.4.0
- @graphql-tools/utils@8.7.0
- @graphql-tools/batch-execute@8.4.11
- 041c5ba1: Use caret range for the tslib dependency
- Updated dependencies [041c5ba1]
- @graphql-tools/batch-execute@8.4.10
- @graphql-tools/schema@8.3.14
- @graphql-tools/utils@8.6.13
- Updated dependencies [da7ad43b]
- @graphql-tools/utils@8.6.12
- @graphql-tools/batch-execute@8.4.9
- @graphql-tools/schema@8.3.13
- Updated dependencies [c0762ee3]
- @graphql-tools/utils@8.6.11
- @graphql-tools/batch-execute@8.4.8
- @graphql-tools/schema@8.3.12
- Updated dependencies [0fc510cb]
- @graphql-tools/utils@8.6.10
- @graphql-tools/batch-execute@8.4.7
- @graphql-tools/schema@8.3.11
- Updated dependencies [31a33e2b]
- @graphql-tools/utils@8.6.9
- @graphql-tools/batch-execute@8.4.6
- @graphql-tools/schema@8.3.10
-
26e4b464: relax subschema error path check
...as (apparently) some implementations may return path as
null
rather than not returning a path.
- Updated dependencies [cb238877]
- @graphql-tools/utils@8.6.8
- @graphql-tools/batch-execute@8.4.5
- @graphql-tools/schema@8.3.9
-
0bbb1769: Refine generic typings using
extends X
when appropriateTypescript 4.7 has stricter requirements around generics which is explained well in the related PR: microsoft/TypeScript#48366
These changes resolve the errors that these packages will face when attempting to upgrade to TS 4.7 (still in beta at the time of writing this). Landing these changes now will allow other TS libraries which depend on these packages to experiment with TS 4.7 in the meantime.
-
Updated dependencies [0bbb1769]
- @graphql-tools/utils@8.6.7
- @graphql-tools/batch-execute@8.4.4
- @graphql-tools/schema@8.3.8
- fe9402af: Bump data-loader and cross-undici-fetch
- Updated dependencies [fe9402af]
- @graphql-tools/batch-execute@8.4.3
- Updated dependencies [904c0847]
- @graphql-tools/utils@8.6.6
- @graphql-tools/batch-execute@8.4.2
- @graphql-tools/schema@8.3.7
- Updated dependencies [722abad7]
- @graphql-tools/schema@8.3.6
- d8fd6b94: enhance(delegate): use graphql-executor for subscriptions
- Updated dependencies [be2c02d7]
- @graphql-tools/utils@8.6.5
- @graphql-tools/batch-execute@8.4.1
- @graphql-tools/schema@8.3.5
- c40e801f: feat: forward gateway operation's name to subschema executors
- Updated dependencies [c40e801f]
- Updated dependencies [d36d530b]
- @graphql-tools/batch-execute@8.4.0
- @graphql-tools/utils@8.6.4
- @graphql-tools/schema@8.3.4
- 0c0c6857: fix - align versions
- Updated dependencies [0c0c6857]
- @graphql-tools/batch-execute@8.3.3
- @graphql-tools/schema@8.3.3
- 70081f8f: enhance(delegate): type is now inferred from the transformed subschema instead of unified schema
- 70081f8f: enhance(stitch): support promises in key functions
- b84a7809: fix(delegate): do not resolve the type twice
- 18341363: feat(visitResult): ignore if field not present in visited object
- Updated dependencies [18341363]
- @graphql-tools/batch-execute@8.3.2
- @graphql-tools/schema@8.3.2
- @graphql-tools/utils@8.6.2
- 081b97e8: Add better type support for stitchSchemas using subschema transformations
- 51315610: enhance: avoid using globalThis
- Updated dependencies [51315610]
- @graphql-tools/utils@8.5.4
- 960e178a: fix: isAsyncIterable should check if it is an object with iterator factory function
- Updated dependencies [960e178a]
- Updated dependencies [947a3fe0]
- @graphql-tools/utils@8.5.3
- 4bfb3428: enhance: use ^ for tslib dependency
- Updated dependencies [4bfb3428]
- @graphql-tools/batch-execute@8.3.1
- @graphql-tools/schema@8.3.1
- @graphql-tools/utils@8.5.1
- ad04dc79: enhance: make operationType optional
- Updated dependencies [ad04dc79]
- @graphql-tools/batch-execute@8.3.0
- @graphql-tools/utils@8.5.0
- 149afddb: fix: getting ready for GraphQL v16
- Updated dependencies [149afddb]
- @graphql-tools/batch-execute@8.2.0
- @graphql-tools/schema@8.3.0
- @graphql-tools/utils@8.4.0
- 58262be7: enhance: show more clear error messages for aggregated error
- Updated dependencies [58262be7]
- @graphql-tools/utils@8.3.0
- 014937db: batch-execute enhancements:
- fixes bugs with batched fragment definitions
- unpathed errors are now returned for all batch results
- the "graphqlTools" prefix is simplified down to just "_"
- new tests and documentation
- Updated dependencies [014937db]
- @graphql-tools/batch-execute@8.1.1
- @graphql-tools/utils@8.2.4
- b2f18d6f: fix(delegate): pass an empty array if fieldNodes is falsy
- c5b0719c: enhance(utils): copy inspect util from graphql-js
- c5b0719c: feat: GraphQL v16 support
- c5b0719c: enhance(utils): move memoize functions to utils
- c5b0719c: enhance(utils): copy collectFields from graphql-js@16 for backwards compat
- Updated dependencies [c5b0719c]
- Updated dependencies [c5b0719c]
- Updated dependencies [c5b0719c]
- Updated dependencies [c5b0719c]
- Updated dependencies [c5b0719c]
- @graphql-tools/utils@8.2.0
- @graphql-tools/batch-execute@8.1.0
- @graphql-tools/schema@8.2.0
- c8c13ed1: enhance: remove TypeMap and small improvements
- Updated dependencies [c8c13ed1]
- @graphql-tools/utils@8.1.2
-
631b11bd: refactor(delegationPlanner): introduce static version of our piecemeal planner
...which, although undocumented, can be accessed within the StitchingInfo object saved in a stitched schema's extensions.
Also improves memoization technique slightly across the board.
- e50852e6: use version ranges instead of a fixed version for the graphql-tools package versions
- Updated dependencies [631b11bd]
- Updated dependencies [e50852e6]
- @graphql-tools/batch-execute@8.0.5
- @graphql-tools/schema@8.1.2
- Updated dependencies [2c807ddb]
- @graphql-tools/utils@8.1.1
- @graphql-tools/batch-execute@8.0.4
- @graphql-tools/schema@8.1.1
- 9a13357c: Fix nested type merges with repeated children ignore all but first occurrence
- Updated dependencies [b9684631]
- Updated dependencies [9ede806a]
- Updated dependencies [67691b78]
- @graphql-tools/utils@8.1.0
- @graphql-tools/schema@8.1.0
- @graphql-tools/batch-execute@8.0.3
- d47dcf42: fix(delegate): visit list values to collect variables
- ded29f3d: fix(delegate): collect variables from directives on FragmentSpread
- 7fdef335: fix(delegate): handle variables correctly
- Updated dependencies [04830049]
- @graphql-tools/utils@8.0.2
- @graphql-tools/batch-execute@8.0.2
- @graphql-tools/schema@8.0.2
- Updated dependencies [b823dbaf]
- @graphql-tools/utils@8.0.1
- @graphql-tools/batch-execute@8.0.1
- @graphql-tools/schema@8.0.1
- d93945fa: fix(delegate): ignore if stitchingInfo is not in extensions
- c36defbe: fix(delegate): fix ESM import
-
7d3e3006: BREAKING CHANGE
- Remove
rootValue
from subschemaConfig -
- Pass it through
ExecutionParams
or delegation options
- Pass it through
- Do not pass
info.rootValue
ifrootValue
is falsy
- Remove
-
d53e3be5: BREAKING CHANGES;
Refactor the core delegation transforms into individual functions to modify request and results. This will improve the performance considerably by reducing the number of visits over the request document.
- Replace
CheckResultAndHandleErrors
withcheckResultAndHandleErrors
- Remove
delegationBindings
- Replace
AddArgumentsAsVariables
,AddSelectionSets
,AddTypenameToAbstract
,ExpandAbstractTypes
,FilterToSchema
,VisitSelectionSets
andWrapConcreteTypes
withprepareGatewayDocument
andfinalizeGatewayRequest
- Replace
-
dae6dc7b: refactor: ExecutionParams type replaced by Request type
rootValue property is now a part of the Request type.
When delegating with delegateToSchema, rootValue can be set multiple ways:
- when using a custom executor, the custom executor can utilize a rootValue in whichever custom way it specifies.
- when using the default executor (execute/subscribe from graphql-js): -- rootValue can be passed to delegateToSchema via a named option -- rootValue can be included within a subschemaConfig -- otherwise, rootValue is inferred from the originating schema
When using wrapSchema/stitchSchemas, a subschemaConfig can specify the createProxyingResolver function which can pass whatever rootValue it wants to delegateToSchema as above.
-
c42e811d: BREAKING CHANGES;
- Rename
Request
toExecutionRequest
- Add required
operationType: OperationTypeNode
field inExecutionRequest
- Add
context
increateRequest
andcreateRequestInfo
instead ofdelegateToSchema
It doesn't rely on info.operation.operationType to allow the user to call an operation from different root type. And it doesn't call getOperationAST again and again to get operation type from the document/operation because we have it in Request and ExecutionParams https://github.com/ardatan/graphql-tools/pull/3166/files#diff-d4824895ea613dcc1f710c3ac82e952fe0ca12391b671f70d9f2d90d5656fdceR38
Improvements;
- Memoize
defaultExecutor
for a singleGraphQLSchema
so allowgetBatchingExecutor
to memoizebatchingExecutor
correctly. - And there is no different
defaultExecutor
is created forsubscription
and other operation types. Only one executor is used.
Batch executor is memoized by
executor
reference butcreateDefaultExecutor
didn't memoize the default executor so this memoization wasn't working correctly onbatch-execute
side. https://github.com/ardatan/graphql-tools/blob/remove-info-executor/packages/batch-execute/src/getBatchingExecutor.ts#L9 - Rename
-
7d3e3006: BREAKING CHANGE
- Now it uses the native
AggregateError
implementation. The major difference is the individual errors are kept undererrors
property instead of the object itself withSymbol.iterator
.
// From; for (const error of aggregateError) // To; for (const error of aggregateError.errors)
- Now it uses the native
-
aa43054d: BREAKING CHANGE: validations are skipped by default, use validateRequest: true to reenable
-
c0ca3190: BREAKING CHANGE
- Remove Subscriber and use only Executor
-
- Now
Executor
can receiveAsyncIterable
and subscriptions will also be handled byExecutor
. This is a future-proof change for defer, stream and live queries
- Now
- Updated dependencies [af9a78de]
- Updated dependencies [9c26b847]
- Updated dependencies [7d3e3006]
- Updated dependencies [7d3e3006]
- Updated dependencies [dae6dc7b]
- Updated dependencies [6877b913]
- Updated dependencies [7d3e3006]
- Updated dependencies [c42e811d]
- Updated dependencies [7d3e3006]
- Updated dependencies [8c8d4fc0]
- Updated dependencies [7d3e3006]
- Updated dependencies [7d3e3006]
- Updated dependencies [7d3e3006]
- Updated dependencies [74581cf3]
- Updated dependencies [c0ca3190]
- Updated dependencies [7d3e3006]
- Updated dependencies [982c8f53]
- Updated dependencies [7d3e3006]
- Updated dependencies [7d3e3006]
- Updated dependencies [7d3e3006]
- @graphql-tools/utils@8.0.0
- @graphql-tools/schema@8.0.0
- @graphql-tools/batch-execute@8.0.0
- 22a9f3da: fix(deps): follow package conventions on when to pin
- Updated dependencies [22a9f3da]
- @graphql-tools/batch-execute@7.1.2
- @graphql-tools/schema@7.1.5
- 61da3e82: use value-or-promise to streamline working with sync values or async promises
- Updated dependencies [61da3e82]
- @graphql-tools/batch-execute@7.1.1
- @graphql-tools/schema@7.1.4
- b202587b: fix(delegate): handle executor errors
-
6aed1714: Allows
MergedTypeConfig
to be written with anentryPoints
array for multiple merged type entry points, each with their ownfieldName
andselectionSet
:{ schema: testSchema, merge: { Product: { entryPoints: [{ selectionSet: '{ id }', fieldName: 'productById', key: ({ id, price, weight }) => ({ id, price, weight }), argsFromKeys: (key) => ({ key }), }, { selectionSet: '{ upc }', fieldName: 'productByUpc', key: ({ upc, price, weight }) => ({ upc, price, weight }), argsFromKeys: (key) => ({ key }), }], } } }
These multiple entry points accommodate types with multiple keys across services that rely on a central service to join them, for example:
- Catalog service:
type Product { upc }
- Vendors service:
type Product { upc id }
- Reviews service:
type Product { id }
Given this graph, the possible traversals require the Vendors service to provide entry points for each unique key format:
Catalog > Vendors > Reviews
Catalog < Vendors > Reviews
Catalog < Vendors < Reviews
Is it highly recommended that you enable query batching for subschemas with multiple entry points.
- Catalog service:
- f84e7b15: fix(delegate): export executor typings not to have breaking change
- Updated dependencies [194ac370]
- @graphql-tools/utils@7.7.1
- 58fd4b28: feat(types): add TContext to stitchSchemas and executor
- Updated dependencies [58fd4b28]
- Updated dependencies [43da6b59]
- @graphql-tools/batch-execute@7.1.0
- @graphql-tools/utils@7.7.0
-
24926654: Deprecates the
MergeTypeConfig.computedFields
setting (with backwards-compatible warning) in favor of new computed field configuration written as:merge: { MyType: { fields: { myComputedField: { selectionSet: '{ weight }', computed: true, } } } }
A field-level
selectionSet
specifies field dependencies while thecomputed
setting structures the field in a way that assures it is always selected with this data provided. TheselectionSet
is intentionally generic to support possible future uses. This new pattern organizes all field-level configuration (includingcanonical
) into a single structure.
- d9b82a2e: fix(delegate) fix array check
- d9b82a2e: enhance(stitch) canonical merged type and field definitions. Use the @canonical directive to promote preferred type and field descriptions into the combined gateway schema.
-
cd5da458: fix(stitch): type merging for nested root types
Because root types do not usually require selectionSets, a nested root type proxied to a remote service may end up having an empty selectionSet, if the nested root types only includes fields from a different subservice.
Empty selection sets return null, but, in this case, it should return an empty object. We can force this behavior by including the __typename field which exists on every schema.
Addresses #2347.
In the future, we may want to include short-circuiting behavior that when delegating to composite fields, if an empty selection set is included, an empty object is returned rather than null. This short-circuiting behavior would be complex for lists, as it would be unclear the length of the list...
-
cd5da458: fix(delegate): resolve external values only once
Because items in a list may be identical and the defaultMergedResolver mutates those objects when resolving them as external values, a check is required so that the mutation happens only once.
Partially addresses #2304
-
Updated dependencies [cd5da458]
- @graphql-tools/utils@7.1.6
- 1b730f80: fix(typeMerging): enable subschemas to use keys that have been renamed via transforms
- 29ead57c: fix(batch-delegate): proxy batched errors
- d40c0a84: fix(delegate): add selectionSets prior to expanding abstract types
- e50f80a3: enhance(stitch): custom merge resolvers
- 83b8e428: fix(delegate): import AggregateError polyfill (#2196)
- 856e23fa: fix(delegate): WrapConcreteTypes should not process fragments that are not on a root type (#2173)
- Updated dependencies [e3176633]
- @graphql-tools/utils@7.0.2
-
718eda30: fix(stitch): fix mergeExternalObject regressions
v7 introduced a regression in the merging of ExternalObjects that causes type merging to fail when undergoing multiple rounds of merging.
- 294dedda: fix(delegate): Fix type error with
arguments
being undefined - Updated dependencies [8133a907]
- Updated dependencies [2b6c813e]
- @graphql-tools/utils@7.0.1
-
be1a1575: ## Breaking Changes:
-
Resolver validation options should now be set to
error
,warn
orignore
rather thantrue
orfalse
. In previous versions, some of the validators caused errors to be thrown, while some issued warnings. This changes brings consistency to validator behavior. -
The
allowResolversNotInSchema
has been renamed torequireResolversToMatchSchema
, to harmonize the naming convention of all the validators. The default setting ofrequireResolversToMatchSchema
iserror
, matching the previous behavior.
-
The
delegateToSchema
return value has matured and been formalized as anExternalObject
, in which all errors are integrated into the GraphQL response, preserving their initial path. Those advanced users accessing the result directly will note the change in error handling. This also allows for the deprecation of unnecessary helper functions includingslicedError
,getErrors
,getErrorsByPathSegment
functions. Only external errors with missing or invalid paths must still be preserved by annotating the remote object with special properties. The newgetUnpathedErrors
function is therefore necessary for retrieving only these errors. Note also the newannotateExternalObject
andmergeExternalObjects
functions, as well as the renaming ofhandleResult
toresolveExternalValue
. -
Transform types and the
applySchemaTransforms
are now relocated to thedelegate
package;applyRequestTransforms
/applyResultTransforms
functions have been deprecated, however, as this functionality has been replaced since v6 by theTransformer
abstraction. -
The
transformRequest
/transformResult
methods are now provided additionaldelegationContext
andtransformationContext
arguments -- these were introduced in v6, but previously optional. -
The
transformSchema
method may wish to create additional delegating resolvers and so it is now provided thesubschemaConfig
and final (non-executable)transformedSchema
parameters. As in v6, thetransformSchema
is kicked off once to produce the non-executable version, and then, if a wrapping schema is being generated, proxying resolvers are created with access to the (non-executable) initial result. In v7, the individualtransformSchema
methods also get access to the result of the first run, if necessary, they can create additional wrapping schema proxying resolvers. -
applySchemaTransforms
parameters have been updated to match and support thetransformSchema
parameters above.
-
wrapSchema
andgenerateProxyingResolvers
now only take a single options argument with named properties of typeSubschemaConfig
. The previously possible shorthand version with first argument consisting of aGraphQLSchema
and second argument representing the transforms should be reworked as aSubschemaConfig
object. -
Similarly, the
ICreateProxyingResolverOptions
interface that provides the options for thecreateProxyingResolver
property ofSubschemaConfig
options has been adjusted. Theschema
property previously could be set to aGraphQLSchema
or aSubschemaConfig
object. This property has been removed in favor of asubschemaConfig
property that will always be aSubschemaConfig
object. Thetransforms
property has been removed; transforms should be included within theSubschemaConfig
object.` -
The format of the wrapping schema has solidified. All non-root fields are expected to use identical resolvers, either
defaultMergedResolver
or a custom equivalent, with root fields doing the hard work of proxying. Support for custom merged resolvers throughtcreateMergedResolver
has been deprecated, as custom merging resolvers conflicts when using stitching's type merging, where resolvers are expected to be identical across subschemas. -
The
WrapFields
transform'swrappingResolver
option has been removed, as this complicates multiple wrapping layers, as well as planned functionality to wrap subscription root fields in potentially multiple layers, as the wrapping resolvers may be different in different layers. Modifying resolvers can still be performed by use of an additional transform such asTransformRootFields
orTransformObjectFields
. -
The
ExtendSchema
transform has been removed, as it is conceptually simpler just to usestitchSchemas
with one subschema. -
The
ReplaceFieldsWithFragment
,AddFragmentsByField
,AddSelectionSetsByField
, andAddMergedTypeSelectionSets
transforms has been removed, as they are superseded by theAddSelectionSets
andVisitSelectionSets
transforms. TheAddSelectionSets
purposely takes parsed SDL rather than strings, to nudge end users to parse these strings at build time (when possible), rather than at runtime. Parsing of selection set strings can be performed using theparseSelectionSet
function from@graphql-tools/utils
.
-
stitchSchemas
'smergeTypes
option is now true by default! This causes theonTypeConflict
option to be ignored by default. To useonTypeConflict
to select a specific type instead of simply merging, simply setmergeTypes
to false. -
schemas
argument has been deprecated, usesubschemas
,typeDefs
, ortypes
, depending on what you are stitching. -
When using batch delegation in type merging, the
argsFromKeys
function is now set only via theargsFromKeys
property. Previously, ifargsFromKeys
was absent, it could be read fromargs
. -
Support for fragment hints has been removed in favor of selection set hints.
-
stitchSchemas
now processes allGraphQLSchema
andSubschemaConfig
subschema input into newSubschema
objects, handling schema config directives such aso@computed
as well as generating the final transformed schema, stored as thetransformedSchema
property, if transforms are used. Signatures of theonTypeConflict
,fieldConfigMerger
, andinputFieldConfigMerger
have been updated to include metadata related to the original and transformed subschemas. Note the property name change foronTypeConflict
fromschema
tosubschema
.
- Mocks returning objects with fields set as functions are now operating according to upstream
graphql-js convention, i.e. these functions take three arguments,
args
,context
, andinfo
withparent
available asthis
rather than as the first argument.
filterSchema
'sfieldFilter
will now filter all fields across Object, Interface, and Input types. For the previous Object-only behavior, switch to theobjectFieldFilter
option.- Unused
fieldNodes
utility functions have been removed. - Unused
typeContainsSelectionSet
function has been removed, andtypesContainSelectionSet
has been moved to thestitch
package. - Unnecessary
Operation
type has been removed in favor ofOperationTypeNode
from upstream graphql-js. - As above,
applySchemaTransforms
/applyRequestTransforms
/applyResultTransforms
have been removed from theutils
package, as they are implemented elsewhere or no longer necessary.
- proxy all the errors: #1047, #1641
- better error handling for merges #2016, #2062
- fix typings #1614
- disable implicit schema pruning #1817
- mocks not working for functions #1807
-
- Updated dependencies [be1a1575]
- @graphql-tools/batch-execute@7.0.0
- @graphql-tools/schema@7.0.0
- @graphql-tools/utils@7.0.0
- 32c3c4f8: enhance(stitching): improve error message for unknown types
- 533d6d53: Bump all packages to allow adjustments
- Updated dependencies [32c3c4f8]
- Updated dependencies [533d6d53]
- @graphql-tools/utils@6.2.4
- @graphql-tools/schema@6.2.4