@graphql-codegen/visitor-plugin-common 7.1.1 → 7.1.3-alpha-20260625140734-1ad8f133387ecf5e348a737d91b1a2e22bcfab4f
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/selection-set-to-object.js +27 -3
- package/cjs/utils.js +1 -1
- package/esm/selection-set-to-object.js +27 -3
- package/esm/utils.js +1 -1
- package/package.json +4 -4
|
@@ -182,7 +182,7 @@ class SelectionSetToObject {
|
|
|
182
182
|
if (originalNode.kind === graphql_1.Kind.FIELD) {
|
|
183
183
|
return {
|
|
184
184
|
...originalNode,
|
|
185
|
-
fragmentDirectives: [...spread.directives],
|
|
185
|
+
fragmentDirectives: [...(spread.directives || [])],
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
188
|
return originalNode;
|
|
@@ -192,7 +192,7 @@ class SelectionSetToObject {
|
|
|
192
192
|
typeName: usage,
|
|
193
193
|
onType: fragmentSpreadObject.onType,
|
|
194
194
|
selectionNodes: fragmentSelectionNodes,
|
|
195
|
-
fragmentDirectives: [...spread.directives],
|
|
195
|
+
fragmentDirectives: [...(spread.directives || [])],
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
}
|
|
@@ -373,7 +373,31 @@ class SelectionSetToObject {
|
|
|
373
373
|
}
|
|
374
374
|
return prev;
|
|
375
375
|
}, []);
|
|
376
|
-
|
|
376
|
+
// Top-level INLINE_FRAGMENT / FRAGMENT_SPREAD nodes among the
|
|
377
|
+
// inlined selections cannot be consumed directly by
|
|
378
|
+
// `buildSelectionSet`, which only handles FIELD and DIRECTIVE
|
|
379
|
+
// kinds for AST nodes and throws "Unexpected type." otherwise.
|
|
380
|
+
// Route them through `flattenSelectionSet` — which already
|
|
381
|
+
// expands inline fragments and fragment spreads per type — and
|
|
382
|
+
// merge the FIELD-only result with the already-FIELD selections
|
|
383
|
+
// before handing off.
|
|
384
|
+
const directNodes = [];
|
|
385
|
+
const nestedSelections = [];
|
|
386
|
+
for (const n of flattenedSelectionNodes) {
|
|
387
|
+
if ('kind' in n &&
|
|
388
|
+
(n.kind === graphql_1.Kind.INLINE_FRAGMENT || n.kind === graphql_1.Kind.FRAGMENT_SPREAD)) {
|
|
389
|
+
nestedSelections.push(n);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
directNodes.push(n);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (nestedSelections.length) {
|
|
396
|
+
const { selectionNodesByTypeName: nestedByType } = this.flattenSelectionSet(nestedSelections, schemaType);
|
|
397
|
+
const nestedForThisType = nestedByType.get(typeName) ?? [];
|
|
398
|
+
directNodes.push(...nestedForThisType);
|
|
399
|
+
}
|
|
400
|
+
collectGrouped(directNodes);
|
|
377
401
|
}
|
|
378
402
|
if (incrementalDirectivesFound) {
|
|
379
403
|
for (const incrementalNode of selectionNodes) {
|
package/cjs/utils.js
CHANGED
|
@@ -540,7 +540,7 @@ const getFieldNames = ({ selections, fieldNames = new Set(), parentName = '', lo
|
|
|
540
540
|
exports.getFieldNames = getFieldNames;
|
|
541
541
|
const getNodeComment = (node) => {
|
|
542
542
|
let commentText = node.description?.value;
|
|
543
|
-
const deprecationDirective = node.directives
|
|
543
|
+
const deprecationDirective = node.directives?.find(v => v.name.value === 'deprecated');
|
|
544
544
|
if (deprecationDirective) {
|
|
545
545
|
const deprecationReason = getDeprecationReason(deprecationDirective);
|
|
546
546
|
commentText = `${commentText ? `${commentText}\n` : ''}@deprecated ${deprecationReason}`;
|
|
@@ -178,7 +178,7 @@ export class SelectionSetToObject {
|
|
|
178
178
|
if (originalNode.kind === Kind.FIELD) {
|
|
179
179
|
return {
|
|
180
180
|
...originalNode,
|
|
181
|
-
fragmentDirectives: [...spread.directives],
|
|
181
|
+
fragmentDirectives: [...(spread.directives || [])],
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
return originalNode;
|
|
@@ -188,7 +188,7 @@ export class SelectionSetToObject {
|
|
|
188
188
|
typeName: usage,
|
|
189
189
|
onType: fragmentSpreadObject.onType,
|
|
190
190
|
selectionNodes: fragmentSelectionNodes,
|
|
191
|
-
fragmentDirectives: [...spread.directives],
|
|
191
|
+
fragmentDirectives: [...(spread.directives || [])],
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
194
|
}
|
|
@@ -369,7 +369,31 @@ export class SelectionSetToObject {
|
|
|
369
369
|
}
|
|
370
370
|
return prev;
|
|
371
371
|
}, []);
|
|
372
|
-
|
|
372
|
+
// Top-level INLINE_FRAGMENT / FRAGMENT_SPREAD nodes among the
|
|
373
|
+
// inlined selections cannot be consumed directly by
|
|
374
|
+
// `buildSelectionSet`, which only handles FIELD and DIRECTIVE
|
|
375
|
+
// kinds for AST nodes and throws "Unexpected type." otherwise.
|
|
376
|
+
// Route them through `flattenSelectionSet` — which already
|
|
377
|
+
// expands inline fragments and fragment spreads per type — and
|
|
378
|
+
// merge the FIELD-only result with the already-FIELD selections
|
|
379
|
+
// before handing off.
|
|
380
|
+
const directNodes = [];
|
|
381
|
+
const nestedSelections = [];
|
|
382
|
+
for (const n of flattenedSelectionNodes) {
|
|
383
|
+
if ('kind' in n &&
|
|
384
|
+
(n.kind === Kind.INLINE_FRAGMENT || n.kind === Kind.FRAGMENT_SPREAD)) {
|
|
385
|
+
nestedSelections.push(n);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
directNodes.push(n);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (nestedSelections.length) {
|
|
392
|
+
const { selectionNodesByTypeName: nestedByType } = this.flattenSelectionSet(nestedSelections, schemaType);
|
|
393
|
+
const nestedForThisType = nestedByType.get(typeName) ?? [];
|
|
394
|
+
directNodes.push(...nestedForThisType);
|
|
395
|
+
}
|
|
396
|
+
collectGrouped(directNodes);
|
|
373
397
|
}
|
|
374
398
|
if (incrementalDirectivesFound) {
|
|
375
399
|
for (const incrementalNode of selectionNodes) {
|
package/esm/utils.js
CHANGED
|
@@ -510,7 +510,7 @@ export const getFieldNames = ({ selections, fieldNames = new Set(), parentName =
|
|
|
510
510
|
};
|
|
511
511
|
export const getNodeComment = (node) => {
|
|
512
512
|
let commentText = node.description?.value;
|
|
513
|
-
const deprecationDirective = node.directives
|
|
513
|
+
const deprecationDirective = node.directives?.find(v => v.name.value === 'deprecated');
|
|
514
514
|
if (deprecationDirective) {
|
|
515
515
|
const deprecationReason = getDeprecationReason(deprecationDirective);
|
|
516
516
|
commentText = `${commentText ? `${commentText}\n` : ''}@deprecated ${deprecationReason}`;
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/visitor-plugin-common",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.3-alpha-20260625140734-1ad8f133387ecf5e348a737d91b1a2e22bcfab4f",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"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"
|
|
5
|
+
"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 || ^17.0.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@graphql-tools/optimize": "^2.0.0",
|
|
9
9
|
"@graphql-tools/relay-operation-optimizer": "^7.1.1",
|
|
10
|
-
"@graphql-tools/utils": "
|
|
10
|
+
"@graphql-tools/utils": "11.2.0-alpha-20260623121950-9791cce120fe931141445a7135bb46cf4212582e",
|
|
11
11
|
"auto-bind": "^5.0.0",
|
|
12
12
|
"change-case-all": "^2.1.0",
|
|
13
13
|
"dependency-graph": "^1.0.0",
|
|
14
14
|
"graphql-tag": "^2.11.0",
|
|
15
15
|
"parse-filepath": "^1.0.2",
|
|
16
16
|
"tslib": "^2.8.0",
|
|
17
|
-
"@graphql-codegen/plugin-helpers": "^7.0.
|
|
17
|
+
"@graphql-codegen/plugin-helpers": "^7.0.2-alpha-20260625140734-1ad8f133387ecf5e348a737d91b1a2e22bcfab4f"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|