@envelop/core 2.5.0 → 2.5.1-alpha-20220822173124-85a67c8e

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/utils.js CHANGED
@@ -8,17 +8,20 @@ function isOperationDefinition(def) {
8
8
  }
9
9
  exports.isOperationDefinition = isOperationDefinition;
10
10
  function isIntrospectionOperation(operation) {
11
+ var _a;
11
12
  if (operation.kind === 'OperationDefinition') {
12
- let hasIntrospectionField = false;
13
- (0, graphql_1.visit)(operation, {
14
- Field: node => {
15
- if (node.name.value === '__schema') {
16
- hasIntrospectionField = true;
17
- return graphql_1.BREAK;
18
- }
19
- },
13
+ if (((_a = operation.name) === null || _a === void 0 ? void 0 : _a.value) === '__schema') {
14
+ return true;
15
+ }
16
+ const nodesWithSchema = operation.selectionSet.selections.filter(selection => {
17
+ if (selection.kind === 'Field' && selection.name.value === '__schema') {
18
+ return true;
19
+ }
20
+ return false;
20
21
  });
21
- return hasIntrospectionField;
22
+ if (nodesWithSchema.length > 0) {
23
+ return true;
24
+ }
22
25
  }
23
26
  return false;
24
27
  }
package/esm/utils.js CHANGED
@@ -1,20 +1,23 @@
1
- import { Kind, visit, BREAK, } from 'graphql';
1
+ import { Kind, } from 'graphql';
2
2
  export const envelopIsIntrospectionSymbol = Symbol('ENVELOP_IS_INTROSPECTION');
3
3
  export function isOperationDefinition(def) {
4
4
  return def.kind === Kind.OPERATION_DEFINITION;
5
5
  }
6
6
  export function isIntrospectionOperation(operation) {
7
+ var _a;
7
8
  if (operation.kind === 'OperationDefinition') {
8
- let hasIntrospectionField = false;
9
- visit(operation, {
10
- Field: node => {
11
- if (node.name.value === '__schema') {
12
- hasIntrospectionField = true;
13
- return BREAK;
14
- }
15
- },
9
+ if (((_a = operation.name) === null || _a === void 0 ? void 0 : _a.value) === '__schema') {
10
+ return true;
11
+ }
12
+ const nodesWithSchema = operation.selectionSet.selections.filter(selection => {
13
+ if (selection.kind === 'Field' && selection.name.value === '__schema') {
14
+ return true;
15
+ }
16
+ return false;
16
17
  });
17
- return hasIntrospectionField;
18
+ if (nodesWithSchema.length > 0) {
19
+ return true;
20
+ }
18
21
  }
19
22
  return false;
20
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envelop/core",
3
- "version": "2.5.0",
3
+ "version": "2.5.1-alpha-20220822173124-85a67c8e",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"