@graphql-mesh/fusion-runtime 1.11.1 → 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/index.cjs +21 -17
- package/dist/index.js +22 -18
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @graphql-mesh/fusion-runtime
|
|
2
2
|
|
|
3
|
+
## 1.11.2
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#2473](https://github.com/graphql-hive/gateway/pull/2473) [`6f2c3b6`](https://github.com/graphql-hive/gateway/commit/6f2c3b64b05f6ba17928fd098915c2167f3daedc) Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
|
|
9
|
+
|
|
10
|
+
- Updated dependency [`@graphql-mesh/utils@^0.104.38` ↗︎](https://www.npmjs.com/package/@graphql-mesh/utils/v/0.104.38) (from `^0.104.36`, in `dependencies`)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
- [#2473](https://github.com/graphql-hive/gateway/pull/2473) [`6f2c3b6`](https://github.com/graphql-hive/gateway/commit/6f2c3b64b05f6ba17928fd098915c2167f3daedc) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Fields that are not provided by any subschema (added through `typeDefs` or `resolvers`) can now return partial objects of merged types; the missing fields are resolved from the owning subschema automatically
|
|
14
|
+
|
|
15
|
+
```graphql
|
|
16
|
+
type Query {
|
|
17
|
+
personCreated: PersonCreated
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type PersonCreated {
|
|
21
|
+
person: Person # merged type, owned by a subschema
|
|
22
|
+
cursor: String
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
const resolvers = {
|
|
28
|
+
Query: {
|
|
29
|
+
// only the key of `Person` is provided locally
|
|
30
|
+
personCreated: () => ({ person: { id: '1' }, cursor: 'c1' }),
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Before, `person` had to be resolved manually even though the stitched schema knows `Person` and its keys. Now the key is enough: `{ person { name } }` runs through the standard stitching planner, while local data (`cursor`) and local field resolvers on `Person` keep working as before. Computed fields, `@requires` dependencies, batching, and fields from other subschemas use the same type-merging flow as regular delegated results.
|
|
36
|
+
- Updated dependencies [[`6f2c3b6`](https://github.com/graphql-hive/gateway/commit/6f2c3b64b05f6ba17928fd098915c2167f3daedc), [`6f2c3b6`](https://github.com/graphql-hive/gateway/commit/6f2c3b64b05f6ba17928fd098915c2167f3daedc), [`6f2c3b6`](https://github.com/graphql-hive/gateway/commit/6f2c3b64b05f6ba17928fd098915c2167f3daedc)]:
|
|
37
|
+
- @graphql-tools/delegate@12.1.0
|
|
38
|
+
- @graphql-tools/stitch@10.2.0
|
|
39
|
+
- @graphql-mesh/transport-common@1.0.18
|
|
40
|
+
- @graphql-tools/federation@4.4.10
|
|
41
|
+
- @graphql-tools/stitching-directives@4.0.26
|
|
42
|
+
- @graphql-tools/wrap@11.1.20
|
|
43
|
+
|
|
3
44
|
## 1.11.1
|
|
4
45
|
### Patch Changes
|
|
5
46
|
|
package/dist/index.cjs
CHANGED
|
@@ -706,6 +706,24 @@ const handleFederationSupergraph = function({
|
|
|
706
706
|
}
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
|
+
const subscriptionType = unifiedGraph.getSubscriptionType();
|
|
710
|
+
if (subscriptionType) {
|
|
711
|
+
for (const field of Object.values(subscriptionType.getFields())) {
|
|
712
|
+
const pubsubOperations = utils.getDirectiveExtensions(field, unifiedGraph).pubsubOperation;
|
|
713
|
+
if (pubsubOperations?.length) {
|
|
714
|
+
const resolver = {};
|
|
715
|
+
for (const pubsubOperationArgs of pubsubOperations) {
|
|
716
|
+
Object.assign(
|
|
717
|
+
resolver,
|
|
718
|
+
utils$1.getResolverForPubSubOperation(pubsubOperationArgs)
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
additionalResolvers.push({
|
|
722
|
+
[subscriptionType.name]: { [field.name]: resolver }
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
709
727
|
const unifiedGraphDirectives = utils.getDirectiveExtensions(unifiedGraph);
|
|
710
728
|
let executableUnifiedGraph = federation.getStitchedSchemaFromSupergraphSdl({
|
|
711
729
|
supergraphSdl: utils.getDocumentNodeFromSchema(unifiedGraph),
|
|
@@ -858,21 +876,6 @@ const handleFederationSupergraph = function({
|
|
|
858
876
|
}
|
|
859
877
|
}
|
|
860
878
|
}
|
|
861
|
-
if (executableUnifiedGraph.getDirective("pubsubOperation")) {
|
|
862
|
-
executableUnifiedGraph = utils.mapSchema(executableUnifiedGraph, {
|
|
863
|
-
[utils.MapperKind.ROOT_FIELD](fieldConfig) {
|
|
864
|
-
const directiveExtensions = utils.getDirectiveExtensions(fieldConfig, executableUnifiedGraph);
|
|
865
|
-
if (directiveExtensions.pubsubOperation?.length) {
|
|
866
|
-
for (const pubsubOperationArgs of directiveExtensions.pubsubOperation) {
|
|
867
|
-
const { subscribe, resolve } = utils$1.getResolverForPubSubOperation(pubsubOperationArgs);
|
|
868
|
-
fieldConfig.subscribe = subscribe;
|
|
869
|
-
fieldConfig.resolve = resolve;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
return fieldConfig;
|
|
873
|
-
}
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
879
|
if (executableUnifiedGraph.getDirective("pubsubPublish")) {
|
|
877
880
|
executableUnifiedGraph = utils.mapSchema(executableUnifiedGraph, {
|
|
878
881
|
[utils.MapperKind.ROOT_FIELD](fieldConfig) {
|
|
@@ -1238,7 +1241,7 @@ function compareSubgraphNames(name1, name2) {
|
|
|
1238
1241
|
return constantCase(name1) === constantCase(name2);
|
|
1239
1242
|
}
|
|
1240
1243
|
function wrapMergedTypeResolver(originalResolver, typeName, onDelegationStageExecuteHooks, log) {
|
|
1241
|
-
return (object, context, info, subschema, selectionSet, key, type) => {
|
|
1244
|
+
return (object, context, info, subschema, selectionSet, key, type, skipTypeMerging) => {
|
|
1242
1245
|
if (subschema.name) {
|
|
1243
1246
|
log = log.child({ subgraph: subschema.name });
|
|
1244
1247
|
}
|
|
@@ -1274,7 +1277,8 @@ function wrapMergedTypeResolver(originalResolver, typeName, onDelegationStageExe
|
|
|
1274
1277
|
subschema,
|
|
1275
1278
|
selectionSet,
|
|
1276
1279
|
key,
|
|
1277
|
-
type
|
|
1280
|
+
type,
|
|
1281
|
+
skipTypeMerging
|
|
1278
1282
|
),
|
|
1279
1283
|
(result) => {
|
|
1280
1284
|
function setResult(newResult) {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getInstrumented } from '@envelop/instrumentation';
|
|
2
2
|
import { LegacyLogger, Logger } from '@graphql-hive/logger';
|
|
3
3
|
import { defaultPrintFn, createDefaultExecutor } from '@graphql-mesh/transport-common';
|
|
4
|
-
import {
|
|
4
|
+
import { getResolverForPubSubOperation, getInContextSDK, resolveAdditionalResolversWithoutImport, isDisposable, iterateAsync, dispose, makeAsyncDisposable } from '@graphql-mesh/utils';
|
|
5
5
|
import { getBatchingExecutor } from '@graphql-tools/batch-execute';
|
|
6
6
|
import { getDirectiveExtensions, mapSchema, MapperKind, astFromField, asArray, getDocumentNodeFromSchema, memoize1, isDocumentNode, printSchemaWithDirectives, mergeDeep, isAsyncIterable, createGraphQLError } from '@graphql-tools/utils';
|
|
7
7
|
import { handleMaybePromise, isPromise, mapAsyncIterator } from '@whatwg-node/promise-helpers';
|
|
@@ -704,6 +704,24 @@ const handleFederationSupergraph = function({
|
|
|
704
704
|
}
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
|
+
const subscriptionType = unifiedGraph.getSubscriptionType();
|
|
708
|
+
if (subscriptionType) {
|
|
709
|
+
for (const field of Object.values(subscriptionType.getFields())) {
|
|
710
|
+
const pubsubOperations = getDirectiveExtensions(field, unifiedGraph).pubsubOperation;
|
|
711
|
+
if (pubsubOperations?.length) {
|
|
712
|
+
const resolver = {};
|
|
713
|
+
for (const pubsubOperationArgs of pubsubOperations) {
|
|
714
|
+
Object.assign(
|
|
715
|
+
resolver,
|
|
716
|
+
getResolverForPubSubOperation(pubsubOperationArgs)
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
additionalResolvers.push({
|
|
720
|
+
[subscriptionType.name]: { [field.name]: resolver }
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
707
725
|
const unifiedGraphDirectives = getDirectiveExtensions(unifiedGraph);
|
|
708
726
|
let executableUnifiedGraph = getStitchedSchemaFromSupergraphSdl({
|
|
709
727
|
supergraphSdl: getDocumentNodeFromSchema(unifiedGraph),
|
|
@@ -856,21 +874,6 @@ const handleFederationSupergraph = function({
|
|
|
856
874
|
}
|
|
857
875
|
}
|
|
858
876
|
}
|
|
859
|
-
if (executableUnifiedGraph.getDirective("pubsubOperation")) {
|
|
860
|
-
executableUnifiedGraph = mapSchema(executableUnifiedGraph, {
|
|
861
|
-
[MapperKind.ROOT_FIELD](fieldConfig) {
|
|
862
|
-
const directiveExtensions = getDirectiveExtensions(fieldConfig, executableUnifiedGraph);
|
|
863
|
-
if (directiveExtensions.pubsubOperation?.length) {
|
|
864
|
-
for (const pubsubOperationArgs of directiveExtensions.pubsubOperation) {
|
|
865
|
-
const { subscribe, resolve } = getResolverForPubSubOperation(pubsubOperationArgs);
|
|
866
|
-
fieldConfig.subscribe = subscribe;
|
|
867
|
-
fieldConfig.resolve = resolve;
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
return fieldConfig;
|
|
871
|
-
}
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
877
|
if (executableUnifiedGraph.getDirective("pubsubPublish")) {
|
|
875
878
|
executableUnifiedGraph = mapSchema(executableUnifiedGraph, {
|
|
876
879
|
[MapperKind.ROOT_FIELD](fieldConfig) {
|
|
@@ -1236,7 +1239,7 @@ function compareSubgraphNames(name1, name2) {
|
|
|
1236
1239
|
return constantCase(name1) === constantCase(name2);
|
|
1237
1240
|
}
|
|
1238
1241
|
function wrapMergedTypeResolver(originalResolver, typeName, onDelegationStageExecuteHooks, log) {
|
|
1239
|
-
return (object, context, info, subschema, selectionSet, key, type) => {
|
|
1242
|
+
return (object, context, info, subschema, selectionSet, key, type, skipTypeMerging) => {
|
|
1240
1243
|
if (subschema.name) {
|
|
1241
1244
|
log = log.child({ subgraph: subschema.name });
|
|
1242
1245
|
}
|
|
@@ -1272,7 +1275,8 @@ function wrapMergedTypeResolver(originalResolver, typeName, onDelegationStageExe
|
|
|
1272
1275
|
subschema,
|
|
1273
1276
|
selectionSet,
|
|
1274
1277
|
key,
|
|
1275
|
-
type
|
|
1278
|
+
type,
|
|
1279
|
+
skipTypeMerging
|
|
1276
1280
|
),
|
|
1277
1281
|
(result) => {
|
|
1278
1282
|
function setResult(newResult) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/fusion-runtime",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Runtime for GraphQL Mesh Fusion Supergraph",
|
|
6
6
|
"repository": {
|
|
@@ -47,25 +47,25 @@
|
|
|
47
47
|
"@envelop/instrumentation": "^1.0.0",
|
|
48
48
|
"@graphql-hive/logger": "^1.1.1",
|
|
49
49
|
"@graphql-mesh/cross-helpers": "^0.4.13",
|
|
50
|
-
"@graphql-mesh/transport-common": "^1.0.
|
|
50
|
+
"@graphql-mesh/transport-common": "^1.0.18",
|
|
51
51
|
"@graphql-mesh/types": "^0.104.28",
|
|
52
|
-
"@graphql-mesh/utils": "^0.104.
|
|
52
|
+
"@graphql-mesh/utils": "^0.104.38",
|
|
53
53
|
"@graphql-tools/batch-execute": "^10.0.9",
|
|
54
|
-
"@graphql-tools/delegate": "^12.0
|
|
54
|
+
"@graphql-tools/delegate": "^12.1.0",
|
|
55
55
|
"@graphql-tools/executor": "^1.4.13",
|
|
56
|
-
"@graphql-tools/federation": "^4.4.
|
|
56
|
+
"@graphql-tools/federation": "^4.4.10",
|
|
57
57
|
"@graphql-tools/merge": "^9.1.5",
|
|
58
|
-
"@graphql-tools/stitch": "^10.
|
|
59
|
-
"@graphql-tools/stitching-directives": "^4.0.
|
|
58
|
+
"@graphql-tools/stitch": "^10.2.0",
|
|
59
|
+
"@graphql-tools/stitching-directives": "^4.0.26",
|
|
60
60
|
"@graphql-tools/utils": "^11.0.0",
|
|
61
|
-
"@graphql-tools/wrap": "^11.1.
|
|
61
|
+
"@graphql-tools/wrap": "^11.1.20",
|
|
62
62
|
"@whatwg-node/disposablestack": "^0.0.6",
|
|
63
63
|
"@whatwg-node/promise-helpers": "^1.3.2",
|
|
64
64
|
"graphql-yoga": "^5.21.1",
|
|
65
65
|
"tslib": "^2.8.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@graphql-hive/router-runtime": "^1.4.
|
|
68
|
+
"@graphql-hive/router-runtime": "^1.4.18",
|
|
69
69
|
"change-case": "^5.4.4",
|
|
70
70
|
"graphql": "^16.12.0",
|
|
71
71
|
"pkgroll": "2.27.1"
|