@envelop/core 2.5.0 → 2.5.1-alpha-20220824152235-afd061e6
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/create.js +7 -5
- package/cjs/index.js +3 -3
- package/cjs/orchestrator.js +24 -16
- package/cjs/utils.js +1 -27
- package/esm/create.js +7 -5
- package/esm/index.js +1 -3
- package/esm/orchestrator.js +13 -5
- package/esm/utils.js +0 -23
- package/package.json +2 -5
- package/typings/create.d.cts +5 -1
- package/typings/create.d.ts +5 -1
- package/typings/index.d.cts +1 -3
- package/typings/index.d.ts +1 -3
- package/typings/orchestrator.d.cts +12 -4
- package/typings/orchestrator.d.ts +12 -4
- package/typings/plugins/use-error-handler.d.cts +1 -2
- package/typings/plugins/use-error-handler.d.ts +1 -2
- package/typings/plugins/use-payload-formatter.d.cts +1 -2
- package/typings/plugins/use-payload-formatter.d.ts +1 -2
- package/typings/plugins/use-schema.d.cts +3 -4
- package/typings/plugins/use-schema.d.ts +3 -4
- package/typings/utils.d.cts +4 -8
- package/typings/utils.d.ts +4 -8
- package/cjs/plugins/use-immediate-introspection.js +0 -50
- package/cjs/plugins/use-masked-errors.js +0 -93
- package/cjs/plugins/use-timing.js +0 -138
- package/cjs/traced-orchestrator.js +0 -136
- package/cjs/traced-schema.js +0 -68
- package/esm/plugins/use-immediate-introspection.js +0 -46
- package/esm/plugins/use-masked-errors.js +0 -87
- package/esm/plugins/use-timing.js +0 -134
- package/esm/traced-orchestrator.js +0 -132
- package/esm/traced-schema.js +0 -64
- package/typings/plugins/use-immediate-introspection.d.cts +0 -6
- package/typings/plugins/use-immediate-introspection.d.ts +0 -6
- package/typings/plugins/use-masked-errors.d.cts +0 -39
- package/typings/plugins/use-masked-errors.d.ts +0 -39
- package/typings/plugins/use-timing.d.cts +0 -21
- package/typings/plugins/use-timing.d.ts +0 -21
- package/typings/traced-orchestrator.d.cts +0 -7
- package/typings/traced-orchestrator.d.ts +0 -7
- package/typings/traced-schema.d.cts +0 -4
- package/typings/traced-schema.d.ts +0 -4
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { getOperationAST } from 'graphql';
|
|
2
|
-
import { isIntrospectionOperationString, envelopIsIntrospectionSymbol } from '../utils.js';
|
|
3
|
-
const HR_TO_NS = 1e9;
|
|
4
|
-
const NS_TO_MS = 1e6;
|
|
5
|
-
const DEFAULT_OPTIONS = {
|
|
6
|
-
onExecutionMeasurement: (args, timing) => console.log(`Operation execution "${args.operationName}" done in ${timing.ms}ms`),
|
|
7
|
-
onSubscriptionMeasurement: (args, timing) => console.log(`Operation subscription "${args.operationName}" done in ${timing.ms}ms`),
|
|
8
|
-
onParsingMeasurement: (source, timing) => console.log(`Parsing "${source}" done in ${timing.ms}ms`),
|
|
9
|
-
onValidationMeasurement: (document, timing) => { var _a, _b; return console.log(`Validation "${((_b = (_a = getOperationAST(document)) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.value) || '-'}" done in ${timing.ms}ms`); },
|
|
10
|
-
onResolverMeasurement: (info, timing) => console.log(`\tResolver of "${info.parentType.toString()}.${info.fieldName}" done in ${timing.ms}ms`),
|
|
11
|
-
onContextBuildingMeasurement: (timing) => console.log(`Context building done in ${timing.ms}ms`),
|
|
12
|
-
};
|
|
13
|
-
const deltaFrom = (hrtime) => {
|
|
14
|
-
const delta = process.hrtime(hrtime);
|
|
15
|
-
const ns = delta[0] * HR_TO_NS + delta[1];
|
|
16
|
-
return {
|
|
17
|
-
ns,
|
|
18
|
-
get ms() {
|
|
19
|
-
return ns / NS_TO_MS;
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export const useTiming = (rawOptions) => {
|
|
24
|
-
const options = {
|
|
25
|
-
...DEFAULT_OPTIONS,
|
|
26
|
-
...rawOptions,
|
|
27
|
-
};
|
|
28
|
-
const result = {};
|
|
29
|
-
if (options.onContextBuildingMeasurement) {
|
|
30
|
-
result.onContextBuilding = ({ context }) => {
|
|
31
|
-
if (context[envelopIsIntrospectionSymbol]) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const contextStartTime = process.hrtime();
|
|
35
|
-
return () => {
|
|
36
|
-
options.onContextBuildingMeasurement(deltaFrom(contextStartTime));
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
if (options.onParsingMeasurement) {
|
|
41
|
-
result.onParse = ({ params, extendContext }) => {
|
|
42
|
-
if (options.skipIntrospection && isIntrospectionOperationString(params.source)) {
|
|
43
|
-
extendContext({
|
|
44
|
-
[envelopIsIntrospectionSymbol]: true,
|
|
45
|
-
});
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const parseStartTime = process.hrtime();
|
|
49
|
-
return () => {
|
|
50
|
-
options.onParsingMeasurement(params.source, deltaFrom(parseStartTime));
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
if (options.onValidationMeasurement) {
|
|
55
|
-
result.onValidate = ({ params, context }) => {
|
|
56
|
-
if (context[envelopIsIntrospectionSymbol]) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const validateStartTime = process.hrtime();
|
|
60
|
-
return () => {
|
|
61
|
-
options.onValidationMeasurement(params.documentAST, deltaFrom(validateStartTime));
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
if (options.onExecutionMeasurement) {
|
|
66
|
-
if (options.onResolverMeasurement) {
|
|
67
|
-
result.onExecute = ({ args }) => {
|
|
68
|
-
if (args.contextValue[envelopIsIntrospectionSymbol]) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const executeStartTime = process.hrtime();
|
|
72
|
-
return {
|
|
73
|
-
onExecuteDone: () => {
|
|
74
|
-
options.onExecutionMeasurement(args, deltaFrom(executeStartTime));
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
result.onResolverCalled = ({ info }) => {
|
|
79
|
-
const resolverStartTime = process.hrtime();
|
|
80
|
-
return () => {
|
|
81
|
-
options.onResolverMeasurement(info, deltaFrom(resolverStartTime));
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
result.onExecute = ({ args }) => {
|
|
87
|
-
if (args.contextValue[envelopIsIntrospectionSymbol]) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const executeStartTime = process.hrtime();
|
|
91
|
-
return {
|
|
92
|
-
onExecuteDone: () => {
|
|
93
|
-
options.onExecutionMeasurement(args, deltaFrom(executeStartTime));
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (options.onSubscriptionMeasurement) {
|
|
100
|
-
if (options.onResolverMeasurement) {
|
|
101
|
-
result.onSubscribe = ({ args }) => {
|
|
102
|
-
if (args.contextValue[envelopIsIntrospectionSymbol]) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const subscribeStartTime = process.hrtime();
|
|
106
|
-
return {
|
|
107
|
-
onSubscribeResult: () => {
|
|
108
|
-
options.onSubscriptionMeasurement && options.onSubscriptionMeasurement(args, deltaFrom(subscribeStartTime));
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
result.onResolverCalled = ({ info }) => {
|
|
113
|
-
const resolverStartTime = process.hrtime();
|
|
114
|
-
return () => {
|
|
115
|
-
options.onResolverMeasurement && options.onResolverMeasurement(info, deltaFrom(resolverStartTime));
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
result.onSubscribe = ({ args }) => {
|
|
121
|
-
if (args.contextValue[envelopIsIntrospectionSymbol]) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
const subscribeStartTime = process.hrtime();
|
|
125
|
-
return {
|
|
126
|
-
onSubscribeResult: () => {
|
|
127
|
-
options.onSubscriptionMeasurement && options.onSubscriptionMeasurement(args, deltaFrom(subscribeStartTime));
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return result;
|
|
134
|
-
};
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { GraphQLSchema, } from 'graphql';
|
|
3
|
-
import { isAsyncIterable } from './utils.js';
|
|
4
|
-
const getTimestamp = typeof globalThis !== 'undefined' && ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.performance) === null || _a === void 0 ? void 0 : _a.now)
|
|
5
|
-
? () => globalThis.performance.now()
|
|
6
|
-
: () => Date.now();
|
|
7
|
-
const measure = () => {
|
|
8
|
-
const start = getTimestamp();
|
|
9
|
-
return () => {
|
|
10
|
-
const end = getTimestamp();
|
|
11
|
-
return end - start;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
const tracingSymbol = Symbol('envelopTracing');
|
|
15
|
-
export function traceOrchestrator(orchestrator) {
|
|
16
|
-
const createTracer = (name, ctx) => {
|
|
17
|
-
const end = measure();
|
|
18
|
-
return () => {
|
|
19
|
-
ctx[tracingSymbol][name] = end();
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
return {
|
|
23
|
-
...orchestrator,
|
|
24
|
-
init: (ctx = {}) => {
|
|
25
|
-
ctx[tracingSymbol] = ctx[tracingSymbol] || {};
|
|
26
|
-
const done = createTracer('init', ctx || {});
|
|
27
|
-
try {
|
|
28
|
-
return orchestrator.init(ctx);
|
|
29
|
-
}
|
|
30
|
-
finally {
|
|
31
|
-
done();
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
parse: (ctx = {}) => {
|
|
35
|
-
ctx[tracingSymbol] = ctx[tracingSymbol] || {};
|
|
36
|
-
const actualFn = orchestrator.parse(ctx);
|
|
37
|
-
return (...args) => {
|
|
38
|
-
const done = createTracer('parse', ctx);
|
|
39
|
-
try {
|
|
40
|
-
return actualFn(...args);
|
|
41
|
-
}
|
|
42
|
-
finally {
|
|
43
|
-
done();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
validate: (ctx = {}) => {
|
|
48
|
-
ctx[tracingSymbol] = ctx[tracingSymbol] || {};
|
|
49
|
-
const actualFn = orchestrator.validate(ctx);
|
|
50
|
-
return (...args) => {
|
|
51
|
-
const done = createTracer('validate', ctx);
|
|
52
|
-
try {
|
|
53
|
-
return actualFn(...args);
|
|
54
|
-
}
|
|
55
|
-
finally {
|
|
56
|
-
done();
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
execute: async (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, typeResolver) => {
|
|
61
|
-
const args = argsOrSchema instanceof GraphQLSchema
|
|
62
|
-
? {
|
|
63
|
-
schema: argsOrSchema,
|
|
64
|
-
document: document,
|
|
65
|
-
rootValue,
|
|
66
|
-
contextValue,
|
|
67
|
-
variableValues,
|
|
68
|
-
operationName,
|
|
69
|
-
fieldResolver,
|
|
70
|
-
typeResolver,
|
|
71
|
-
}
|
|
72
|
-
: argsOrSchema;
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
74
|
-
// @ts-ignore GraphQL.js types contextValue as unknown
|
|
75
|
-
const done = createTracer('execute', args.contextValue || {});
|
|
76
|
-
try {
|
|
77
|
-
const result = await orchestrator.execute(args);
|
|
78
|
-
done();
|
|
79
|
-
if (!isAsyncIterable(result)) {
|
|
80
|
-
result.extensions = result.extensions || {};
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
82
|
-
// @ts-ignore GraphQL.js types contextValue as unknown
|
|
83
|
-
result.extensions.envelopTracing = args.contextValue[tracingSymbol];
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
// eslint-disable-next-line no-console
|
|
87
|
-
console.warn(`"traceOrchestrator" encountered a AsyncIterator which is not supported yet, so tracing data is not available for the operation.`);
|
|
88
|
-
}
|
|
89
|
-
return result;
|
|
90
|
-
}
|
|
91
|
-
catch (e) {
|
|
92
|
-
done();
|
|
93
|
-
throw e;
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
subscribe: async (argsOrSchema, document, rootValue, contextValue, variableValues, operationName, fieldResolver, subscribeFieldResolver) => {
|
|
97
|
-
const args = argsOrSchema instanceof GraphQLSchema
|
|
98
|
-
? {
|
|
99
|
-
schema: argsOrSchema,
|
|
100
|
-
document: document,
|
|
101
|
-
rootValue,
|
|
102
|
-
contextValue,
|
|
103
|
-
variableValues,
|
|
104
|
-
operationName,
|
|
105
|
-
fieldResolver,
|
|
106
|
-
subscribeFieldResolver,
|
|
107
|
-
}
|
|
108
|
-
: argsOrSchema;
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
110
|
-
// @ts-ignore GraphQL.js types contextValue as unknown
|
|
111
|
-
const done = createTracer('subscribe', args.contextValue || {});
|
|
112
|
-
try {
|
|
113
|
-
return await orchestrator.subscribe(args);
|
|
114
|
-
}
|
|
115
|
-
finally {
|
|
116
|
-
done();
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
contextFactory: (ctx = {}) => {
|
|
120
|
-
const actualFn = orchestrator.contextFactory(ctx);
|
|
121
|
-
return async (childCtx) => {
|
|
122
|
-
const done = createTracer('contextFactory', ctx);
|
|
123
|
-
try {
|
|
124
|
-
return await actualFn(childCtx);
|
|
125
|
-
}
|
|
126
|
-
finally {
|
|
127
|
-
done();
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
}
|
package/esm/traced-schema.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { defaultFieldResolver, isIntrospectionType, isObjectType } from 'graphql';
|
|
2
|
-
export const trackedSchemaSymbol = Symbol('TRACKED_SCHEMA');
|
|
3
|
-
export const resolversHooksSymbol = Symbol('RESOLVERS_HOOKS');
|
|
4
|
-
export function prepareTracedSchema(schema) {
|
|
5
|
-
if (!schema || schema[trackedSchemaSymbol]) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
schema[trackedSchemaSymbol] = true;
|
|
9
|
-
const entries = Object.values(schema.getTypeMap());
|
|
10
|
-
for (const type of entries) {
|
|
11
|
-
if (!isIntrospectionType(type) && isObjectType(type)) {
|
|
12
|
-
const fields = Object.values(type.getFields());
|
|
13
|
-
for (const field of fields) {
|
|
14
|
-
let resolverFn = (field.resolve || defaultFieldResolver);
|
|
15
|
-
field.resolve = async (root, args, context, info) => {
|
|
16
|
-
if (context && context[resolversHooksSymbol]) {
|
|
17
|
-
const hooks = context[resolversHooksSymbol];
|
|
18
|
-
const afterCalls = [];
|
|
19
|
-
for (const hook of hooks) {
|
|
20
|
-
const afterFn = await hook({
|
|
21
|
-
root,
|
|
22
|
-
args,
|
|
23
|
-
context,
|
|
24
|
-
info,
|
|
25
|
-
resolverFn,
|
|
26
|
-
replaceResolverFn: newFn => {
|
|
27
|
-
resolverFn = newFn;
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
afterFn && afterCalls.push(afterFn);
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
let result = await resolverFn(root, args, context, info);
|
|
34
|
-
for (const afterFn of afterCalls) {
|
|
35
|
-
afterFn({
|
|
36
|
-
result,
|
|
37
|
-
setResult: newResult => {
|
|
38
|
-
result = newResult;
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
let resultErr = e;
|
|
46
|
-
for (const afterFn of afterCalls) {
|
|
47
|
-
afterFn({
|
|
48
|
-
result: resultErr,
|
|
49
|
-
setResult: newResult => {
|
|
50
|
-
resultErr = newResult;
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
throw resultErr;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return resolverFn(root, args, context, info);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from '@envelop/types';
|
|
2
|
-
/**
|
|
3
|
-
* In case a GraphQL operation only contains introspection fields the context building can be skipped completely.
|
|
4
|
-
* With this plugin any further context extensions will be skipped.
|
|
5
|
-
*/
|
|
6
|
-
export declare const useImmediateIntrospection: () => Plugin;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from '@envelop/types';
|
|
2
|
-
/**
|
|
3
|
-
* In case a GraphQL operation only contains introspection fields the context building can be skipped completely.
|
|
4
|
-
* With this plugin any further context extensions will be skipped.
|
|
5
|
-
*/
|
|
6
|
-
export declare const useImmediateIntrospection: () => Plugin;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Plugin } from '@envelop/types';
|
|
2
|
-
import { GraphQLError, GraphQLErrorExtensions } from 'graphql';
|
|
3
|
-
export declare const DEFAULT_ERROR_MESSAGE = "Unexpected error.";
|
|
4
|
-
export declare class EnvelopError extends GraphQLError {
|
|
5
|
-
constructor(message: string, extensions?: GraphQLErrorExtensions);
|
|
6
|
-
}
|
|
7
|
-
export declare type FormatErrorHandler = (error: GraphQLError | unknown, message: string, isDev: boolean) => GraphQLError;
|
|
8
|
-
export declare const formatError: FormatErrorHandler;
|
|
9
|
-
export declare type UseMaskedErrorsOpts = {
|
|
10
|
-
/** The function used for format/identify errors. */
|
|
11
|
-
formatError?: FormatErrorHandler;
|
|
12
|
-
/** The error message that shall be used for masked errors. */
|
|
13
|
-
errorMessage?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Additional information that is forwarded to the `formatError` function.
|
|
16
|
-
* The default value is `process.env['NODE_ENV'] === 'development'`
|
|
17
|
-
*/
|
|
18
|
-
isDev?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Whether parse errors should be processed by this plugin.
|
|
21
|
-
* In general it is not recommend to set this flag to `true`
|
|
22
|
-
* as a `parse` error contains useful information for debugging a GraphQL operation.
|
|
23
|
-
* A `parse` error never contains any sensitive information.
|
|
24
|
-
* @default false
|
|
25
|
-
*/
|
|
26
|
-
handleParseErrors?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Whether validation errors should processed by this plugin.
|
|
29
|
-
* In general we recommend against setting this flag to `true`
|
|
30
|
-
* as a `validate` error contains useful information for debugging a GraphQL operation.
|
|
31
|
-
* A `validate` error contains "did you mean x" suggestions that make it easier
|
|
32
|
-
* to reverse-introspect a GraphQL schema whose introspection capabilities got disabled.
|
|
33
|
-
* Instead of disabling introspection and masking validation errors, using persisted operations
|
|
34
|
-
* is a safer solution for avoiding the execution of unwanted/arbitrary operations.
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
37
|
-
handleValidationErrors?: boolean;
|
|
38
|
-
};
|
|
39
|
-
export declare const useMaskedErrors: (opts?: UseMaskedErrorsOpts) => Plugin;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Plugin } from '@envelop/types';
|
|
2
|
-
import { GraphQLError, GraphQLErrorExtensions } from 'graphql';
|
|
3
|
-
export declare const DEFAULT_ERROR_MESSAGE = "Unexpected error.";
|
|
4
|
-
export declare class EnvelopError extends GraphQLError {
|
|
5
|
-
constructor(message: string, extensions?: GraphQLErrorExtensions);
|
|
6
|
-
}
|
|
7
|
-
export declare type FormatErrorHandler = (error: GraphQLError | unknown, message: string, isDev: boolean) => GraphQLError;
|
|
8
|
-
export declare const formatError: FormatErrorHandler;
|
|
9
|
-
export declare type UseMaskedErrorsOpts = {
|
|
10
|
-
/** The function used for format/identify errors. */
|
|
11
|
-
formatError?: FormatErrorHandler;
|
|
12
|
-
/** The error message that shall be used for masked errors. */
|
|
13
|
-
errorMessage?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Additional information that is forwarded to the `formatError` function.
|
|
16
|
-
* The default value is `process.env['NODE_ENV'] === 'development'`
|
|
17
|
-
*/
|
|
18
|
-
isDev?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Whether parse errors should be processed by this plugin.
|
|
21
|
-
* In general it is not recommend to set this flag to `true`
|
|
22
|
-
* as a `parse` error contains useful information for debugging a GraphQL operation.
|
|
23
|
-
* A `parse` error never contains any sensitive information.
|
|
24
|
-
* @default false
|
|
25
|
-
*/
|
|
26
|
-
handleParseErrors?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Whether validation errors should processed by this plugin.
|
|
29
|
-
* In general we recommend against setting this flag to `true`
|
|
30
|
-
* as a `validate` error contains useful information for debugging a GraphQL operation.
|
|
31
|
-
* A `validate` error contains "did you mean x" suggestions that make it easier
|
|
32
|
-
* to reverse-introspect a GraphQL schema whose introspection capabilities got disabled.
|
|
33
|
-
* Instead of disabling introspection and masking validation errors, using persisted operations
|
|
34
|
-
* is a safer solution for avoiding the execution of unwanted/arbitrary operations.
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
37
|
-
handleValidationErrors?: boolean;
|
|
38
|
-
};
|
|
39
|
-
export declare const useMaskedErrors: (opts?: UseMaskedErrorsOpts) => Plugin;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Plugin } from '@envelop/types';
|
|
2
|
-
import { DocumentNode, ExecutionArgs, GraphQLResolveInfo, Source, SubscriptionArgs } from 'graphql';
|
|
3
|
-
import { envelopIsIntrospectionSymbol } from '../utils.cjs';
|
|
4
|
-
export declare type ResultTiming = {
|
|
5
|
-
ms: number;
|
|
6
|
-
ns: number;
|
|
7
|
-
};
|
|
8
|
-
export declare type TimingPluginOptions = {
|
|
9
|
-
skipIntrospection?: boolean;
|
|
10
|
-
onContextBuildingMeasurement?: (timing: ResultTiming) => void;
|
|
11
|
-
onExecutionMeasurement?: (args: ExecutionArgs, timing: ResultTiming) => void;
|
|
12
|
-
onSubscriptionMeasurement?: (args: SubscriptionArgs, timing: ResultTiming) => void;
|
|
13
|
-
onParsingMeasurement?: (source: Source | string, timing: ResultTiming) => void;
|
|
14
|
-
onValidationMeasurement?: (document: DocumentNode, timing: ResultTiming) => void;
|
|
15
|
-
onResolverMeasurement?: (info: GraphQLResolveInfo, timing: ResultTiming) => void;
|
|
16
|
-
};
|
|
17
|
-
declare type InternalPluginContext = {
|
|
18
|
-
[envelopIsIntrospectionSymbol]?: true;
|
|
19
|
-
};
|
|
20
|
-
export declare const useTiming: (rawOptions?: TimingPluginOptions) => Plugin<InternalPluginContext>;
|
|
21
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Plugin } from '@envelop/types';
|
|
2
|
-
import { DocumentNode, ExecutionArgs, GraphQLResolveInfo, Source, SubscriptionArgs } from 'graphql';
|
|
3
|
-
import { envelopIsIntrospectionSymbol } from '../utils.js';
|
|
4
|
-
export declare type ResultTiming = {
|
|
5
|
-
ms: number;
|
|
6
|
-
ns: number;
|
|
7
|
-
};
|
|
8
|
-
export declare type TimingPluginOptions = {
|
|
9
|
-
skipIntrospection?: boolean;
|
|
10
|
-
onContextBuildingMeasurement?: (timing: ResultTiming) => void;
|
|
11
|
-
onExecutionMeasurement?: (args: ExecutionArgs, timing: ResultTiming) => void;
|
|
12
|
-
onSubscriptionMeasurement?: (args: SubscriptionArgs, timing: ResultTiming) => void;
|
|
13
|
-
onParsingMeasurement?: (source: Source | string, timing: ResultTiming) => void;
|
|
14
|
-
onValidationMeasurement?: (document: DocumentNode, timing: ResultTiming) => void;
|
|
15
|
-
onResolverMeasurement?: (info: GraphQLResolveInfo, timing: ResultTiming) => void;
|
|
16
|
-
};
|
|
17
|
-
declare type InternalPluginContext = {
|
|
18
|
-
[envelopIsIntrospectionSymbol]?: true;
|
|
19
|
-
};
|
|
20
|
-
export declare const useTiming: (rawOptions?: TimingPluginOptions) => Plugin<InternalPluginContext>;
|
|
21
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ArbitraryObject } from '@envelop/types';
|
|
2
|
-
import { EnvelopOrchestrator } from './orchestrator.cjs';
|
|
3
|
-
declare const tracingSymbol: unique symbol;
|
|
4
|
-
export declare function traceOrchestrator<TInitialContext extends ArbitraryObject, TPluginsContext extends ArbitraryObject>(orchestrator: EnvelopOrchestrator<TInitialContext, TPluginsContext>): EnvelopOrchestrator<TInitialContext & {
|
|
5
|
-
[tracingSymbol]?: {};
|
|
6
|
-
}, TPluginsContext>;
|
|
7
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ArbitraryObject } from '@envelop/types';
|
|
2
|
-
import { EnvelopOrchestrator } from './orchestrator.js';
|
|
3
|
-
declare const tracingSymbol: unique symbol;
|
|
4
|
-
export declare function traceOrchestrator<TInitialContext extends ArbitraryObject, TPluginsContext extends ArbitraryObject>(orchestrator: EnvelopOrchestrator<TInitialContext, TPluginsContext>): EnvelopOrchestrator<TInitialContext & {
|
|
5
|
-
[tracingSymbol]?: {};
|
|
6
|
-
}, TPluginsContext>;
|
|
7
|
-
export {};
|