@graphql-codegen/plugin-helpers 2.2.0-alpha-e04750ad3.0 → 2.3.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.
package/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from './helpers';
5
5
  export * from './federation';
6
6
  export * from './errors';
7
7
  export * from './getCachedDocumentNodeFromSchema';
8
+ export * from './oldVisit';
package/index.js CHANGED
@@ -216,15 +216,17 @@ function isUsingTypes(document, externalFragments, schema) {
216
216
  }
217
217
  },
218
218
  },
219
- enter: {
220
- VariableDefinition: (node, key, parent, path, anscestors) => {
219
+ VariableDefinition: {
220
+ enter: (node, key, parent, path, anscestors) => {
221
221
  const insideIgnoredFragment = anscestors.find((f) => f.kind && f.kind === 'FragmentDefinition' && externalFragments.includes(f.name.value));
222
222
  if (insideIgnoredFragment) {
223
223
  return;
224
224
  }
225
225
  foundFields++;
226
226
  },
227
- InputValueDefinition: (node, key, parent, path, anscestors) => {
227
+ },
228
+ InputValueDefinition: {
229
+ enter: (node, key, parent, path, anscestors) => {
228
230
  const insideIgnoredFragment = anscestors.find((f) => f.kind && f.kind === 'FragmentDefinition' && externalFragments.includes(f.name.value));
229
231
  if (insideIgnoredFragment) {
230
232
  return;
@@ -396,7 +398,7 @@ class ApolloFederation {
396
398
  extractKeyOrRequiresFieldSet(directive) {
397
399
  const arg = directive.arguments.find(arg => arg.name.value === 'fields');
398
400
  const value = arg.value.value;
399
- return graphql.visit(graphql.parse(`{${value}}`), {
401
+ return oldVisit(graphql.parse(`{${value}}`), {
400
402
  leave: {
401
403
  SelectionSet(node) {
402
404
  return node.selections.reduce((accum, field) => {
@@ -499,6 +501,22 @@ function isDetailedError(error) {
499
501
 
500
502
  const getCachedDocumentNodeFromSchema = utils.memoize1(utils.getDocumentNodeFromSchema);
501
503
 
504
+ function oldVisit(root, { enter: enterVisitors, leave: leaveVisitors, ...newVisitor }) {
505
+ if (typeof enterVisitors === 'object') {
506
+ for (const key in enterVisitors) {
507
+ newVisitor[key] = newVisitor[key] || {};
508
+ newVisitor[key].enter = enterVisitors[key];
509
+ }
510
+ }
511
+ if (typeof leaveVisitors === 'object') {
512
+ for (const key in leaveVisitors) {
513
+ newVisitor[key] = newVisitor[key] || {};
514
+ newVisitor[key].leave = leaveVisitors[key];
515
+ }
516
+ }
517
+ return graphql.visit(root, newVisitor);
518
+ }
519
+
502
520
  exports.ApolloFederation = ApolloFederation;
503
521
  exports.DetailedError = DetailedError;
504
522
  exports.addFederationReferencesToSchema = addFederationReferencesToSchema;
@@ -516,6 +534,7 @@ exports.mergeOutputs = mergeOutputs;
516
534
  exports.normalizeConfig = normalizeConfig;
517
535
  exports.normalizeInstanceOrArray = normalizeInstanceOrArray;
518
536
  exports.normalizeOutputParam = normalizeOutputParam;
537
+ exports.oldVisit = oldVisit;
519
538
  exports.removeFederation = removeFederation;
520
539
  exports.removeNonNullWrapper = removeNonNullWrapper;
521
540
  exports.resolveExternalModuleAndFn = resolveExternalModuleAndFn;
package/index.mjs CHANGED
@@ -210,15 +210,17 @@ function isUsingTypes(document, externalFragments, schema) {
210
210
  }
211
211
  },
212
212
  },
213
- enter: {
214
- VariableDefinition: (node, key, parent, path, anscestors) => {
213
+ VariableDefinition: {
214
+ enter: (node, key, parent, path, anscestors) => {
215
215
  const insideIgnoredFragment = anscestors.find((f) => f.kind && f.kind === 'FragmentDefinition' && externalFragments.includes(f.name.value));
216
216
  if (insideIgnoredFragment) {
217
217
  return;
218
218
  }
219
219
  foundFields++;
220
220
  },
221
- InputValueDefinition: (node, key, parent, path, anscestors) => {
221
+ },
222
+ InputValueDefinition: {
223
+ enter: (node, key, parent, path, anscestors) => {
222
224
  const insideIgnoredFragment = anscestors.find((f) => f.kind && f.kind === 'FragmentDefinition' && externalFragments.includes(f.name.value));
223
225
  if (insideIgnoredFragment) {
224
226
  return;
@@ -390,7 +392,7 @@ class ApolloFederation {
390
392
  extractKeyOrRequiresFieldSet(directive) {
391
393
  const arg = directive.arguments.find(arg => arg.name.value === 'fields');
392
394
  const value = arg.value.value;
393
- return visit(parse(`{${value}}`), {
395
+ return oldVisit(parse(`{${value}}`), {
394
396
  leave: {
395
397
  SelectionSet(node) {
396
398
  return node.selections.reduce((accum, field) => {
@@ -493,4 +495,20 @@ function isDetailedError(error) {
493
495
 
494
496
  const getCachedDocumentNodeFromSchema = memoize1(getDocumentNodeFromSchema);
495
497
 
496
- export { ApolloFederation, DetailedError, addFederationReferencesToSchema, federationSpec, getBaseType, getCachedDocumentNodeFromSchema, hasNullableTypeRecursively, isComplexPluginOutput, isConfiguredOutput, isDetailedError, isOutputConfigArray, isUsingTypes, isWrapperType, mergeOutputs, normalizeConfig, normalizeInstanceOrArray, normalizeOutputParam, removeFederation, removeNonNullWrapper, resolveExternalModuleAndFn };
498
+ function oldVisit(root, { enter: enterVisitors, leave: leaveVisitors, ...newVisitor }) {
499
+ if (typeof enterVisitors === 'object') {
500
+ for (const key in enterVisitors) {
501
+ newVisitor[key] = newVisitor[key] || {};
502
+ newVisitor[key].enter = enterVisitors[key];
503
+ }
504
+ }
505
+ if (typeof leaveVisitors === 'object') {
506
+ for (const key in leaveVisitors) {
507
+ newVisitor[key] = newVisitor[key] || {};
508
+ newVisitor[key].leave = leaveVisitors[key];
509
+ }
510
+ }
511
+ return visit(root, newVisitor);
512
+ }
513
+
514
+ export { ApolloFederation, DetailedError, addFederationReferencesToSchema, federationSpec, getBaseType, getCachedDocumentNodeFromSchema, hasNullableTypeRecursively, isComplexPluginOutput, isConfiguredOutput, isDetailedError, isOutputConfigArray, isUsingTypes, isWrapperType, mergeOutputs, normalizeConfig, normalizeInstanceOrArray, normalizeOutputParam, oldVisit, removeFederation, removeNonNullWrapper, resolveExternalModuleAndFn };
package/oldVisit.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ASTNode, visit } from 'graphql';
2
+ declare type VisitFn = typeof visit;
3
+ declare type NewVisitor = Partial<Parameters<VisitFn>[1]>;
4
+ declare type OldVisitor = {
5
+ enter?: Partial<Record<keyof NewVisitor, NewVisitor[keyof NewVisitor]['enter']>>;
6
+ leave?: Partial<Record<keyof NewVisitor, NewVisitor[keyof NewVisitor]['leave']>>;
7
+ } & NewVisitor;
8
+ export declare function oldVisit(root: ASTNode, { enter: enterVisitors, leave: leaveVisitors, ...newVisitor }: OldVisitor): any;
9
+ export {};
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@graphql-codegen/plugin-helpers",
3
- "version": "2.2.0-alpha-e04750ad3.0",
3
+ "version": "2.3.1",
4
4
  "description": "GraphQL Code Generator common utils and types",
5
5
  "peerDependencies": {
6
- "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0"
6
+ "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
7
7
  },
8
8
  "dependencies": {
9
- "@graphql-tools/utils": "^8.1.1",
9
+ "@graphql-tools/utils": "^8.5.2",
10
10
  "change-case-all": "1.0.14",
11
11
  "common-tags": "1.8.0",
12
12
  "import-from": "4.0.0",
package/utils.d.ts CHANGED
@@ -3,4 +3,4 @@ import { Types } from './types';
3
3
  export declare function mergeOutputs(content: Types.PluginOutput | Array<Types.PluginOutput>): string;
4
4
  export declare function isWrapperType(t: GraphQLOutputType): t is GraphQLNonNull<any> | GraphQLList<any>;
5
5
  export declare function getBaseType(type: GraphQLOutputType): GraphQLNamedType;
6
- export declare function removeNonNullWrapper(type: GraphQLOutputType): GraphQLNamedType;
6
+ export declare function removeNonNullWrapper(type: GraphQLOutputType): GraphQLOutputType;