@graphql-codegen/visitor-plugin-common 6.1.1 → 6.1.2-alpha-20251113150958-a61a57fa90f09d12823695db865da6ea9b5afe59
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.
|
@@ -146,7 +146,7 @@ class ClientSideBaseVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
146
146
|
];
|
|
147
147
|
}
|
|
148
148
|
let metaString = '';
|
|
149
|
-
if (this._onExecutableDocumentNode
|
|
149
|
+
if (this._onExecutableDocumentNode) {
|
|
150
150
|
const meta = this._getGraphQLCodegenMetadata(node, definitions);
|
|
151
151
|
if (meta) {
|
|
152
152
|
if (this._omitDefinitions === true) {
|
|
@@ -159,7 +159,8 @@ class ClientSideBaseVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
159
159
|
}
|
|
160
160
|
if (this.config.documentMode === DocumentMode.string) {
|
|
161
161
|
if (node.kind === graphql_1.Kind.FRAGMENT_DEFINITION) {
|
|
162
|
-
|
|
162
|
+
const meta = this._getGraphQLCodegenMetadata(node, (0, graphql_tag_1.default)([doc]).definitions);
|
|
163
|
+
return `new TypedDocumentString(\`${doc}\`, ${JSON.stringify({ fragmentName: node.name.value, ...meta })})`;
|
|
163
164
|
}
|
|
164
165
|
if (this._onExecutableDocumentNode && node.kind === graphql_1.Kind.OPERATION_DEFINITION) {
|
|
165
166
|
const meta = this._getGraphQLCodegenMetadata(node, (0, graphql_tag_1.default)([doc]).definitions);
|
|
@@ -177,10 +178,12 @@ class ClientSideBaseVisitor extends base_visitor_js_1.BaseVisitor {
|
|
|
177
178
|
}
|
|
178
179
|
_getGraphQLCodegenMetadata(node, definitions) {
|
|
179
180
|
let meta;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
if (node.kind === graphql_1.Kind.OPERATION_DEFINITION) {
|
|
182
|
+
meta = this._onExecutableDocumentNode({
|
|
183
|
+
kind: graphql_1.Kind.DOCUMENT,
|
|
184
|
+
definitions,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
184
187
|
const deferredFields = this._findDeferredFields(node);
|
|
185
188
|
if (Object.keys(deferredFields).length) {
|
|
186
189
|
meta = {
|
|
@@ -142,7 +142,7 @@ export class ClientSideBaseVisitor extends BaseVisitor {
|
|
|
142
142
|
];
|
|
143
143
|
}
|
|
144
144
|
let metaString = '';
|
|
145
|
-
if (this._onExecutableDocumentNode
|
|
145
|
+
if (this._onExecutableDocumentNode) {
|
|
146
146
|
const meta = this._getGraphQLCodegenMetadata(node, definitions);
|
|
147
147
|
if (meta) {
|
|
148
148
|
if (this._omitDefinitions === true) {
|
|
@@ -155,7 +155,8 @@ export class ClientSideBaseVisitor extends BaseVisitor {
|
|
|
155
155
|
}
|
|
156
156
|
if (this.config.documentMode === DocumentMode.string) {
|
|
157
157
|
if (node.kind === Kind.FRAGMENT_DEFINITION) {
|
|
158
|
-
|
|
158
|
+
const meta = this._getGraphQLCodegenMetadata(node, gqlTag([doc]).definitions);
|
|
159
|
+
return `new TypedDocumentString(\`${doc}\`, ${JSON.stringify({ fragmentName: node.name.value, ...meta })})`;
|
|
159
160
|
}
|
|
160
161
|
if (this._onExecutableDocumentNode && node.kind === Kind.OPERATION_DEFINITION) {
|
|
161
162
|
const meta = this._getGraphQLCodegenMetadata(node, gqlTag([doc]).definitions);
|
|
@@ -173,10 +174,12 @@ export class ClientSideBaseVisitor extends BaseVisitor {
|
|
|
173
174
|
}
|
|
174
175
|
_getGraphQLCodegenMetadata(node, definitions) {
|
|
175
176
|
let meta;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
if (node.kind === Kind.OPERATION_DEFINITION) {
|
|
178
|
+
meta = this._onExecutableDocumentNode({
|
|
179
|
+
kind: Kind.DOCUMENT,
|
|
180
|
+
definitions,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
180
183
|
const deferredFields = this._findDeferredFields(node);
|
|
181
184
|
if (Object.keys(deferredFields).length) {
|
|
182
185
|
meta = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/visitor-plugin-common",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.2-alpha-20251113150958-a61a57fa90f09d12823695db865da6ea9b5afe59",
|
|
4
4
|
"peerDependencies": {
|
|
5
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"
|
|
6
6
|
},
|
|
@@ -222,8 +222,8 @@ export declare class ClientSideBaseVisitor<TRawConfig extends RawClientSideBaseP
|
|
|
222
222
|
protected _includeFragments(fragments: string[]): string;
|
|
223
223
|
protected _prepareDocument(documentStr: string): string;
|
|
224
224
|
protected _gql(node: FragmentDefinitionNode | OperationDefinitionNode): string;
|
|
225
|
-
protected _getGraphQLCodegenMetadata(node: OperationDefinitionNode, definitions?: ReadonlyArray<DefinitionNode>): Record<string, any> | void | undefined;
|
|
226
|
-
protected _findDeferredFields(node: OperationDefinitionNode): {
|
|
225
|
+
protected _getGraphQLCodegenMetadata(node: OperationDefinitionNode | FragmentDefinitionNode, definitions?: ReadonlyArray<DefinitionNode>): Record<string, any> | void | undefined;
|
|
226
|
+
protected _findDeferredFields(node: OperationDefinitionNode | FragmentDefinitionNode): {
|
|
227
227
|
[fargmentName: string]: string[];
|
|
228
228
|
};
|
|
229
229
|
protected _generateFragment(fragmentDocument: FragmentDefinitionNode): string | void;
|
|
@@ -222,8 +222,8 @@ export declare class ClientSideBaseVisitor<TRawConfig extends RawClientSideBaseP
|
|
|
222
222
|
protected _includeFragments(fragments: string[]): string;
|
|
223
223
|
protected _prepareDocument(documentStr: string): string;
|
|
224
224
|
protected _gql(node: FragmentDefinitionNode | OperationDefinitionNode): string;
|
|
225
|
-
protected _getGraphQLCodegenMetadata(node: OperationDefinitionNode, definitions?: ReadonlyArray<DefinitionNode>): Record<string, any> | void | undefined;
|
|
226
|
-
protected _findDeferredFields(node: OperationDefinitionNode): {
|
|
225
|
+
protected _getGraphQLCodegenMetadata(node: OperationDefinitionNode | FragmentDefinitionNode, definitions?: ReadonlyArray<DefinitionNode>): Record<string, any> | void | undefined;
|
|
226
|
+
protected _findDeferredFields(node: OperationDefinitionNode | FragmentDefinitionNode): {
|
|
227
227
|
[fargmentName: string]: string[];
|
|
228
228
|
};
|
|
229
229
|
protected _generateFragment(fragmentDocument: FragmentDefinitionNode): string | void;
|