@graphql-codegen/cli 6.2.1 → 7.0.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/README.md +2 -1
- package/cjs/cli.js +17 -7
- package/cjs/codegen.js +80 -27
- package/cjs/config.js +30 -17
- package/cjs/documentTransforms.js +5 -1
- package/cjs/generate-and-save.js +1 -1
- package/cjs/graphql-config.js +1 -1
- package/cjs/init/helpers.js +8 -4
- package/cjs/init/index.js +1 -1
- package/cjs/init/plugins.js +3 -1
- package/cjs/init/questions.js +10 -3
- package/cjs/init/targets.js +1 -1
- package/cjs/load.js +6 -3
- package/cjs/utils/patterns.js +17 -6
- package/cjs/utils/watcher.js +12 -7
- package/esm/codegen.js +80 -27
- package/esm/config.js +31 -18
- package/esm/documentTransforms.js +5 -1
- package/esm/generate-and-save.js +1 -1
- package/esm/graphql-config.js +1 -1
- package/esm/init/helpers.js +8 -4
- package/esm/init/index.js +1 -1
- package/esm/init/plugins.js +3 -1
- package/esm/init/questions.js +11 -4
- package/esm/init/targets.js +1 -1
- package/esm/load.js +6 -3
- package/esm/utils/file-system.js +1 -1
- package/esm/utils/patterns.js +17 -6
- package/esm/utils/watcher.js +12 -7
- package/package.json +18 -17
- package/typings/config.d.cts +3 -2
- package/typings/config.d.ts +3 -2
- package/typings/init/questions.d.cts +1 -1
- package/typings/init/questions.d.ts +1 -1
- package/typings/init/targets.d.cts +1 -1
- package/typings/init/targets.d.ts +1 -1
- package/typings/load.d.cts +3 -2
- package/typings/load.d.ts +3 -2
- package/cjs/utils/abort-controller-polyfill.js +0 -99
- package/esm/utils/abort-controller-polyfill.js +0 -96
- package/typings/utils/abort-controller-polyfill.d.cts +0 -5
- package/typings/utils/abort-controller-polyfill.d.ts +0 -5
package/typings/config.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Profiler, Types } from '@graphql-codegen/plugin-helpers';
|
|
2
1
|
import { GraphQLSchema } from 'graphql';
|
|
3
2
|
import { GraphQLConfig } from 'graphql-config';
|
|
3
|
+
import { Profiler, Types } from '@graphql-codegen/plugin-helpers';
|
|
4
|
+
import type { UnnormalizedTypeDefPointer } from '@graphql-tools/load';
|
|
4
5
|
export type CodegenConfig = Types.Config;
|
|
5
6
|
export type YamlCliFlags = {
|
|
6
7
|
config: string;
|
|
@@ -147,6 +148,6 @@ export declare class CodegenContext {
|
|
|
147
148
|
[key: string]: any;
|
|
148
149
|
};
|
|
149
150
|
loadSchema(pointer: Types.Schema | Types.Schema[]): Promise<GraphQLSchema>;
|
|
150
|
-
loadDocuments(pointer:
|
|
151
|
+
loadDocuments(pointer: UnnormalizedTypeDefPointer, type: 'standard' | 'external'): Promise<Types.DocumentFile[]>;
|
|
151
152
|
}
|
|
152
153
|
export declare function ensureContext(input: CodegenContext | Types.Config): CodegenContext;
|
package/typings/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Profiler, Types } from '@graphql-codegen/plugin-helpers';
|
|
2
1
|
import { GraphQLSchema } from 'graphql';
|
|
3
2
|
import { GraphQLConfig } from 'graphql-config';
|
|
3
|
+
import { Profiler, Types } from '@graphql-codegen/plugin-helpers';
|
|
4
|
+
import type { UnnormalizedTypeDefPointer } from '@graphql-tools/load';
|
|
4
5
|
export type CodegenConfig = Types.Config;
|
|
5
6
|
export type YamlCliFlags = {
|
|
6
7
|
config: string;
|
|
@@ -147,6 +148,6 @@ export declare class CodegenContext {
|
|
|
147
148
|
[key: string]: any;
|
|
148
149
|
};
|
|
149
150
|
loadSchema(pointer: Types.Schema | Types.Schema[]): Promise<GraphQLSchema>;
|
|
150
|
-
loadDocuments(pointer:
|
|
151
|
+
loadDocuments(pointer: UnnormalizedTypeDefPointer, type: 'standard' | 'external'): Promise<Types.DocumentFile[]>;
|
|
151
152
|
}
|
|
152
153
|
export declare function ensureContext(input: CodegenContext | Types.Config): CodegenContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Answers, type PluginOption
|
|
1
|
+
import { Tags, type Answers, type PluginOption } from './types.cjs';
|
|
2
2
|
export declare function getAnswers(possibleTargets: Record<Tags, boolean>): Promise<Answers>;
|
|
3
3
|
export declare function getApplicationTypeChoices(possibleTargets: Record<Tags, boolean>): {
|
|
4
4
|
name: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Answers, type PluginOption
|
|
1
|
+
import { Tags, type Answers, type PluginOption } from './types.js';
|
|
2
2
|
export declare function getAnswers(possibleTargets: Record<Tags, boolean>): Promise<Answers>;
|
|
3
3
|
export declare function getApplicationTypeChoices(possibleTargets: Record<Tags, boolean>): {
|
|
4
4
|
name: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Tags } from './types.cjs';
|
|
2
|
-
export declare function guessTargets():
|
|
2
|
+
export declare function guessTargets(): Record<Tags, boolean>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Tags } from './types.js';
|
|
2
|
-
export declare function guessTargets():
|
|
2
|
+
export declare function guessTargets(): Record<Tags, boolean>;
|
package/typings/load.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import type { Source } from 'graphql-config';
|
|
1
3
|
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
2
4
|
import { UnnormalizedTypeDefPointer } from '@graphql-tools/load';
|
|
3
|
-
import { GraphQLSchema } from 'graphql';
|
|
4
5
|
export declare const defaultSchemaLoadOptions: {
|
|
5
6
|
assumeValidSDL: boolean;
|
|
6
7
|
sort: boolean;
|
|
@@ -12,4 +13,4 @@ export declare const defaultDocumentsLoadOptions: {
|
|
|
12
13
|
skipGraphQLImport: boolean;
|
|
13
14
|
};
|
|
14
15
|
export declare function loadSchema(schemaPointers: UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[], config: Types.Config): Promise<GraphQLSchema>;
|
|
15
|
-
export declare function loadDocuments(documentPointers: UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[], config: Types.Config): Promise<
|
|
16
|
+
export declare function loadDocuments(documentPointers: UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[], config: Types.Config): Promise<Source[]>;
|
package/typings/load.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import type { Source } from 'graphql-config';
|
|
1
3
|
import { Types } from '@graphql-codegen/plugin-helpers';
|
|
2
4
|
import { UnnormalizedTypeDefPointer } from '@graphql-tools/load';
|
|
3
|
-
import { GraphQLSchema } from 'graphql';
|
|
4
5
|
export declare const defaultSchemaLoadOptions: {
|
|
5
6
|
assumeValidSDL: boolean;
|
|
6
7
|
sort: boolean;
|
|
@@ -12,4 +13,4 @@ export declare const defaultDocumentsLoadOptions: {
|
|
|
12
13
|
skipGraphQLImport: boolean;
|
|
13
14
|
};
|
|
14
15
|
export declare function loadSchema(schemaPointers: UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[], config: Types.Config): Promise<GraphQLSchema>;
|
|
15
|
-
export declare function loadDocuments(documentPointers: UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[], config: Types.Config): Promise<
|
|
16
|
+
export declare function loadDocuments(documentPointers: UnnormalizedTypeDefPointer | UnnormalizedTypeDefPointer[], config: Types.Config): Promise<Source[]>;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbortController = void 0;
|
|
4
|
-
const events_1 = require("events");
|
|
5
|
-
const debugging_js_1 = require("./debugging.js");
|
|
6
|
-
/**
|
|
7
|
-
* Node v14 does not have AbortSignal or AbortController, so to safely use it in
|
|
8
|
-
* another module, you can import it from here.
|
|
9
|
-
*
|
|
10
|
-
* Node v14.7+ does have it, but only with flag --experimental-abortcontroller
|
|
11
|
-
*
|
|
12
|
-
* We don't actually use AbortController anywhere except in tests, but it
|
|
13
|
-
* still gets called in watcher.ts, so by polyfilling it we can avoid breaking
|
|
14
|
-
* existing installations using Node v14 without flag --experimental-abortcontroller,
|
|
15
|
-
* and we also ensure that tests continue to pass under Node v14 without any new flags.
|
|
16
|
-
*
|
|
17
|
-
* This polyfill was adapted (TypeScript-ified) from here:
|
|
18
|
-
* https://github.com/southpolesteve/node-abort-controller/blob/master/index.js
|
|
19
|
-
*/
|
|
20
|
-
class AbortSignalPolyfill {
|
|
21
|
-
eventEmitter;
|
|
22
|
-
onabort;
|
|
23
|
-
aborted;
|
|
24
|
-
reason;
|
|
25
|
-
constructor() {
|
|
26
|
-
this.eventEmitter = new events_1.EventEmitter();
|
|
27
|
-
this.onabort = null;
|
|
28
|
-
this.aborted = false;
|
|
29
|
-
this.reason = undefined;
|
|
30
|
-
}
|
|
31
|
-
toString() {
|
|
32
|
-
return '[object AbortSignal]';
|
|
33
|
-
}
|
|
34
|
-
get [Symbol.toStringTag]() {
|
|
35
|
-
return 'AbortSignal';
|
|
36
|
-
}
|
|
37
|
-
removeEventListener(name, handler) {
|
|
38
|
-
this.eventEmitter.removeListener(name, handler);
|
|
39
|
-
}
|
|
40
|
-
addEventListener(name, handler) {
|
|
41
|
-
this.eventEmitter.on(name, handler);
|
|
42
|
-
}
|
|
43
|
-
// @ts-expect-error No Event type in Node 14
|
|
44
|
-
dispatchEvent(type) {
|
|
45
|
-
const event = { type, target: this };
|
|
46
|
-
const handlerName = `on${event.type}`;
|
|
47
|
-
if (typeof this[handlerName] === 'function')
|
|
48
|
-
this[handlerName](event);
|
|
49
|
-
return this.eventEmitter.emit(event.type, event);
|
|
50
|
-
}
|
|
51
|
-
throwIfAborted() {
|
|
52
|
-
if (this.aborted) {
|
|
53
|
-
throw this.reason;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
static abort(reason) {
|
|
57
|
-
const controller = new AbortController();
|
|
58
|
-
controller.abort(reason);
|
|
59
|
-
return controller.signal;
|
|
60
|
-
}
|
|
61
|
-
static timeout(time) {
|
|
62
|
-
const controller = new AbortController();
|
|
63
|
-
setTimeout(() => controller.abort(new Error('TimeoutError')), time);
|
|
64
|
-
return controller.signal;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const AbortSignal = global.AbortSignal ?? AbortSignalPolyfill;
|
|
68
|
-
class AbortControllerPolyfill {
|
|
69
|
-
signal;
|
|
70
|
-
constructor() {
|
|
71
|
-
(0, debugging_js_1.debugLog)('Using polyfilled AbortController');
|
|
72
|
-
// @ts-expect-error No Event type in Node 14
|
|
73
|
-
this.signal = new AbortSignal();
|
|
74
|
-
}
|
|
75
|
-
abort(reason) {
|
|
76
|
-
if (this.signal.aborted)
|
|
77
|
-
return;
|
|
78
|
-
// @ts-expect-error Not a read only property when polyfilling
|
|
79
|
-
this.signal.aborted = true;
|
|
80
|
-
if (reason) {
|
|
81
|
-
// @ts-expect-error Not a read only property when polyfilling
|
|
82
|
-
this.signal.reason = reason;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
// @ts-expect-error Not a read only property when polyfilling
|
|
86
|
-
this.signal.reason = new Error('AbortError');
|
|
87
|
-
}
|
|
88
|
-
// @ts-expect-error No Event type in Node 14
|
|
89
|
-
this.signal.dispatchEvent('abort');
|
|
90
|
-
}
|
|
91
|
-
toString() {
|
|
92
|
-
return '[object AbortController]';
|
|
93
|
-
}
|
|
94
|
-
get [Symbol.toStringTag]() {
|
|
95
|
-
return 'AbortController';
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const AbortController = global.AbortController ?? AbortControllerPolyfill;
|
|
99
|
-
exports.AbortController = AbortController;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
import { debugLog } from './debugging.js';
|
|
3
|
-
/**
|
|
4
|
-
* Node v14 does not have AbortSignal or AbortController, so to safely use it in
|
|
5
|
-
* another module, you can import it from here.
|
|
6
|
-
*
|
|
7
|
-
* Node v14.7+ does have it, but only with flag --experimental-abortcontroller
|
|
8
|
-
*
|
|
9
|
-
* We don't actually use AbortController anywhere except in tests, but it
|
|
10
|
-
* still gets called in watcher.ts, so by polyfilling it we can avoid breaking
|
|
11
|
-
* existing installations using Node v14 without flag --experimental-abortcontroller,
|
|
12
|
-
* and we also ensure that tests continue to pass under Node v14 without any new flags.
|
|
13
|
-
*
|
|
14
|
-
* This polyfill was adapted (TypeScript-ified) from here:
|
|
15
|
-
* https://github.com/southpolesteve/node-abort-controller/blob/master/index.js
|
|
16
|
-
*/
|
|
17
|
-
class AbortSignalPolyfill {
|
|
18
|
-
eventEmitter;
|
|
19
|
-
onabort;
|
|
20
|
-
aborted;
|
|
21
|
-
reason;
|
|
22
|
-
constructor() {
|
|
23
|
-
this.eventEmitter = new EventEmitter();
|
|
24
|
-
this.onabort = null;
|
|
25
|
-
this.aborted = false;
|
|
26
|
-
this.reason = undefined;
|
|
27
|
-
}
|
|
28
|
-
toString() {
|
|
29
|
-
return '[object AbortSignal]';
|
|
30
|
-
}
|
|
31
|
-
get [Symbol.toStringTag]() {
|
|
32
|
-
return 'AbortSignal';
|
|
33
|
-
}
|
|
34
|
-
removeEventListener(name, handler) {
|
|
35
|
-
this.eventEmitter.removeListener(name, handler);
|
|
36
|
-
}
|
|
37
|
-
addEventListener(name, handler) {
|
|
38
|
-
this.eventEmitter.on(name, handler);
|
|
39
|
-
}
|
|
40
|
-
// @ts-expect-error No Event type in Node 14
|
|
41
|
-
dispatchEvent(type) {
|
|
42
|
-
const event = { type, target: this };
|
|
43
|
-
const handlerName = `on${event.type}`;
|
|
44
|
-
if (typeof this[handlerName] === 'function')
|
|
45
|
-
this[handlerName](event);
|
|
46
|
-
return this.eventEmitter.emit(event.type, event);
|
|
47
|
-
}
|
|
48
|
-
throwIfAborted() {
|
|
49
|
-
if (this.aborted) {
|
|
50
|
-
throw this.reason;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
static abort(reason) {
|
|
54
|
-
const controller = new AbortController();
|
|
55
|
-
controller.abort(reason);
|
|
56
|
-
return controller.signal;
|
|
57
|
-
}
|
|
58
|
-
static timeout(time) {
|
|
59
|
-
const controller = new AbortController();
|
|
60
|
-
setTimeout(() => controller.abort(new Error('TimeoutError')), time);
|
|
61
|
-
return controller.signal;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const AbortSignal = global.AbortSignal ?? AbortSignalPolyfill;
|
|
65
|
-
class AbortControllerPolyfill {
|
|
66
|
-
signal;
|
|
67
|
-
constructor() {
|
|
68
|
-
debugLog('Using polyfilled AbortController');
|
|
69
|
-
// @ts-expect-error No Event type in Node 14
|
|
70
|
-
this.signal = new AbortSignal();
|
|
71
|
-
}
|
|
72
|
-
abort(reason) {
|
|
73
|
-
if (this.signal.aborted)
|
|
74
|
-
return;
|
|
75
|
-
// @ts-expect-error Not a read only property when polyfilling
|
|
76
|
-
this.signal.aborted = true;
|
|
77
|
-
if (reason) {
|
|
78
|
-
// @ts-expect-error Not a read only property when polyfilling
|
|
79
|
-
this.signal.reason = reason;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
// @ts-expect-error Not a read only property when polyfilling
|
|
83
|
-
this.signal.reason = new Error('AbortError');
|
|
84
|
-
}
|
|
85
|
-
// @ts-expect-error No Event type in Node 14
|
|
86
|
-
this.signal.dispatchEvent('abort');
|
|
87
|
-
}
|
|
88
|
-
toString() {
|
|
89
|
-
return '[object AbortController]';
|
|
90
|
-
}
|
|
91
|
-
get [Symbol.toStringTag]() {
|
|
92
|
-
return 'AbortController';
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const AbortController = global.AbortController ?? AbortControllerPolyfill;
|
|
96
|
-
export { AbortController };
|