@envelop/core 2.6.0 → 2.6.1-alpha-20220901205925-b1fd44a9
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 +20 -12
- package/cjs/plugins/use-error-handler.js +1 -2
- package/cjs/traced-schema.js +29 -7
- package/cjs/utils.js +8 -40
- package/esm/create.js +7 -5
- package/esm/index.js +1 -3
- package/esm/orchestrator.js +12 -4
- package/esm/plugins/use-error-handler.js +1 -2
- package/esm/traced-schema.js +25 -3
- package/esm/utils.js +7 -36
- 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 +11 -4
- package/typings/orchestrator.d.ts +11 -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/traced-schema.d.cts +1 -3
- package/typings/traced-schema.d.ts +1 -3
- 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/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/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
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { GraphQLError } from 'graphql';
|
|
2
|
-
import { handleStreamOrSingleExecutionResult } from '../utils.js';
|
|
3
|
-
export const DEFAULT_ERROR_MESSAGE = 'Unexpected error.';
|
|
4
|
-
export class EnvelopError extends GraphQLError {
|
|
5
|
-
constructor(message, extensions) {
|
|
6
|
-
super(message, undefined, undefined, undefined, undefined, undefined, extensions);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export const formatError = (err, message, isDev) => {
|
|
10
|
-
var _a, _b, _c, _d;
|
|
11
|
-
if (err instanceof GraphQLError) {
|
|
12
|
-
if (
|
|
13
|
-
/** execution error */
|
|
14
|
-
(err.originalError && err.originalError instanceof EnvelopError === false) ||
|
|
15
|
-
/** validate and parse errors */
|
|
16
|
-
(err.originalError === undefined && err instanceof EnvelopError === false)) {
|
|
17
|
-
return new GraphQLError(message, err.nodes, err.source, err.positions, err.path, undefined, isDev
|
|
18
|
-
? {
|
|
19
|
-
originalError: {
|
|
20
|
-
message: (_b = (_a = err.originalError) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : err.message,
|
|
21
|
-
stack: (_d = (_c = err.originalError) === null || _c === void 0 ? void 0 : _c.stack) !== null && _d !== void 0 ? _d : err.stack,
|
|
22
|
-
},
|
|
23
|
-
}
|
|
24
|
-
: undefined);
|
|
25
|
-
}
|
|
26
|
-
return err;
|
|
27
|
-
}
|
|
28
|
-
return new GraphQLError(message);
|
|
29
|
-
};
|
|
30
|
-
const makeHandleResult = (format, message, isDev) => ({ result, setResult }) => {
|
|
31
|
-
if (result.errors != null) {
|
|
32
|
-
setResult({ ...result, errors: result.errors.map(error => format(error, message, isDev)) });
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
export const useMaskedErrors = (opts) => {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
const format = (_a = opts === null || opts === void 0 ? void 0 : opts.formatError) !== null && _a !== void 0 ? _a : formatError;
|
|
38
|
-
const message = (opts === null || opts === void 0 ? void 0 : opts.errorMessage) || DEFAULT_ERROR_MESSAGE;
|
|
39
|
-
// eslint-disable-next-line dot-notation
|
|
40
|
-
const isDev = (_b = opts === null || opts === void 0 ? void 0 : opts.isDev) !== null && _b !== void 0 ? _b : (typeof process !== 'undefined' ? process.env['NODE_ENV'] === 'development' : false);
|
|
41
|
-
const handleResult = makeHandleResult(format, message, isDev);
|
|
42
|
-
return {
|
|
43
|
-
onParse: (opts === null || opts === void 0 ? void 0 : opts.handleParseErrors) === true
|
|
44
|
-
? function onParse() {
|
|
45
|
-
return function onParseEnd({ result, replaceParseResult }) {
|
|
46
|
-
if (result instanceof Error) {
|
|
47
|
-
replaceParseResult(format(result, message, isDev));
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
: undefined,
|
|
52
|
-
onValidate: (opts === null || opts === void 0 ? void 0 : opts.handleValidationErrors) === true
|
|
53
|
-
? function onValidate() {
|
|
54
|
-
return function onValidateEnd({ valid, result, setResult }) {
|
|
55
|
-
if (valid === false) {
|
|
56
|
-
setResult(result.map(error => format(error, message, isDev)));
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
: undefined,
|
|
61
|
-
onPluginInit(context) {
|
|
62
|
-
context.registerContextErrorHandler(({ error, setError }) => {
|
|
63
|
-
if (error instanceof GraphQLError === false && error instanceof Error) {
|
|
64
|
-
error = new GraphQLError(error.message, undefined, undefined, undefined, undefined, error);
|
|
65
|
-
}
|
|
66
|
-
setError(format(error, message, isDev));
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
onExecute() {
|
|
70
|
-
return {
|
|
71
|
-
onExecuteDone(payload) {
|
|
72
|
-
return handleStreamOrSingleExecutionResult(payload, handleResult);
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
onSubscribe() {
|
|
77
|
-
return {
|
|
78
|
-
onSubscribeResult(payload) {
|
|
79
|
-
return handleStreamOrSingleExecutionResult(payload, handleResult);
|
|
80
|
-
},
|
|
81
|
-
onSubscribeError({ error, setError }) {
|
|
82
|
-
setError(format(error, message, isDev));
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
};
|
|
@@ -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
|
-
}
|
|
@@ -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 {};
|