@graphql-tools/utils 8.2.2 → 9.0.0-alpha-8ae2f1b1.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.
Files changed (58) hide show
  1. package/index.js +77 -19
  2. package/index.mjs +76 -20
  3. package/memoize.d.ts +2 -0
  4. package/package.json +1 -1
  5. package/es5/AggregateError.d.ts +0 -10
  6. package/es5/Interfaces.d.ts +0 -242
  7. package/es5/addTypes.d.ts +0 -2
  8. package/es5/astFromType.d.ts +0 -2
  9. package/es5/astFromValueUntyped.d.ts +0 -17
  10. package/es5/build-operation-for-field.d.ts +0 -18
  11. package/es5/collectFields.d.ts +0 -5
  12. package/es5/comments.d.ts +0 -30
  13. package/es5/errors.d.ts +0 -2
  14. package/es5/executor.d.ts +0 -7
  15. package/es5/fields.d.ts +0 -5
  16. package/es5/filterSchema.d.ts +0 -12
  17. package/es5/fixSchemaAst.d.ts +0 -3
  18. package/es5/forEachDefaultValue.d.ts +0 -3
  19. package/es5/forEachField.d.ts +0 -3
  20. package/es5/get-directives.d.ts +0 -11
  21. package/es5/get-fields-with-directives.d.ts +0 -16
  22. package/es5/get-implementing-types.d.ts +0 -2
  23. package/es5/getArgumentValues.d.ts +0 -10
  24. package/es5/getObjectTypeFromTypeMap.d.ts +0 -3
  25. package/es5/getResolversFromSchema.d.ts +0 -3
  26. package/es5/getResponseKeyFromInfo.d.ts +0 -7
  27. package/es5/heal.d.ts +0 -3
  28. package/es5/helpers.d.ts +0 -9
  29. package/es5/implementsAbstractType.d.ts +0 -3
  30. package/es5/index.d.ts +0 -49
  31. package/es5/index.js +0 -4842
  32. package/es5/index.mjs +0 -4734
  33. package/es5/inspect.d.ts +0 -4
  34. package/es5/isAsyncIterable.d.ts +0 -1
  35. package/es5/isDocumentNode.d.ts +0 -2
  36. package/es5/loaders.d.ts +0 -18
  37. package/es5/mapAsyncIterator.d.ts +0 -5
  38. package/es5/mapSchema.d.ts +0 -7
  39. package/es5/memoize.d.ts +0 -6
  40. package/es5/mergeDeep.d.ts +0 -9
  41. package/es5/observableToAsyncIterable.d.ts +0 -12
  42. package/es5/package.json +0 -35
  43. package/es5/parse-graphql-json.d.ts +0 -4
  44. package/es5/parse-graphql-sdl.d.ts +0 -13
  45. package/es5/print-schema-with-directives.d.ts +0 -21
  46. package/es5/prune.d.ts +0 -8
  47. package/es5/renameType.d.ts +0 -8
  48. package/es5/rewire.d.ts +0 -5
  49. package/es5/rootTypes.d.ts +0 -5
  50. package/es5/selectionSets.d.ts +0 -3
  51. package/es5/stub.d.ts +0 -9
  52. package/es5/transformInputValue.d.ts +0 -6
  53. package/es5/types.d.ts +0 -49
  54. package/es5/updateArgument.d.ts +0 -3
  55. package/es5/validate-documents.d.ts +0 -9
  56. package/es5/valueMatchesCriteria.d.ts +0 -1
  57. package/es5/visitResult.d.ts +0 -15
  58. package/es5/withCancel.d.ts +0 -3
