@graphql-tools/utils 10.5.0 → 10.5.1

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.
@@ -352,39 +352,27 @@ function makeDeprecatedDirective(deprecationReason) {
352
352
  exports.makeDeprecatedDirective = makeDeprecatedDirective;
353
353
  function makeDirectiveNode(name, args, directive) {
354
354
  const directiveArguments = [];
355
- if (directive != null) {
356
- for (const arg of directive.args) {
357
- const argName = arg.name;
358
- const argValue = args?.[argName];
359
- if (argValue !== undefined) {
360
- const value = (0, astFromValue_js_1.astFromValue)(argValue, arg.type);
361
- if (value) {
362
- directiveArguments.push({
363
- kind: graphql_1.Kind.ARGUMENT,
364
- name: {
365
- kind: graphql_1.Kind.NAME,
366
- value: argName,
367
- },
368
- value,
369
- });
370
- }
355
+ for (const argName in args) {
356
+ const argValue = args[argName];
357
+ let value;
358
+ if (directive != null) {
359
+ const arg = directive.args.find(arg => arg.name === argName);
360
+ if (arg) {
361
+ value = (0, astFromValue_js_1.astFromValue)(argValue, arg.type);
371
362
  }
372
363
  }
373
- }
374
- else {
375
- for (const argName in args) {
376
- const argValue = args[argName];
377
- const value = (0, astFromValueUntyped_js_1.astFromValueUntyped)(argValue);
378
- if (value) {
379
- directiveArguments.push({
380
- kind: graphql_1.Kind.ARGUMENT,
381
- name: {
382
- kind: graphql_1.Kind.NAME,
383
- value: argName,
384
- },
385
- value,
386
- });
387
- }
364
+ if (value == null) {
365
+ value = (0, astFromValueUntyped_js_1.astFromValueUntyped)(argValue);
366
+ }
367
+ if (value != null) {
368
+ directiveArguments.push({
369
+ kind: graphql_1.Kind.ARGUMENT,
370
+ name: {
371
+ kind: graphql_1.Kind.NAME,
372
+ value: argName,
373
+ },
374
+ value,
375
+ });
388
376
  }
389
377
  }
390
378
  return {
@@ -332,39 +332,27 @@ export function makeDeprecatedDirective(deprecationReason) {
332
332
  }
333
333
  export function makeDirectiveNode(name, args, directive) {
334
334
  const directiveArguments = [];
335
- if (directive != null) {
336
- for (const arg of directive.args) {
337
- const argName = arg.name;
338
- const argValue = args?.[argName];
339
- if (argValue !== undefined) {
340
- const value = astFromValue(argValue, arg.type);
341
- if (value) {
342
- directiveArguments.push({
343
- kind: Kind.ARGUMENT,
344
- name: {
345
- kind: Kind.NAME,
346
- value: argName,
347
- },
348
- value,
349
- });
350
- }
335
+ for (const argName in args) {
336
+ const argValue = args[argName];
337
+ let value;
338
+ if (directive != null) {
339
+ const arg = directive.args.find(arg => arg.name === argName);
340
+ if (arg) {
341
+ value = astFromValue(argValue, arg.type);
351
342
  }
352
343
  }
353
- }
354
- else {
355
- for (const argName in args) {
356
- const argValue = args[argName];
357
- const value = astFromValueUntyped(argValue);
358
- if (value) {
359
- directiveArguments.push({
360
- kind: Kind.ARGUMENT,
361
- name: {
362
- kind: Kind.NAME,
363
- value: argName,
364
- },
365
- value,
366
- });
367
- }
344
+ if (value == null) {
345
+ value = astFromValueUntyped(argValue);
346
+ }
347
+ if (value != null) {
348
+ directiveArguments.push({
349
+ kind: Kind.ARGUMENT,
350
+ name: {
351
+ kind: Kind.NAME,
352
+ value: argName,
353
+ },
354
+ value,
355
+ });
368
356
  }
369
357
  }
370
358
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils",
3
- "version": "10.5.0",
3
+ "version": "10.5.1",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {