@graphql-codegen/plugin-helpers 6.0.0 → 6.1.0-alpha-20251119131248-4aa0bce27decc294509fae591f5c2236858abdbb
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/helpers.js +10 -0
- package/esm/helpers.js +9 -0
- package/package.json +1 -1
- package/typings/helpers.d.cts +4 -0
- package/typings/helpers.d.ts +4 -0
- package/typings/types.d.cts +8 -0
- package/typings/types.d.ts +8 -0
package/cjs/helpers.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.normalizeInstanceOrArray = normalizeInstanceOrArray;
|
|
|
7
7
|
exports.normalizeConfig = normalizeConfig;
|
|
8
8
|
exports.hasNullableTypeRecursively = hasNullableTypeRecursively;
|
|
9
9
|
exports.isUsingTypes = isUsingTypes;
|
|
10
|
+
exports.normalizeImportExtension = normalizeImportExtension;
|
|
10
11
|
const graphql_1 = require("graphql");
|
|
11
12
|
const utils_js_1 = require("./utils.js");
|
|
12
13
|
function isOutputConfigArray(type) {
|
|
@@ -166,3 +167,12 @@ function isUsingTypes(document, externalFragments, schema) {
|
|
|
166
167
|
});
|
|
167
168
|
return foundFields > 0;
|
|
168
169
|
}
|
|
170
|
+
function normalizeImportExtension({ emitLegacyCommonJSImports, importExtension, }) {
|
|
171
|
+
if (importExtension !== undefined) {
|
|
172
|
+
return importExtension;
|
|
173
|
+
}
|
|
174
|
+
if (emitLegacyCommonJSImports === undefined || emitLegacyCommonJSImports === true) {
|
|
175
|
+
return '';
|
|
176
|
+
}
|
|
177
|
+
return '.js';
|
|
178
|
+
}
|
package/esm/helpers.js
CHANGED
|
@@ -157,3 +157,12 @@ export function isUsingTypes(document, externalFragments, schema) {
|
|
|
157
157
|
});
|
|
158
158
|
return foundFields > 0;
|
|
159
159
|
}
|
|
160
|
+
export function normalizeImportExtension({ emitLegacyCommonJSImports, importExtension, }) {
|
|
161
|
+
if (importExtension !== undefined) {
|
|
162
|
+
return importExtension;
|
|
163
|
+
}
|
|
164
|
+
if (emitLegacyCommonJSImports === undefined || emitLegacyCommonJSImports === true) {
|
|
165
|
+
return '';
|
|
166
|
+
}
|
|
167
|
+
return '.js';
|
|
168
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/plugin-helpers",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0-alpha-20251119131248-4aa0bce27decc294509fae591f5c2236858abdbb",
|
|
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 || ^16.0.0"
|
package/typings/helpers.d.cts
CHANGED
|
@@ -7,3 +7,7 @@ export declare function normalizeInstanceOrArray<T>(type: T | T[]): T[];
|
|
|
7
7
|
export declare function normalizeConfig(config: Types.OutputConfig | Types.OutputConfig[]): Types.ConfiguredPlugin[];
|
|
8
8
|
export declare function hasNullableTypeRecursively(type: GraphQLOutputType): boolean;
|
|
9
9
|
export declare function isUsingTypes(document: DocumentNode, externalFragments: string[], schema?: GraphQLSchema): boolean;
|
|
10
|
+
export declare function normalizeImportExtension({ emitLegacyCommonJSImports, importExtension, }: {
|
|
11
|
+
emitLegacyCommonJSImports: boolean | undefined;
|
|
12
|
+
importExtension: '' | `.${string}` | undefined;
|
|
13
|
+
}): '' | `.${string}`;
|
package/typings/helpers.d.ts
CHANGED
|
@@ -7,3 +7,7 @@ export declare function normalizeInstanceOrArray<T>(type: T | T[]): T[];
|
|
|
7
7
|
export declare function normalizeConfig(config: Types.OutputConfig | Types.OutputConfig[]): Types.ConfiguredPlugin[];
|
|
8
8
|
export declare function hasNullableTypeRecursively(type: GraphQLOutputType): boolean;
|
|
9
9
|
export declare function isUsingTypes(document: DocumentNode, externalFragments: string[], schema?: GraphQLSchema): boolean;
|
|
10
|
+
export declare function normalizeImportExtension({ emitLegacyCommonJSImports, importExtension, }: {
|
|
11
|
+
emitLegacyCommonJSImports: boolean | undefined;
|
|
12
|
+
importExtension: '' | `.${string}` | undefined;
|
|
13
|
+
}): '' | `.${string}`;
|
package/typings/types.d.cts
CHANGED
|
@@ -22,6 +22,8 @@ export declare namespace Types {
|
|
|
22
22
|
profiler?: Profiler;
|
|
23
23
|
cache?<T>(namespace: string, key: string, factory: () => Promise<T>): Promise<T>;
|
|
24
24
|
documentTransforms?: ConfiguredDocumentTransform[];
|
|
25
|
+
emitLegacyCommonJSImports?: boolean;
|
|
26
|
+
importExtension?: '' | `.${string}`;
|
|
25
27
|
}
|
|
26
28
|
type FileOutput = {
|
|
27
29
|
filename: string;
|
|
@@ -425,9 +427,15 @@ export declare namespace Types {
|
|
|
425
427
|
*/
|
|
426
428
|
ignoreNoDocuments?: boolean;
|
|
427
429
|
/**
|
|
430
|
+
* @deprecated Please use `importExtension` instead.
|
|
428
431
|
* @description A flag to disable adding `.js` extension to the output file. Default: `true`.
|
|
429
432
|
*/
|
|
430
433
|
emitLegacyCommonJSImports?: boolean;
|
|
434
|
+
/**
|
|
435
|
+
* @description Append this extension to all imports.
|
|
436
|
+
* Useful for ESM environments that require file extensions in import statements.
|
|
437
|
+
*/
|
|
438
|
+
importExtension?: '' | `.${string}`;
|
|
431
439
|
/**
|
|
432
440
|
* @description A flag to suppress printing errors when they occur.
|
|
433
441
|
*/
|
package/typings/types.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export declare namespace Types {
|
|
|
22
22
|
profiler?: Profiler;
|
|
23
23
|
cache?<T>(namespace: string, key: string, factory: () => Promise<T>): Promise<T>;
|
|
24
24
|
documentTransforms?: ConfiguredDocumentTransform[];
|
|
25
|
+
emitLegacyCommonJSImports?: boolean;
|
|
26
|
+
importExtension?: '' | `.${string}`;
|
|
25
27
|
}
|
|
26
28
|
type FileOutput = {
|
|
27
29
|
filename: string;
|
|
@@ -425,9 +427,15 @@ export declare namespace Types {
|
|
|
425
427
|
*/
|
|
426
428
|
ignoreNoDocuments?: boolean;
|
|
427
429
|
/**
|
|
430
|
+
* @deprecated Please use `importExtension` instead.
|
|
428
431
|
* @description A flag to disable adding `.js` extension to the output file. Default: `true`.
|
|
429
432
|
*/
|
|
430
433
|
emitLegacyCommonJSImports?: boolean;
|
|
434
|
+
/**
|
|
435
|
+
* @description Append this extension to all imports.
|
|
436
|
+
* Useful for ESM environments that require file extensions in import statements.
|
|
437
|
+
*/
|
|
438
|
+
importExtension?: '' | `.${string}`;
|
|
431
439
|
/**
|
|
432
440
|
* @description A flag to suppress printing errors when they occur.
|
|
433
441
|
*/
|