@envelop/generic-auth 11.2.2 → 11.2.3

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 CHANGED
@@ -11,13 +11,6 @@ const executor_1 = require("@graphql-tools/executor");
11
11
  const utils_1 = require("@graphql-tools/utils");
12
12
  const promise_helpers_1 = require("@whatwg-node/promise-helpers");
13
13
  const utils_js_1 = require("./utils.js");
14
- // graphql-js 17 changed `getDirectiveValues`'s `variableValues` parameter from a plain
15
- // `{ [name]: value }` map to the `{ sources, coerced }` wrapper produced by its own
16
- // `getVariableValues`. `@graphql-tools/utils`'s `shouldIncludeNode` (which delegates to
17
- // `getDirectiveValues` for `@skip`/`@include`) still passes the plain map through unchanged,
18
- // so under graphql-js 17 it crashes on any `@skip`/`@include` that references a variable.
19
- // Wrap the plain map to match until `@graphql-tools/utils` is updated for the new contract.
20
- const isGraphQL17OrAbove = parseInt(graphql_1.version.split('.')[0], 10) >= 17;
21
14
  exports.DIRECTIVE_SDL = `
22
15
  directive @authenticated on FIELD_DEFINITION | OBJECT | INTERFACE
23
16
  `;
@@ -137,14 +130,7 @@ const useGenericAuth = (options) => {
137
130
  const schema = context.getSchema();
138
131
  const operationAST = (0, graphql_1.getOperationAST)(args.document, args.operationName);
139
132
  const variableDefinitions = operationAST?.variableDefinitions;
140
- let variableValues;
141
- if (variableDefinitions?.length) {
142
- const { coerced } = (0, executor_1.getVariableValues)(schema, variableDefinitions, args.variableValues || {});
143
- variableValues = coerced;
144
- }
145
- else {
146
- variableValues = args.variableValues;
147
- }
133
+ const { variableValues } = (0, executor_1.getVariableValues)(schema, variableDefinitions ?? [], args.variableValues || {});
148
134
  const operationType = operationAST?.operation ?? 'query';
149
135
  const fragmentPaths = new Map();
150
136
  function getResolvePath(path, currType) {
@@ -231,10 +217,8 @@ const useGenericAuth = (options) => {
231
217
  }
232
218
  },
233
219
  Field(node, key, parent, path, ancestors) {
234
- const directiveVariableValues = isGraphQL17OrAbove
235
- ? { coerced: variableValues, sources: {} }
236
- : variableValues;
237
- if (variableValues && !(0, utils_1.shouldIncludeNode)(directiveVariableValues, node)) {
220
+ // shouldIncludeNode takes the wrapper, not the raw variable map
221
+ if (variableValues && !(0, utils_1.shouldIncludeNode)(variableValues, node)) {
238
222
  return;
239
223
  }
240
224
  const fieldType = (0, graphql_1.getNamedType)(context.getParentType());
package/esm/index.js CHANGED
@@ -1,16 +1,9 @@
1
- import { getNamedType, getOperationAST, version as graphqlVersion, isAbstractType, isInterfaceType, isIntrospectionType, isListType, isObjectType, isUnionType, } from 'graphql';
1
+ import { getNamedType, getOperationAST, isAbstractType, isInterfaceType, isIntrospectionType, isListType, isObjectType, isUnionType, } from 'graphql';
2
2
  import { useExtendedValidation } from '@envelop/extended-validation';
3
3
  import { getVariableValues } from '@graphql-tools/executor';
4
4
  import { createGraphQLError, getDefinedRootType, getDirectiveExtensions, shouldIncludeNode, } from '@graphql-tools/utils';
5
5
  import { handleMaybePromise } from '@whatwg-node/promise-helpers';
6
6
  import { removeEmptyOrUnusedNodes } from './utils.js';
7
- // graphql-js 17 changed `getDirectiveValues`'s `variableValues` parameter from a plain
8
- // `{ [name]: value }` map to the `{ sources, coerced }` wrapper produced by its own
9
- // `getVariableValues`. `@graphql-tools/utils`'s `shouldIncludeNode` (which delegates to
10
- // `getDirectiveValues` for `@skip`/`@include`) still passes the plain map through unchanged,
11
- // so under graphql-js 17 it crashes on any `@skip`/`@include` that references a variable.
12
- // Wrap the plain map to match until `@graphql-tools/utils` is updated for the new contract.
13
- const isGraphQL17OrAbove = parseInt(graphqlVersion.split('.')[0], 10) >= 17;
14
7
  export const DIRECTIVE_SDL = /* GraphQL */ `
15
8
  directive @authenticated on FIELD_DEFINITION | OBJECT | INTERFACE
16
9
  `;
@@ -130,14 +123,7 @@ export const useGenericAuth = (options) => {
130
123
  const schema = context.getSchema();
131
124
  const operationAST = getOperationAST(args.document, args.operationName);
132
125
  const variableDefinitions = operationAST?.variableDefinitions;
133
- let variableValues;
134
- if (variableDefinitions?.length) {
135
- const { coerced } = getVariableValues(schema, variableDefinitions, args.variableValues || {});
136
- variableValues = coerced;
137
- }
138
- else {
139
- variableValues = args.variableValues;
140
- }
126
+ const { variableValues } = getVariableValues(schema, variableDefinitions ?? [], args.variableValues || {});
141
127
  const operationType = operationAST?.operation ?? 'query';
142
128
  const fragmentPaths = new Map();
143
129
  function getResolvePath(path, currType) {
@@ -224,10 +210,8 @@ export const useGenericAuth = (options) => {
224
210
  }
225
211
  },
226
212
  Field(node, key, parent, path, ancestors) {
227
- const directiveVariableValues = isGraphQL17OrAbove
228
- ? { coerced: variableValues, sources: {} }
229
- : variableValues;
230
- if (variableValues && !shouldIncludeNode(directiveVariableValues, node)) {
213
+ // shouldIncludeNode takes the wrapper, not the raw variable map
214
+ if (variableValues && !shouldIncludeNode(variableValues, node)) {
231
215
  return;
232
216
  }
233
217
  const fieldType = getNamedType(context.getParentType());
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@envelop/generic-auth",
3
- "version": "11.2.2",
3
+ "version": "11.2.3",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
7
7
  "@envelop/core": "^5.6.1"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/executor": "^1.5.7",
11
- "@graphql-tools/utils": "^11.2.2",
10
+ "@graphql-tools/executor": "^2.0.3",
11
+ "@graphql-tools/utils": "^12.0.3",
12
12
  "@whatwg-node/promise-helpers": "^1.2.1",
13
13
  "tslib": "^2.5.0",
14
- "@envelop/extended-validation": "^7.2.2"
14
+ "@envelop/extended-validation": "^7.2.3"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",