@envelop/graphql-middleware 3.3.2-alpha-763ffe6.0 → 3.3.3-alpha-329be36.0
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/index.js +6 -3
- package/index.mjs +6 -3
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -4,16 +4,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const graphqlMiddleware = require('graphql-middleware');
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const graphqlMiddlewareAppliedTransformSymbol = Symbol('graphqlMiddleware.appliedTransform');
|
|
8
8
|
const useGraphQLMiddleware = (middlewares) => {
|
|
9
9
|
return {
|
|
10
10
|
onSchemaChange({ schema, replaceSchema }) {
|
|
11
|
-
if (schema
|
|
11
|
+
if (graphqlMiddlewareAppliedTransformSymbol in schema.extensions) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
if (middlewares.length > 0) {
|
|
15
15
|
const wrappedSchema = graphqlMiddleware.applyMiddleware(schema, ...middlewares);
|
|
16
|
-
wrappedSchema
|
|
16
|
+
wrappedSchema.extensions = {
|
|
17
|
+
...schema.extensions,
|
|
18
|
+
[graphqlMiddlewareAppliedTransformSymbol]: true,
|
|
19
|
+
};
|
|
17
20
|
replaceSchema(wrappedSchema);
|
|
18
21
|
}
|
|
19
22
|
},
|
package/index.mjs
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { applyMiddleware } from 'graphql-middleware';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const graphqlMiddlewareAppliedTransformSymbol = Symbol('graphqlMiddleware.appliedTransform');
|
|
4
4
|
const useGraphQLMiddleware = (middlewares) => {
|
|
5
5
|
return {
|
|
6
6
|
onSchemaChange({ schema, replaceSchema }) {
|
|
7
|
-
if (schema
|
|
7
|
+
if (graphqlMiddlewareAppliedTransformSymbol in schema.extensions) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
if (middlewares.length > 0) {
|
|
11
11
|
const wrappedSchema = applyMiddleware(schema, ...middlewares);
|
|
12
|
-
wrappedSchema
|
|
12
|
+
wrappedSchema.extensions = {
|
|
13
|
+
...schema.extensions,
|
|
14
|
+
[graphqlMiddlewareAppliedTransformSymbol]: true,
|
|
15
|
+
};
|
|
13
16
|
replaceSchema(wrappedSchema);
|
|
14
17
|
}
|
|
15
18
|
},
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/graphql-middleware",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.3-alpha-329be36.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "2.3.2
|
|
6
|
+
"@envelop/core": "^2.3.2",
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
8
8
|
"graphql-middleware": "^6.0.0"
|
|
9
9
|
},
|