package/index.js CHANGED
@@ -484,24 +484,24 @@ function astFromValueUntyped(value) {
484
484
  const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/;
485
485
 
486
486
  function memoize1(fn) {
487
- const memoize1cache = new WeakMap();
487
+ const cache1 = new WeakMap();
488
488
  return function memoized(a1) {
489
- const cachedValue = memoize1cache.get(a1);
489
+ const cachedValue = cache1.get(a1);
490
490
  if (cachedValue === undefined) {
491
491
  const newValue = fn(a1);
492
- memoize1cache.set(a1, newValue);
492
+ cache1.set(a1, newValue);
493
493
  return newValue;
494
494
  }
495
495
  return cachedValue;
496
496
  };
497
497
  }
498
498
  function memoize2(fn) {
499
- const memoize2cache = new WeakMap();
499
+ const cache1 = new WeakMap();
500
500
  return function memoized(a1, a2) {
501
- let cache2 = memoize2cache.get(a1);
501
+ let cache2 = cache1.get(a1);
502
502
  if (!cache2) {
503
503
  cache2 = new WeakMap();
504
- memoize2cache.set(a1, cache2);
504
+ cache1.set(a1, cache2);
505
505
  const newValue = fn(a1, a2);
506
506
  cache2.set(a2, newValue);
507
507
  return newValue;
@@ -516,12 +516,12 @@ function memoize2(fn) {
516
516
  };
517
517
  }
518
518
  function memoize3(fn) {
519
- const memoize3Cache = new WeakMap();
519
+ const cache1 = new WeakMap();
520
520
  return function memoized(a1, a2, a3) {
521
- let cache2 = memoize3Cache.get(a1);
521
+ let cache2 = cache1.get(a1);
522
522
  if (!cache2) {
523
523
  cache2 = new WeakMap();
524
- memoize3Cache.set(a1, cache2);
524
+ cache1.set(a1, cache2);
525
525
  const cache3 = new WeakMap();
526
526
  cache2.set(a2, cache3);
527
527
  const newValue = fn(a1, a2, a3);
@@ -546,12 +546,12 @@ function memoize3(fn) {
546
546
  };
547
547
  }
548
548
  function memoize4(fn) {
549
- const memoize4Cache = new WeakMap();
549
+ const cache1 = new WeakMap();
550
550
  return function memoized(a1, a2, a3, a4) {
551
- let cache2 = memoize4Cache.get(a1);
551
+ let cache2 = cache1.get(a1);
552
552
  if (!cache2) {
553
553
  cache2 = new WeakMap();
554
- memoize4Cache.set(a1, cache2);
554
+ cache1.set(a1, cache2);
555
555
  const cache3 = new WeakMap();
556
556
  cache2.set(a2, cache3);
557
557
  const cache4 = new WeakMap();
@@ -588,12 +588,12 @@ function memoize4(fn) {
588
588
  };
589
589
  }
590
590
  function memoize5(fn) {
591
- const memoize5Cache = new WeakMap();
591
+ const cache1 = new WeakMap();
592
592
  return function memoized(a1, a2, a3, a4, a5) {
593
- let cache2 = memoize5Cache.get(a1);
593
+ let cache2 = cache1.get(a1);
594
594
  if (!cache2) {
595
595
  cache2 = new WeakMap();
596
- memoize5Cache.set(a1, cache2);
596
+ cache1.set(a1, cache2);
597
597
  const cache3 = new WeakMap();
598
598
  cache2.set(a2, cache3);
599
599
  const cache4 = new WeakMap();
@@ -643,13 +643,25 @@ function memoize5(fn) {
643
643
  return cachedValue;
644
644
  };
645
645
  }
646
- const memoize2of4cache = new WeakMap();
646
+ function memoize1of2(fn) {
647
+ const cache1 = new WeakMap();
648
+ return function memoized(a1, a2) {
649
+ const cachedValue = cache1.get(a1);
650
+ if (cachedValue === undefined) {
651
+ const newValue = fn(a1, a2);
652
+ cache1.set(a1, newValue);
653
+ return newValue;
654
+ }
655
+ return cachedValue;
656
+ };
657
+ }
647
658
  function memoize2of4(fn) {
659
+ const cache1 = new WeakMap();
648
660
  return function memoized(a1, a2, a3, a4) {
649
- let cache2 = memoize2of4cache.get(a1);
661
+ let cache2 = cache1.get(a1);
650
662
  if (!cache2) {
651
663
  cache2 = new WeakMap();
652
- memoize2of4cache.set(a1, cache2);
664
+ cache1.set(a1, cache2);
653
665
  const newValue = fn(a1, a2, a3, a4);
654
666
  cache2.set(a2, newValue);
655
667
  return newValue;
@@ -663,6 +675,48 @@ function memoize2of4(fn) {
663
675
  return cachedValue;
664
676
  };
665
677
  }
678
+ function memoize4ofMany(fn) {
679
+ const cache1 = new WeakMap();
680
+ return function memoized(a1, a2, a3, a4, ...args) {
681
+ let cache2 = cache1.get(a1);
682
+ if (!cache2) {
683
+ cache2 = new WeakMap();
684
+ cache1.set(a1, cache2);
685
+ const cache3 = new WeakMap();
686
+ cache2.set(a2, cache3);
687
+ const cache4 = new WeakMap();
688
+ cache3.set(a3, cache4);
689
+ const newValue = fn(a1, a2, a3, a4, ...args);
690
+ cache4.set(a4, newValue);
691
+ return newValue;
692
+ }
693
+ let cache3 = cache2.get(a2);
694
+ if (!cache3) {
695
+ cache3 = new WeakMap();
696
+ cache2.set(a2, cache3);
697
+ const cache4 = new WeakMap();
698
+ cache3.set(a3, cache4);
699
+ const newValue = fn(a1, a2, a3, a4, ...args);
700
+ cache4.set(a4, newValue);
701
+ return newValue;
702
+ }
703
+ const cache4 = cache3.get(a3);
704
+ if (!cache4) {
705
+ const cache4 = new WeakMap();
706
+ cache3.set(a3, cache4);
707
+ const newValue = fn(a1, a2, a3, a4, ...args);
708
+ cache4.set(a4, newValue);
709
+ return newValue;
710
+ }
711
+ const cachedValue = cache4.get(a4);
712
+ if (cachedValue === undefined) {
713
+ const newValue = fn(a1, a2, a3, a4, ...args);
714
+ cache4.set(a4, newValue);
715
+ return newValue;
716
+ }
717
+ return cachedValue;
718
+ };
719
+ }
666
720
 
667
721
  function getDefinedRootType(schema, operation) {
668
722
  const rootTypeMap = getRootTypeMap(schema);
@@ -3930,7 +3984,9 @@ function visitData(data, enter, leave) {
3930
3984
  if (newData != null) {
3931
3985
  for (const key in newData) {
3932
3986
  const value = newData[key];
3933
- newData[key] = visitData(value, enter, leave);
3987
+ Object.defineProperty(newData, key, {
3988
+ value: visitData(value, enter, leave),
3989
+ });
3934
3990
  }
3935
3991
  }
3936
3992
  return leave != null ? leave(newData) : newData;
@@ -4250,10 +4306,12 @@ exports.makeDirectiveNodes = makeDirectiveNodes;
4250
4306
  exports.mapAsyncIterator = mapAsyncIterator;
4251
4307
  exports.mapSchema = mapSchema;
4252
4308
  exports.memoize1 = memoize1;
4309
+ exports.memoize1of2 = memoize1of2;
4253
4310
  exports.memoize2 = memoize2;
4254
4311
  exports.memoize2of4 = memoize2of4;
4255
4312
  exports.memoize3 = memoize3;
4256
4313
  exports.memoize4 = memoize4;
4314
+ exports.memoize4ofMany = memoize4ofMany;
4257
4315
  exports.memoize5 = memoize5;
4258
4316
  exports.mergeDeep = mergeDeep;
4259
4317
  exports.modifyObjectFields = modifyObjectFields;
package/index.mjs CHANGED
@@ -480,24 +480,24 @@ function astFromValueUntyped(value) {
480
480
  const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/;
481
481
 
482
482
  function memoize1(fn) {
483
- const memoize1cache = new WeakMap();
483
+ const cache1 = new WeakMap();
484
484
  return function memoized(a1) {
485
- const cachedValue = memoize1cache.get(a1);
485
+ const cachedValue = cache1.get(a1);
486
486
  if (cachedValue === undefined) {
487
487
  const newValue = fn(a1);
488
- memoize1cache.set(a1, newValue);
488
+ cache1.set(a1, newValue);
489
489
  return newValue;
490
490
  }
491
491
  return cachedValue;
492
492
  };
493
493
  }
494
494
  function memoize2(fn) {
495
- const memoize2cache = new WeakMap();
495
+ const cache1 = new WeakMap();
496
496
  return function memoized(a1, a2) {
497
- let cache2 = memoize2cache.get(a1);
497
+ let cache2 = cache1.get(a1);
498
498
  if (!cache2) {
499
499
  cache2 = new WeakMap();
500
- memoize2cache.set(a1, cache2);
500
+ cache1.set(a1, cache2);
501
501
  const newValue = fn(a1, a2);
502
502
  cache2.set(a2, newValue);
503
503
  return newValue;
@@ -512,12 +512,12 @@ function memoize2(fn) {
512
512
  };
513
513
  }
514
514
  function memoize3(fn) {
515
- const memoize3Cache = new WeakMap();
515
+ const cache1 = new WeakMap();
516
516
  return function memoized(a1, a2, a3) {
517
- let cache2 = memoize3Cache.get(a1);
517
+ let cache2 = cache1.get(a1);
518
518
  if (!cache2) {
519
519
  cache2 = new WeakMap();
520
- memoize3Cache.set(a1, cache2);
520
+ cache1.set(a1, cache2);
521
521
  const cache3 = new WeakMap();
522
522
  cache2.set(a2, cache3);
523
523
  const newValue = fn(a1, a2, a3);
@@ -542,12 +542,12 @@ function memoize3(fn) {
542
542
  };
543
543
  }
544
544
  function memoize4(fn) {
545
- const memoize4Cache = new WeakMap();
545
+ const cache1 = new WeakMap();
546
546
  return function memoized(a1, a2, a3, a4) {
547
- let cache2 = memoize4Cache.get(a1);
547
+ let cache2 = cache1.get(a1);
548
548
  if (!cache2) {
549
549
  cache2 = new WeakMap();
550
- memoize4Cache.set(a1, cache2);
550
+ cache1.set(a1, cache2);
551
551
  const cache3 = new WeakMap();
552
552
  cache2.set(a2, cache3);
553
553
  const cache4 = new WeakMap();
@@ -584,12 +584,12 @@ function memoize4(fn) {
584
584
  };
585
585
  }
586
586
  function memoize5(fn) {
587
- const memoize5Cache = new WeakMap();
587
+ const cache1 = new WeakMap();
588
588
  return function memoized(a1, a2, a3, a4, a5) {
589
- let cache2 = memoize5Cache.get(a1);
589
+ let cache2 = cache1.get(a1);
590
590
  if (!cache2) {
591
591
  cache2 = new WeakMap();
592
- memoize5Cache.set(a1, cache2);
592
+ cache1.set(a1, cache2);
593
593
  const cache3 = new WeakMap();
594
594
  cache2.set(a2, cache3);
595
595
  const cache4 = new WeakMap();
@@ -639,13 +639,25 @@ function memoize5(fn) {
639
639
  return cachedValue;
640
640
  };
641
641
  }
642
- const memoize2of4cache = new WeakMap();
642
+ function memoize1of2(fn) {
643
+ const cache1 = new WeakMap();
644
+ return function memoized(a1, a2) {
645
+ const cachedValue = cache1.get(a1);
646
+ if (cachedValue === undefined) {
647
+ const newValue = fn(a1, a2);
648
+ cache1.set(a1, newValue);
649
+ return newValue;
650
+ }
651
+ return cachedValue;
652
+ };
653
+ }
643
654
  function memoize2of4(fn) {
655
+ const cache1 = new WeakMap();
644
656
  return function memoized(a1, a2, a3, a4) {
645
- let cache2 = memoize2of4cache.get(a1);
657
+ let cache2 = cache1.get(a1);
646
658
  if (!cache2) {
647
659
  cache2 = new WeakMap();
648
- memoize2of4cache.set(a1, cache2);
660
+ cache1.set(a1, cache2);
649
661
  const newValue = fn(a1, a2, a3, a4);
650
662
  cache2.set(a2, newValue);
651
663
  return newValue;
@@ -659,6 +671,48 @@ function memoize2of4(fn) {
659
671
  return cachedValue;
660
672
  };
661
673
  }
674
+ function memoize4ofMany(fn) {
675
+ const cache1 = new WeakMap();
676
+ return function memoized(a1, a2, a3, a4, ...args) {
677
+ let cache2 = cache1.get(a1);
678
+ if (!cache2) {
679
+ cache2 = new WeakMap();
680
+ cache1.set(a1, cache2);
681
+ const cache3 = new WeakMap();
682
+ cache2.set(a2, cache3);
683
+ const cache4 = new WeakMap();
684
+ cache3.set(a3, cache4);
685
+ const newValue = fn(a1, a2, a3, a4, ...args);
686
+ cache4.set(a4, newValue);
687
+ return newValue;
688
+ }
689
+ let cache3 = cache2.get(a2);
690
+ if (!cache3) {
691
+ cache3 = new WeakMap();
692
+ cache2.set(a2, cache3);
693
+ const cache4 = new WeakMap();
694
+ cache3.set(a3, cache4);
695
+ const newValue = fn(a1, a2, a3, a4, ...args);
696
+ cache4.set(a4, newValue);
697
+ return newValue;
698
+ }
699
+ const cache4 = cache3.get(a3);
700
+ if (!cache4) {
701
+ const cache4 = new WeakMap();
702
+ cache3.set(a3, cache4);
703
+ const newValue = fn(a1, a2, a3, a4, ...args);
704
+ cache4.set(a4, newValue);
705
+ return newValue;
706
+ }
707
+ const cachedValue = cache4.get(a4);
708
+ if (cachedValue === undefined) {
709
+ const newValue = fn(a1, a2, a3, a4, ...args);
710
+ cache4.set(a4, newValue);
711
+ return newValue;
712
+ }
713
+ return cachedValue;
714
+ };
715
+ }
662
716
 
663
717
  function getDefinedRootType(schema, operation) {
664
718
  const rootTypeMap = getRootTypeMap(schema);
@@ -3927,7 +3981,9 @@ function visitData(data, enter, leave) {
3927
3981
  if (newData != null) {
3928
3982
  for (const key in newData) {
3929
3983
  const value = newData[key];
3930
- newData[key] = visitData(value, enter, leave);
3984
+ Object.defineProperty(newData, key, {
3985
+ value: visitData(value, enter, leave),
3986
+ });
3931
3987
  }
3932
3988
  }
3933
3989
  return leave != null ? leave(newData) : newData;
@@ -4176,4 +4232,4 @@ function fixSchemaAst(schema, options) {
4176
4232
  return schema;
4177
4233
  }
4178
4234
 
4179
- export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, withCancel };
4235
+ export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize1of2, memoize2, memoize2of4, memoize3, memoize4, memoize4ofMany, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, withCancel };
package/memoize.d.ts CHANGED
@@ -3,4 +3,6 @@ export declare function memoize2<F extends (a1: any, a2: any) => any>(fn: F): F;
3
3
  export declare function memoize3<F extends (a1: any, a2: any, a3: any) => any>(fn: F): F;
4
4
  export declare function memoize4<F extends (a1: any, a2: any, a3: any, a4: any) => any>(fn: F): F;
5
5
  export declare function memoize5<F extends (a1: any, a2: any, a3: any, a4: any, a5: any) => any>(fn: F): F;
6
+ export declare function memoize1of2<F extends (a1: any, a2: any) => any>(fn: F): F;
6
7
  export declare function memoize2of4<F extends (a1: any, a2: any, a3: any, a4: any) => any>(fn: F): F;
8
+ export declare function memoize4ofMany<F extends (a1: any, a2: any, a3: any, a4: any, ...args: Array<any>) => any>(fn: F): F;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils",
3
- "version": "8.2.2",
3
+ "version": "9.0.0-alpha-8ae2f1b1.0",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -1,10 +0,0 @@
1
- interface AggregateError extends Error {
2
- errors: any[];
3
- }
4
- interface AggregateErrorConstructor {
5
- new (errors: Iterable<any>, message?: string): AggregateError;
6
- (errors: Iterable<any>, message?: string): AggregateError;
7
- readonly prototype: AggregateError;
8
- }
9
- declare let AggregateErrorImpl: AggregateErrorConstructor;
10
- export { AggregateErrorImpl as AggregateError };
@@ -1,242 +0,0 @@
1
- import { GraphQLSchema, GraphQLField, GraphQLInputType, GraphQLNamedType, GraphQLResolveInfo, GraphQLScalarType, DocumentNode, FieldNode, GraphQLEnumValue, GraphQLEnumType, GraphQLUnionType, GraphQLArgument, GraphQLInputField, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLObjectType, GraphQLDirective, FragmentDefinitionNode, SelectionNode, ExecutionResult as GraphQLExecutionResult, GraphQLOutputType, FieldDefinitionNode, GraphQLFieldConfig, GraphQLInputFieldConfig, GraphQLArgumentConfig, GraphQLEnumValueConfig, GraphQLScalarSerializer, GraphQLScalarValueParser, GraphQLScalarLiteralParser, ScalarTypeDefinitionNode, ScalarTypeExtensionNode, EnumTypeDefinitionNode, EnumTypeExtensionNode, GraphQLIsTypeOfFn, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, InterfaceTypeExtensionNode, InterfaceTypeDefinitionNode, GraphQLTypeResolver, UnionTypeDefinitionNode, UnionTypeExtensionNode, InputObjectTypeExtensionNode, InputObjectTypeDefinitionNode, GraphQLType, Source, DefinitionNode, OperationTypeNode } from 'graphql';
2
- export declare type ExecutionResult<TData = Record<string, any>> = GraphQLExecutionResult & {
3
- data?: TData | null;
4
- extensions?: Record<string, any>;
5
- };
6
- export interface ExecutionRequest<TArgs extends Record<string, any> = Record<string, any>, TContext = any, TRootValue = any, TExtensions = Record<string, any>> {
7
- document: DocumentNode;
8
- operationType: OperationTypeNode;
9
- variables?: TArgs;
10
- operationName?: string;
11
- extensions?: TExtensions;
12
- rootValue?: TRootValue;
13
- context?: TContext;
14
- info?: GraphQLResolveInfo;
15
- }
16
- export interface GraphQLParseOptions {
17
- noLocation?: boolean;
18
- allowLegacySDLEmptyFields?: boolean;
19
- allowLegacySDLImplementsInterfaces?: boolean;
20
- experimentalFragmentVariables?: boolean;
21
- /**
22
- * Set to `true` in order to convert all GraphQL comments (marked with # sign) to descriptions (""")
23
- * GraphQL has built-in support for transforming descriptions to comments (with `print`), but not while
24
- * parsing. Turning the flag on will support the other way as well (`parse`)
25
- */
26
- commentDescriptions?: boolean;
27
- }
28
- export declare type ValidatorBehavior = 'error' | 'warn' | 'ignore';
29
- /**
30
- * Options for validating resolvers
31
- */
32
- export interface IResolverValidationOptions {
33
- /**
34
- * Enable to require a resolver to be defined for any field that has
35
- * arguments. Defaults to `ignore`.
36
- */
37
- requireResolversForArgs?: ValidatorBehavior;
38
- /**
39
- * Enable to require a resolver to be defined for any field which has
40
- * a return type that isn't a scalar. Defaults to `ignore`.
41
- */
42
- requireResolversForNonScalar?: ValidatorBehavior;
43
- /**
44
- * Enable to require a resolver for be defined for all fields defined
45
- * in the schema. Defaults to `ignore`.
46
- */
47
- requireResolversForAllFields?: ValidatorBehavior;
48
- /**
49
- * Enable to require a `resolveType()` for Interface and Union types.
50
- * Defaults to `ignore`.
51
- */
52
- requireResolversForResolveType?: ValidatorBehavior;
53
- /**
54
- * Enable to require all defined resolvers to match fields that
55
- * actually exist in the schema. Defaults to `error` to catch common errors.
56
- */
57
- requireResolversToMatchSchema?: ValidatorBehavior;
58
- }
59
- /**
60
- * Configuration object for adding resolvers to a schema
61
- */
62
- export interface IAddResolversToSchemaOptions {
63
- /**
64
- * The schema to which to add resolvers
65
- */
66
- schema: GraphQLSchema;
67
- /**
68
- * Object describing the field resolvers to add to the provided schema
69
- */
70
- resolvers: IResolvers;
71
- /**
72
- * Override the default field resolver provided by `graphql-js`
73
- */
74
- defaultFieldResolver?: IFieldResolver<any, any>;
75
- /**
76
- * Additional options for validating the provided resolvers
77
- */
78
- resolverValidationOptions?: IResolverValidationOptions;
79
- /**
80
- * GraphQL object types that implement interfaces will inherit any missing
81
- * resolvers from their interface types defined in the `resolvers` object
82
- */
83
- inheritResolversFromInterfaces?: boolean;
84
- /**
85
- * Set to `true` to modify the existing schema instead of creating a new one
86
- */
87
- updateResolversInPlace?: boolean;
88
- }
89
- export declare type IScalarTypeResolver = GraphQLScalarType & {
90
- __name?: string;
91
- __description?: string;
92
- __serialize?: GraphQLScalarSerializer<any>;
93
- __parseValue?: GraphQLScalarValueParser<any>;
94
- __parseLiteral?: GraphQLScalarLiteralParser<any>;
95
- __extensions?: Record<string, any>;
96
- __astNode?: ScalarTypeDefinitionNode;
97
- __extensionASTNodes?: Array<ScalarTypeExtensionNode>;
98
- };
99
- export declare type IEnumTypeResolver = Record<string, any> & {
100
- __name?: string;
101
- __description?: string;
102
- __extensions?: Record<string, any>;
103
- __astNode?: EnumTypeDefinitionNode;
104
- __extensionASTNodes?: Array<EnumTypeExtensionNode>;
105
- };
106
- export interface IFieldResolverOptions<TSource = any, TContext = any, TArgs = any> {
107
- name?: string;
108
- description?: string;
109
- type?: GraphQLOutputType;
110
- args?: Array<GraphQLArgument>;
111
- resolve?: IFieldResolver<TSource, TContext, TArgs>;
112
- subscribe?: IFieldResolver<TSource, TContext, TArgs>;
113
- isDeprecated?: boolean;
114
- deprecationReason?: string;
115
- extensions?: Record<string, any>;
116
- astNode?: FieldDefinitionNode;
117
- }
118
- export declare type FieldNodeMapper = (fieldNode: FieldNode, fragments: Record<string, FragmentDefinitionNode>, transformationContext: Record<string, any>) => SelectionNode | Array<SelectionNode>;
119
- export declare type FieldNodeMappers = Record<string, Record<string, FieldNodeMapper>>;
120
- export declare type InputFieldFilter = (typeName?: string, fieldName?: string, inputFieldConfig?: GraphQLInputFieldConfig) => boolean;
121
- export declare type FieldFilter = (typeName: string, fieldName: string, fieldConfig: GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig) => boolean;
122
- export declare type ObjectFieldFilter = (typeName: string, fieldName: string, fieldConfig: GraphQLFieldConfig<any, any>) => boolean;
123
- export declare type RootFieldFilter = (operation: 'Query' | 'Mutation' | 'Subscription', rootFieldName: string, fieldConfig: GraphQLFieldConfig<any, any>) => boolean;
124
- export declare type TypeFilter = (typeName: string, type: GraphQLType) => boolean;
125
- export declare type ArgumentFilter = (typeName?: string, fieldName?: string, argName?: string, argConfig?: GraphQLArgumentConfig) => boolean;
126
- export declare type RenameTypesOptions = {
127
- renameBuiltins: boolean;
128
- renameScalars: boolean;
129
- };
130
- export declare type IFieldResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => TReturn;
131
- export declare type TypeSource = string | Source | DocumentNode | GraphQLSchema | DefinitionNode | Array<TypeSource> | (() => TypeSource);
132
- export declare type IObjectTypeResolver<TSource = any, TContext = any, TArgs = any> = {
133
- [key: string]: IFieldResolver<TSource, TContext, TArgs> | IFieldResolverOptions<TSource, TContext>;
134
- } & {
135
- __name?: string;
136
- __description?: string;
137
- __isTypeOf?: GraphQLIsTypeOfFn<TSource, TContext>;
138
- __extensions?: Record<string, any>;
139
- __astNode?: ObjectTypeDefinitionNode;
140
- __extensionASTNodes?: ObjectTypeExtensionNode;
141
- };
142
- export declare type IInterfaceTypeResolver<TSource = any, TContext = any, TArgs = any> = {
143
- [key: string]: IFieldResolver<TSource, TContext, TArgs> | IFieldResolverOptions<TSource, TContext>;
144
- } & {
145
- __name?: string;
146
- __description?: string;
147
- __resolveType?: GraphQLTypeResolver<any, any>;
148
- __extensions?: Record<string, any>;
149
- __astNode?: InterfaceTypeDefinitionNode;
150
- __extensionASTNodes?: Array<InterfaceTypeExtensionNode>;
151
- };
152
- export declare type IUnionTypeResolver = {
153
- __name?: string;
154
- __description?: string;
155
- __resolveType?: GraphQLTypeResolver<any, any>;
156
- __extensions?: Record<string, any>;
157
- __astNode?: UnionTypeDefinitionNode;
158
- __extensionASTNodes?: Array<UnionTypeExtensionNode>;
159
- };
160
- export declare type IInputObjectTypeResolver = {
161
- __name?: string;
162
- __description?: string;
163
- __extensions?: Record<string, any>;
164
- __astNode?: InputObjectTypeDefinitionNode;
165
- __extensionASTNodes?: Array<InputObjectTypeExtensionNode>;
166
- };
167
- export declare type ISchemaLevelResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = IFieldResolver<TSource, TContext, TArgs, TReturn>;
168
- export declare type IResolvers<TSource = any, TContext = any, TArgs = Record<string, any>, TReturn = any> = Record<string, ISchemaLevelResolver<TSource, TContext, TArgs, TReturn> | IObjectTypeResolver<TSource, TContext> | IInterfaceTypeResolver<TSource, TContext> | IUnionTypeResolver | IScalarTypeResolver | IEnumTypeResolver | IInputObjectTypeResolver>;
169
- export declare type IFieldIteratorFn = (fieldDef: GraphQLField<any, any>, typeName: string, fieldName: string) => void;
170
- export declare type IDefaultValueIteratorFn = (type: GraphQLInputType, value: any) => void;
171
- export declare type NextResolverFn = () => Promise<any>;
172
- export declare type VisitableSchemaType = GraphQLSchema | GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType | GraphQLNamedType | GraphQLScalarType | GraphQLField<any, any> | GraphQLInputField | GraphQLArgument | GraphQLUnionType | GraphQLEnumType | GraphQLEnumValue;
173
- export declare enum MapperKind {
174
- TYPE = "MapperKind.TYPE",
175
- SCALAR_TYPE = "MapperKind.SCALAR_TYPE",
176
- ENUM_TYPE = "MapperKind.ENUM_TYPE",
177
- COMPOSITE_TYPE = "MapperKind.COMPOSITE_TYPE",
178
- OBJECT_TYPE = "MapperKind.OBJECT_TYPE",
179
- INPUT_OBJECT_TYPE = "MapperKind.INPUT_OBJECT_TYPE",
180
- ABSTRACT_TYPE = "MapperKind.ABSTRACT_TYPE",
181
- UNION_TYPE = "MapperKind.UNION_TYPE",
182
- INTERFACE_TYPE = "MapperKind.INTERFACE_TYPE",
183
- ROOT_OBJECT = "MapperKind.ROOT_OBJECT",
184
- QUERY = "MapperKind.QUERY",
185
- MUTATION = "MapperKind.MUTATION",
186
- SUBSCRIPTION = "MapperKind.SUBSCRIPTION",
187
- DIRECTIVE = "MapperKind.DIRECTIVE",
188
- FIELD = "MapperKind.FIELD",
189
- COMPOSITE_FIELD = "MapperKind.COMPOSITE_FIELD",
190
- OBJECT_FIELD = "MapperKind.OBJECT_FIELD",
191
- ROOT_FIELD = "MapperKind.ROOT_FIELD",
192
- QUERY_ROOT_FIELD = "MapperKind.QUERY_ROOT_FIELD",
193
- MUTATION_ROOT_FIELD = "MapperKind.MUTATION_ROOT_FIELD",
194
- SUBSCRIPTION_ROOT_FIELD = "MapperKind.SUBSCRIPTION_ROOT_FIELD",
195
- INTERFACE_FIELD = "MapperKind.INTERFACE_FIELD",
196
- INPUT_OBJECT_FIELD = "MapperKind.INPUT_OBJECT_FIELD",
197
- ARGUMENT = "MapperKind.ARGUMENT",
198
- ENUM_VALUE = "MapperKind.ENUM_VALUE"
199
- }
200
- export interface SchemaMapper {
201
- [MapperKind.TYPE]?: NamedTypeMapper;
202
- [MapperKind.SCALAR_TYPE]?: ScalarTypeMapper;
203
- [MapperKind.ENUM_TYPE]?: EnumTypeMapper;
204
- [MapperKind.COMPOSITE_TYPE]?: CompositeTypeMapper;
205
- [MapperKind.OBJECT_TYPE]?: ObjectTypeMapper;
206
- [MapperKind.INPUT_OBJECT_TYPE]?: InputObjectTypeMapper;
207
- [MapperKind.ABSTRACT_TYPE]?: AbstractTypeMapper;
208
- [MapperKind.UNION_TYPE]?: UnionTypeMapper;
209
- [MapperKind.INTERFACE_TYPE]?: InterfaceTypeMapper;
210
- [MapperKind.ROOT_OBJECT]?: ObjectTypeMapper;
211
- [MapperKind.QUERY]?: ObjectTypeMapper;
212
- [MapperKind.MUTATION]?: ObjectTypeMapper;
213
- [MapperKind.SUBSCRIPTION]?: ObjectTypeMapper;
214
- [MapperKind.ENUM_VALUE]?: EnumValueMapper;
215
- [MapperKind.FIELD]?: GenericFieldMapper<GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig>;
216
- [MapperKind.OBJECT_FIELD]?: FieldMapper;
217
- [MapperKind.ROOT_FIELD]?: FieldMapper;
218
- [MapperKind.QUERY_ROOT_FIELD]?: FieldMapper;
219
- [MapperKind.MUTATION_ROOT_FIELD]?: FieldMapper;
220
- [MapperKind.SUBSCRIPTION_ROOT_FIELD]?: FieldMapper;
221
- [MapperKind.INTERFACE_FIELD]?: FieldMapper;
222
- [MapperKind.COMPOSITE_FIELD]?: FieldMapper;
223
- [MapperKind.ARGUMENT]?: ArgumentMapper;
224
- [MapperKind.INPUT_OBJECT_FIELD]?: InputFieldMapper;
225
- [MapperKind.DIRECTIVE]?: DirectiveMapper;
226
- }
227
- export declare type SchemaFieldMapperTypes = Array<MapperKind.FIELD | MapperKind.COMPOSITE_FIELD | MapperKind.OBJECT_FIELD | MapperKind.ROOT_FIELD | MapperKind.QUERY_ROOT_FIELD | MapperKind.MUTATION_ROOT_FIELD | MapperKind.SUBSCRIPTION_ROOT_FIELD | MapperKind.INTERFACE_FIELD | MapperKind.INPUT_OBJECT_FIELD>;
228
- export declare type NamedTypeMapper = (type: GraphQLNamedType, schema: GraphQLSchema) => GraphQLNamedType | null | undefined;
229
- export declare type ScalarTypeMapper = (type: GraphQLScalarType, schema: GraphQLSchema) => GraphQLScalarType | null | undefined;
230
- export declare type EnumTypeMapper = (type: GraphQLEnumType, schema: GraphQLSchema) => GraphQLEnumType | null | undefined;
231
- export declare type EnumValueMapper = (valueConfig: GraphQLEnumValueConfig, typeName: string, schema: GraphQLSchema, externalValue: string) => GraphQLEnumValueConfig | [string, GraphQLEnumValueConfig] | null | undefined;
232
- export declare type CompositeTypeMapper = (type: GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType, schema: GraphQLSchema) => GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | null | undefined;
233
- export declare type ObjectTypeMapper = (type: GraphQLObjectType, schema: GraphQLSchema) => GraphQLObjectType | null | undefined;
234
- export declare type InputObjectTypeMapper = (type: GraphQLInputObjectType, schema: GraphQLSchema) => GraphQLInputObjectType | null | undefined;
235
- export declare type AbstractTypeMapper = (type: GraphQLInterfaceType | GraphQLUnionType, schema: GraphQLSchema) => GraphQLInterfaceType | GraphQLUnionType | null | undefined;
236
- export declare type UnionTypeMapper = (type: GraphQLUnionType, schema: GraphQLSchema) => GraphQLUnionType | null | undefined;
237
- export declare type InterfaceTypeMapper = (type: GraphQLInterfaceType, schema: GraphQLSchema) => GraphQLInterfaceType | null | undefined;
238
- export declare type DirectiveMapper = (directive: GraphQLDirective, schema: GraphQLSchema) => GraphQLDirective | null | undefined;
239
- export declare type GenericFieldMapper<F extends GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig> = (fieldConfig: F, fieldName: string, typeName: string, schema: GraphQLSchema) => F | [string, F] | null | undefined;
240
- export declare type FieldMapper = GenericFieldMapper<GraphQLFieldConfig<any, any>>;
241
- export declare type ArgumentMapper = (argumentConfig: GraphQLArgumentConfig, fieldName: string, typeName: string, schema: GraphQLSchema) => GraphQLArgumentConfig | [string, GraphQLArgumentConfig] | null | undefined;
242
- export declare type InputFieldMapper = GenericFieldMapper<GraphQLInputFieldConfig>;
package/es5/addTypes.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { GraphQLSchema, GraphQLNamedType, GraphQLDirective } from 'graphql';
2
- export declare function addTypes(schema: GraphQLSchema, newTypesOrDirectives: Array<GraphQLNamedType | GraphQLDirective>): GraphQLSchema;
@@ -1,2 +0,0 @@
1
- import { GraphQLType, TypeNode } from 'graphql';
2
- export declare function astFromType(type: GraphQLType): TypeNode;
@@ -1,17 +0,0 @@
1
- import { ValueNode } from 'graphql';
2
- /**
3
- * Produces a GraphQL Value AST given a JavaScript object.
4
- * Function will match JavaScript/JSON values to GraphQL AST schema format
5
- * by using the following mapping.
6
- *
7
- * | JSON Value | GraphQL Value |
8
- * | ------------- | -------------------- |
9
- * | Object | Input Object |
10
- * | Array | List |
11
- * | Boolean | Boolean |
12
- * | String | String |
13
- * | Number | Int / Float |
14
- * | null | NullValue |
15
- *
16
- */
17
- export declare function astFromValueUntyped(value: any): ValueNode | null;