@graphql-codegen/plugin-helpers 2.2.0-alpha-b24e050a5.0 → 2.3.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.
- package/index.d.ts +1 -0
- package/index.js +23 -4
- package/index.mjs +23 -5
- package/oldVisit.d.ts +9 -0
- package/package.json +1 -1
- package/types.d.ts +11 -1
- package/utils.d.ts +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -216,15 +216,17 @@ function isUsingTypes(document, externalFragments, schema) {
|
|
|
216
216
|
}
|
|
217
217
|
},
|
|
218
218
|
},
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
214
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/plugin-helpers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "GraphQL Code Generator common utils and types",
|
|
5
5
|
"peerDependencies": {
|
|
6
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"
|
package/types.d.ts
CHANGED
|
@@ -509,9 +509,19 @@ export declare namespace Types {
|
|
|
509
509
|
beforeAllFileWrite: T;
|
|
510
510
|
};
|
|
511
511
|
type SkipDocumentsValidationOptions = {
|
|
512
|
+
/**
|
|
513
|
+
* @description Allows you to skip specific rules while validating the documents.
|
|
514
|
+
* See all the rules; https://github.com/graphql/graphql-js/tree/main/src/validation/rules
|
|
515
|
+
*/
|
|
512
516
|
ignoreRules?: string[];
|
|
517
|
+
/**
|
|
518
|
+
* @description Ignore duplicate documents validation
|
|
519
|
+
*/
|
|
513
520
|
skipDuplicateValidation?: boolean;
|
|
514
|
-
|
|
521
|
+
/**
|
|
522
|
+
* @description Skip document validation entirely against the schema
|
|
523
|
+
*/
|
|
524
|
+
skipValidationAgainstSchema?: boolean;
|
|
515
525
|
} | boolean;
|
|
516
526
|
}
|
|
517
527
|
export declare function isComplexPluginOutput(obj: Types.PluginOutput): obj is Types.ComplexPluginOutput;
|
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):
|
|
6
|
+
export declare function removeNonNullWrapper(type: GraphQLOutputType): GraphQLOutputType;
|