@graphql-codegen/gql-tag-operations 1.5.7 → 1.5.8
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/index.js +16 -1
- package/esm/index.js +16 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -28,7 +28,16 @@ const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmentedModuleN
|
|
|
28
28
|
}
|
|
29
29
|
code.push([
|
|
30
30
|
`\n`,
|
|
31
|
+
`/**\n * The ${gqlTagName} function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n *\n`,
|
|
32
|
+
` *\n * @example\n`,
|
|
33
|
+
' * ```ts\n',
|
|
34
|
+
' * const query = gql(`query GetUser($id: ID!) { user(id: $id) { name } }`);\n',
|
|
35
|
+
' * ```\n *\n',
|
|
36
|
+
` * The query argument is unknown!\n`,
|
|
37
|
+
` * Please regenerate the types.\n`,
|
|
38
|
+
`**/\n`,
|
|
31
39
|
`export function ${gqlTagName}(source: string): unknown;\n`,
|
|
40
|
+
`\n`,
|
|
32
41
|
`export function ${gqlTagName}(source: string) {\n`,
|
|
33
42
|
` return (documents as any)[source] ?? {};\n`,
|
|
34
43
|
`}\n`,
|
|
@@ -57,6 +66,11 @@ const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmentedModuleN
|
|
|
57
66
|
exports.plugin = plugin;
|
|
58
67
|
function getDocumentRegistryChunk(sourcesWithOperations = []) {
|
|
59
68
|
const lines = new Set();
|
|
69
|
+
lines.add(`/**\n * Map of all GraphQL operations in the project.\n *\n * This map has several performance disadvantages:\n`);
|
|
70
|
+
lines.add(` * 1. It is not tree-shakeable, so it will include all operations in the project.\n`);
|
|
71
|
+
lines.add(` * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.\n`);
|
|
72
|
+
lines.add(` * 3. It does not support dead code elimination, so it will add unused operations.\n *\n`);
|
|
73
|
+
lines.add(` * Therefore it is highly recommended to use the babel-plugin for production.\n */\n`);
|
|
60
74
|
lines.add(`const documents = {\n`);
|
|
61
75
|
for (const { operations, ...rest } of sourcesWithOperations) {
|
|
62
76
|
const originalString = rest.source.rawSDL;
|
|
@@ -77,7 +91,8 @@ function getGqlOverloadChunk(sourcesWithOperations, gqlTagName, mode, emitLegacy
|
|
|
77
91
|
: emitLegacyCommonJSImports
|
|
78
92
|
? `typeof import('./graphql').${operations[0].initialName}`
|
|
79
93
|
: `typeof import('./graphql.js').${operations[0].initialName}`;
|
|
80
|
-
lines.add(
|
|
94
|
+
lines.add(`/**\n * The ${gqlTagName} function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n */\n` +
|
|
95
|
+
`export function ${gqlTagName}(source: ${JSON.stringify(originalString)}): ${returnType};\n`);
|
|
81
96
|
}
|
|
82
97
|
return lines;
|
|
83
98
|
}
|
package/esm/index.js
CHANGED
|
@@ -25,7 +25,16 @@ export const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmented
|
|
|
25
25
|
}
|
|
26
26
|
code.push([
|
|
27
27
|
`\n`,
|
|
28
|
+
`/**\n * The ${gqlTagName} function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n *\n`,
|
|
29
|
+
` *\n * @example\n`,
|
|
30
|
+
' * ```ts\n',
|
|
31
|
+
' * const query = gql(`query GetUser($id: ID!) { user(id: $id) { name } }`);\n',
|
|
32
|
+
' * ```\n *\n',
|
|
33
|
+
` * The query argument is unknown!\n`,
|
|
34
|
+
` * Please regenerate the types.\n`,
|
|
35
|
+
`**/\n`,
|
|
28
36
|
`export function ${gqlTagName}(source: string): unknown;\n`,
|
|
37
|
+
`\n`,
|
|
29
38
|
`export function ${gqlTagName}(source: string) {\n`,
|
|
30
39
|
` return (documents as any)[source] ?? {};\n`,
|
|
31
40
|
`}\n`,
|
|
@@ -53,6 +62,11 @@ export const plugin = (_, __, { sourcesWithOperations, useTypeImports, augmented
|
|
|
53
62
|
};
|
|
54
63
|
function getDocumentRegistryChunk(sourcesWithOperations = []) {
|
|
55
64
|
const lines = new Set();
|
|
65
|
+
lines.add(`/**\n * Map of all GraphQL operations in the project.\n *\n * This map has several performance disadvantages:\n`);
|
|
66
|
+
lines.add(` * 1. It is not tree-shakeable, so it will include all operations in the project.\n`);
|
|
67
|
+
lines.add(` * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.\n`);
|
|
68
|
+
lines.add(` * 3. It does not support dead code elimination, so it will add unused operations.\n *\n`);
|
|
69
|
+
lines.add(` * Therefore it is highly recommended to use the babel-plugin for production.\n */\n`);
|
|
56
70
|
lines.add(`const documents = {\n`);
|
|
57
71
|
for (const { operations, ...rest } of sourcesWithOperations) {
|
|
58
72
|
const originalString = rest.source.rawSDL;
|
|
@@ -73,7 +87,8 @@ function getGqlOverloadChunk(sourcesWithOperations, gqlTagName, mode, emitLegacy
|
|
|
73
87
|
: emitLegacyCommonJSImports
|
|
74
88
|
? `typeof import('./graphql').${operations[0].initialName}`
|
|
75
89
|
: `typeof import('./graphql.js').${operations[0].initialName}`;
|
|
76
|
-
lines.add(
|
|
90
|
+
lines.add(`/**\n * The ${gqlTagName} function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n */\n` +
|
|
91
|
+
`export function ${gqlTagName}(source: ${JSON.stringify(originalString)}): ${returnType};\n`);
|
|
77
92
|
}
|
|
78
93
|
return lines;
|
|
79
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/gql-tag-operations",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating a typed gql tag function",
|
|
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 || ^16.0.0"
|