@graphql-mesh/transform-encapsulate 0.95.5 → 0.95.6
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/cjs/index.js +20 -1
- package/esm/index.js +20 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const graphql_1 = require("graphql");
|
|
3
4
|
const utils_1 = require("@graphql-mesh/utils");
|
|
4
5
|
const utils_2 = require("@graphql-tools/utils");
|
|
5
6
|
const wrap_1 = require("@graphql-tools/wrap");
|
|
@@ -46,7 +47,25 @@ class EncapsulateTransform {
|
|
|
46
47
|
return (0, utils_1.applySchemaTransforms)(originalWrappingSchema, subschemaConfig, transformedSchema, this.transforms);
|
|
47
48
|
}
|
|
48
49
|
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
49
|
-
|
|
50
|
+
const transformedRequest = (0, utils_1.applyRequestTransforms)(originalRequest, delegationContext, transformationContext, this.transforms);
|
|
51
|
+
if (delegationContext.operation === 'subscription') {
|
|
52
|
+
transformedRequest.document = {
|
|
53
|
+
...transformedRequest.document,
|
|
54
|
+
definitions: transformedRequest.document.definitions.map(def => {
|
|
55
|
+
if (def.kind === graphql_1.Kind.OPERATION_DEFINITION) {
|
|
56
|
+
return {
|
|
57
|
+
...def,
|
|
58
|
+
selectionSet: {
|
|
59
|
+
...def.selectionSet,
|
|
60
|
+
selections: def.selectionSet.selections.filter(selection => selection.kind === graphql_1.Kind.FIELD && selection.name.value !== '__typename'),
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return def;
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return transformedRequest;
|
|
50
69
|
}
|
|
51
70
|
transformResult(originalResult, delegationContext, transformationContext) {
|
|
52
71
|
return (0, utils_1.applyResultTransforms)(originalResult, delegationContext, transformationContext, this.transforms);
|
package/esm/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Kind } from 'graphql';
|
|
1
2
|
import { applyRequestTransforms, applyResultTransforms, applySchemaTransforms, } from '@graphql-mesh/utils';
|
|
2
3
|
import { getRootTypeMap, selectObjectFields, } from '@graphql-tools/utils';
|
|
3
4
|
import { WrapType } from '@graphql-tools/wrap';
|
|
@@ -44,7 +45,25 @@ export default class EncapsulateTransform {
|
|
|
44
45
|
return applySchemaTransforms(originalWrappingSchema, subschemaConfig, transformedSchema, this.transforms);
|
|
45
46
|
}
|
|
46
47
|
transformRequest(originalRequest, delegationContext, transformationContext) {
|
|
47
|
-
|
|
48
|
+
const transformedRequest = applyRequestTransforms(originalRequest, delegationContext, transformationContext, this.transforms);
|
|
49
|
+
if (delegationContext.operation === 'subscription') {
|
|
50
|
+
transformedRequest.document = {
|
|
51
|
+
...transformedRequest.document,
|
|
52
|
+
definitions: transformedRequest.document.definitions.map(def => {
|
|
53
|
+
if (def.kind === Kind.OPERATION_DEFINITION) {
|
|
54
|
+
return {
|
|
55
|
+
...def,
|
|
56
|
+
selectionSet: {
|
|
57
|
+
...def.selectionSet,
|
|
58
|
+
selections: def.selectionSet.selections.filter(selection => selection.kind === Kind.FIELD && selection.name.value !== '__typename'),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return def;
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return transformedRequest;
|
|
48
67
|
}
|
|
49
68
|
transformResult(originalResult, delegationContext, transformationContext) {
|
|
50
69
|
return applyResultTransforms(originalResult, delegationContext, transformationContext, this.transforms);
|