@graphql-codegen/plugin-helpers 2.3.1 → 2.4.0-alpha-23d229715.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/helpers.d.ts +1 -1
- package/index.d.ts +1 -0
- package/index.js +50 -2
- package/index.mjs +47 -1
- package/package.json +3 -2
- package/profiler.d.ts +28 -0
- package/types.d.ts +4 -1
package/helpers.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Types } from './types';
|
|
|
2
2
|
import { DocumentNode, GraphQLSchema, GraphQLOutputType } from 'graphql';
|
|
3
3
|
export declare function isOutputConfigArray(type: any): type is Types.OutputConfig[];
|
|
4
4
|
export declare function isConfiguredOutput(type: any): type is Types.ConfiguredOutput;
|
|
5
|
-
export declare function normalizeOutputParam(config: Types.OutputConfig | Types.ConfiguredOutput): Types.ConfiguredOutput;
|
|
5
|
+
export declare function normalizeOutputParam(config: Types.OutputConfig | Types.ConfiguredPlugin[] | Types.ConfiguredOutput): Types.ConfiguredOutput;
|
|
6
6
|
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;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
7
|
const module$1 = require('module');
|
|
8
|
-
const process = require('process');
|
|
8
|
+
const process$1 = require('process');
|
|
9
9
|
const changeCaseAll = require('change-case-all');
|
|
10
10
|
const graphql = require('graphql');
|
|
11
11
|
const merge = _interopDefault(require('lodash/merge.js'));
|
|
@@ -28,7 +28,7 @@ function resolveExternalModuleAndFn(pointer) {
|
|
|
28
28
|
else {
|
|
29
29
|
// we have to use a path to a filename here (it does not need to exist.)
|
|
30
30
|
// https://github.com/dotansimha/graphql-code-generator/issues/6553
|
|
31
|
-
const cwdRequire = module$1.createRequire(process.cwd() + '/index.js');
|
|
31
|
+
const cwdRequire = module$1.createRequire(process$1.cwd() + '/index.js');
|
|
32
32
|
loadedModule = cwdRequire(moduleName);
|
|
33
33
|
if (!(functionName in loadedModule) && typeof loadedModule !== 'function') {
|
|
34
34
|
throw new Error(`${functionName} couldn't be found in module ${moduleName}!`);
|
|
@@ -517,9 +517,57 @@ function oldVisit(root, { enter: enterVisitors, leave: leaveVisitors, ...newVisi
|
|
|
517
517
|
return graphql.visit(root, newVisitor);
|
|
518
518
|
}
|
|
519
519
|
|
|
520
|
+
function createNoopProfiler() {
|
|
521
|
+
return {
|
|
522
|
+
run(fn) {
|
|
523
|
+
return Promise.resolve().then(() => fn());
|
|
524
|
+
},
|
|
525
|
+
collect() {
|
|
526
|
+
return [];
|
|
527
|
+
},
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
function createProfiler() {
|
|
531
|
+
const events = [];
|
|
532
|
+
return {
|
|
533
|
+
collect() {
|
|
534
|
+
return events;
|
|
535
|
+
},
|
|
536
|
+
run(fn, name, cat) {
|
|
537
|
+
let startTime;
|
|
538
|
+
return Promise.resolve()
|
|
539
|
+
.then(() => {
|
|
540
|
+
startTime = process.hrtime();
|
|
541
|
+
})
|
|
542
|
+
.then(() => fn())
|
|
543
|
+
.then(value => {
|
|
544
|
+
const duration = process.hrtime(startTime);
|
|
545
|
+
// Trace Event Format documentation:
|
|
546
|
+
// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
|
|
547
|
+
const event = {
|
|
548
|
+
name,
|
|
549
|
+
cat,
|
|
550
|
+
ph: 'X',
|
|
551
|
+
ts: hrtimeToMicroseconds(startTime),
|
|
552
|
+
pid: 1,
|
|
553
|
+
tid: 0,
|
|
554
|
+
dur: hrtimeToMicroseconds(duration),
|
|
555
|
+
};
|
|
556
|
+
events.push(event);
|
|
557
|
+
return value;
|
|
558
|
+
});
|
|
559
|
+
},
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
function hrtimeToMicroseconds(hrtime) {
|
|
563
|
+
return (hrtime[0] * 1e9 + hrtime[1]) / 1000;
|
|
564
|
+
}
|
|
565
|
+
|
|
520
566
|
exports.ApolloFederation = ApolloFederation;
|
|
521
567
|
exports.DetailedError = DetailedError;
|
|
522
568
|
exports.addFederationReferencesToSchema = addFederationReferencesToSchema;
|
|
569
|
+
exports.createNoopProfiler = createNoopProfiler;
|
|
570
|
+
exports.createProfiler = createProfiler;
|
|
523
571
|
exports.federationSpec = federationSpec;
|
|
524
572
|
exports.getBaseType = getBaseType;
|
|
525
573
|
exports.getCachedDocumentNodeFromSchema = getCachedDocumentNodeFromSchema;
|
package/index.mjs
CHANGED
|
@@ -511,4 +511,50 @@ function oldVisit(root, { enter: enterVisitors, leave: leaveVisitors, ...newVisi
|
|
|
511
511
|
return visit(root, newVisitor);
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
-
|
|
514
|
+
function createNoopProfiler() {
|
|
515
|
+
return {
|
|
516
|
+
run(fn) {
|
|
517
|
+
return Promise.resolve().then(() => fn());
|
|
518
|
+
},
|
|
519
|
+
collect() {
|
|
520
|
+
return [];
|
|
521
|
+
},
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
function createProfiler() {
|
|
525
|
+
const events = [];
|
|
526
|
+
return {
|
|
527
|
+
collect() {
|
|
528
|
+
return events;
|
|
529
|
+
},
|
|
530
|
+
run(fn, name, cat) {
|
|
531
|
+
let startTime;
|
|
532
|
+
return Promise.resolve()
|
|
533
|
+
.then(() => {
|
|
534
|
+
startTime = process.hrtime();
|
|
535
|
+
})
|
|
536
|
+
.then(() => fn())
|
|
537
|
+
.then(value => {
|
|
538
|
+
const duration = process.hrtime(startTime);
|
|
539
|
+
// Trace Event Format documentation:
|
|
540
|
+
// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
|
|
541
|
+
const event = {
|
|
542
|
+
name,
|
|
543
|
+
cat,
|
|
544
|
+
ph: 'X',
|
|
545
|
+
ts: hrtimeToMicroseconds(startTime),
|
|
546
|
+
pid: 1,
|
|
547
|
+
tid: 0,
|
|
548
|
+
dur: hrtimeToMicroseconds(duration),
|
|
549
|
+
};
|
|
550
|
+
events.push(event);
|
|
551
|
+
return value;
|
|
552
|
+
});
|
|
553
|
+
},
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
function hrtimeToMicroseconds(hrtime) {
|
|
557
|
+
return (hrtime[0] * 1e9 + hrtime[1]) / 1000;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export { ApolloFederation, DetailedError, addFederationReferencesToSchema, createNoopProfiler, createProfiler, federationSpec, getBaseType, getCachedDocumentNodeFromSchema, hasNullableTypeRecursively, isComplexPluginOutput, isConfiguredOutput, isDetailedError, isOutputConfigArray, isUsingTypes, isWrapperType, mergeOutputs, normalizeConfig, normalizeInstanceOrArray, normalizeOutputParam, oldVisit, removeFederation, removeNonNullWrapper, resolveExternalModuleAndFn };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/plugin-helpers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-alpha-23d229715.0",
|
|
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"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@graphql-tools/utils": "^8.5.2",
|
|
10
10
|
"change-case-all": "1.0.14",
|
|
11
|
-
"common-tags": "1.8.
|
|
11
|
+
"common-tags": "1.8.2",
|
|
12
12
|
"import-from": "4.0.0",
|
|
13
13
|
"lodash": "~4.17.0",
|
|
14
14
|
"tslib": "~2.3.0"
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"definition": "index.d.ts"
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
29
|
+
"./package.json": "./package.json",
|
|
29
30
|
".": {
|
|
30
31
|
"require": "./index.js",
|
|
31
32
|
"import": "./index.mjs"
|
package/profiler.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface ProfilerEvent {
|
|
2
|
+
/** The name of the event, as displayed in Trace Viewer */
|
|
3
|
+
name: string;
|
|
4
|
+
/** The event categories. This is a comma separated list of categories for the event. The categories can be used to hide events in the Trace Viewer UI. */
|
|
5
|
+
cat: string;
|
|
6
|
+
/** The event type. This is a single character which changes depending on the type of event being output. The valid values are listed in the table below. We will discuss each phase type below. */
|
|
7
|
+
ph: string;
|
|
8
|
+
/** The tracing clock timestamp of the event. The timestamps are provided at microsecond granularity. */
|
|
9
|
+
ts: number;
|
|
10
|
+
/** Optional. The thread clock timestamp of the event. The timestamps are provided at microsecond granularity. */
|
|
11
|
+
tts?: string;
|
|
12
|
+
/** The process ID for the process that output this event. */
|
|
13
|
+
pid: number;
|
|
14
|
+
/** The thread ID for the thread that output this event. */
|
|
15
|
+
tid: number;
|
|
16
|
+
/** Any arguments provided for the event. Some of the event types have required argument fields, otherwise, you can put any information you wish in here. The arguments are displayed in Trace Viewer when you view an event in the analysis section. */
|
|
17
|
+
args?: any;
|
|
18
|
+
/** duration */
|
|
19
|
+
dur: number;
|
|
20
|
+
/** A fixed color name to associate with the event. If provided, cname must be one of the names listed in trace-viewer's base color scheme's reserved color names list */
|
|
21
|
+
cname?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Profiler {
|
|
24
|
+
run<T>(fn: () => Promise<T>, name: string, cat?: string): Promise<T>;
|
|
25
|
+
collect(): ProfilerEvent[];
|
|
26
|
+
}
|
|
27
|
+
export declare function createNoopProfiler(): Profiler;
|
|
28
|
+
export declare function createProfiler(): Profiler;
|
package/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GraphQLSchema, DocumentNode } from 'graphql';
|
|
2
2
|
import { Source } from '@graphql-tools/utils';
|
|
3
|
+
import type { Profiler } from './profiler';
|
|
3
4
|
export declare namespace Types {
|
|
4
5
|
interface GenerateOptions {
|
|
5
6
|
filename: string;
|
|
@@ -17,6 +18,7 @@ export declare namespace Types {
|
|
|
17
18
|
pluginContext?: {
|
|
18
19
|
[key: string]: any;
|
|
19
20
|
};
|
|
21
|
+
profiler?: Profiler;
|
|
20
22
|
}
|
|
21
23
|
type FileOutput = {
|
|
22
24
|
filename: string;
|
|
@@ -293,6 +295,7 @@ export declare namespace Types {
|
|
|
293
295
|
pluginContext?: {
|
|
294
296
|
[name: string]: any;
|
|
295
297
|
};
|
|
298
|
+
profiler?: Profiler;
|
|
296
299
|
};
|
|
297
300
|
type OutputPreset<TPresetConfig = any> = {
|
|
298
301
|
buildGeneratesSection: (options: PresetFnArgs<TPresetConfig>) => Promisable<GenerateOptions[]>;
|
|
@@ -367,7 +370,7 @@ export declare namespace Types {
|
|
|
367
370
|
* For more details: https://graphql-code-generator.com/docs/getting-started/codegen-config
|
|
368
371
|
*/
|
|
369
372
|
generates: {
|
|
370
|
-
[outputPath: string]: ConfiguredOutput;
|
|
373
|
+
[outputPath: string]: ConfiguredOutput | ConfiguredPlugin[];
|
|
371
374
|
};
|
|
372
375
|
/**
|
|
373
376
|
* @description A flag to overwrite files if they already exist when generating code (`true` by default).
|