@envelop/core 1.1.0 → 1.4.0-alpha-e8998c9.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/create.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { GetEnvelopedFn, ComposeContext, Plugin } from '@envelop/types';
2
+ import { PluginOrDisabledPlugin } from './enable-if';
2
3
  export declare function envelop<PluginsType extends Plugin<any>[]>(options: {
3
- plugins: PluginsType;
4
+ plugins: Array<PluginOrDisabledPlugin>;
4
5
  enableInternalTracing?: boolean;
5
6
  }): GetEnvelopedFn<ComposeContext<PluginsType>>;
package/enable-if.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { Plugin } from '@envelop/types';
2
+ /**
3
+ * This enum is used only internally in order to create nominal type for the disabled plugin
4
+ */
5
+ declare enum EnableIfBranded {
6
+ DisabledPlugin = 0
7
+ }
8
+ export declare type PluginOrDisabledPlugin = Plugin<any> | EnableIfBranded.DisabledPlugin;
9
+ export declare function isPluginEnabled(t: PluginOrDisabledPlugin): t is Plugin;
10
+ /**
11
+ * Utility function to enable a plugin.
12
+ */
13
+ export declare function enableIf(condition: boolean, plugin: Plugin): PluginOrDisabledPlugin;
14
+ export {};
package/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export * from './plugins/use-error-handler';
9
9
  export * from './plugins/use-extend-context';
10
10
  export * from './plugins/use-payload-formatter';
11
11
  export * from './plugins/use-masked-errors';
12
+ export * from './enable-if';
package/index.js CHANGED
@@ -5,6 +5,23 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const types = require('@envelop/types');
6
6
  const graphql = require('graphql');
7
7
 
8
+ /**
9
+ * This enum is used only internally in order to create nominal type for the disabled plugin
10
+ */
11
+ var EnableIfBranded;
12
+ (function (EnableIfBranded) {
13
+ EnableIfBranded[EnableIfBranded["DisabledPlugin"] = 0] = "DisabledPlugin";
14
+ })(EnableIfBranded || (EnableIfBranded = {}));
15
+ function isPluginEnabled(t) {
16
+ return t !== EnableIfBranded.DisabledPlugin && t !== null;
17
+ }
18
+ /**
19
+ * Utility function to enable a plugin.
20
+ */
21
+ function enableIf(condition, plugin) {
22
+ return condition ? plugin : EnableIfBranded.DisabledPlugin;
23
+ }
24
+
8
25
  const trackedSchemaSymbol = Symbol('TRACKED_SCHEMA');
9
26
  const resolversHooksSymbol = Symbol('RESOLVERS_HOOKS');
10
27
  function prepareTracedSchema(schema) {
@@ -400,11 +417,14 @@ function createEnvelopOrchestrator(plugins) {
400
417
  let result = await subscribeFn({
401
418
  ...args,
402
419
  contextValue: context,
420
+ // Casted for GraphQL.js 15 compatibility
421
+ // Can be removed once we drop support for GraphQL.js 15
403
422
  });
404
423
  const onNextHandler = [];
405
424
  const onEndHandler = [];
406
425
  for (const afterCb of afterCalls) {
407
426
  const hookResult = afterCb({
427
+ args: args,
408
428
  result,
409
429
  setResult: newResult => {
410
430
  result = newResult;
@@ -422,7 +442,11 @@ function createEnvelopOrchestrator(plugins) {
422
442
  if (onNextHandler.length && types.isAsyncIterable(result)) {
423
443
  result = mapAsyncIterator(result, async (result) => {
424
444
  for (const onNext of onNextHandler) {
425
- await onNext({ result, setResult: newResult => (result = newResult) });
445
+ await onNext({
446
+ args: args,
447
+ result,
448
+ setResult: newResult => (result = newResult),
449
+ });
426
450
  }
427
451
  return result;
428
452
  });
@@ -504,6 +528,7 @@ function createEnvelopOrchestrator(plugins) {
504
528
  const onEndHandler = [];
505
529
  for (const afterCb of afterCalls) {
506
530
  const hookResult = afterCb({
531
+ args: args,
507
532
  result,
508
533
  setResult: newResult => {
509
534
  result = newResult;
@@ -521,7 +546,11 @@ function createEnvelopOrchestrator(plugins) {
521
546
  if (onNextHandler.length && types.isAsyncIterable(result)) {
522
547
  result = mapAsyncIterator(result, async (result) => {
523
548
  for (const onNext of onNextHandler) {
524
- await onNext({ result, setResult: newResult => (result = newResult) });
549
+ await onNext({
550
+ args: args,
551
+ result,
552
+ setResult: newResult => (result = newResult),
553
+ });
525
554
  }
526
555
  return result;
527
556
  });
@@ -627,12 +656,16 @@ function traceOrchestrator(orchestrator) {
627
656
  typeResolver,
628
657
  }
629
658
  : argsOrSchema;
659
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
660
+ // @ts-ignore GraphQL.js types contextValue as unknown
630
661
  const done = createTracer('execute', args.contextValue || {});
631
662
  try {
632
663
  const result = await orchestrator.execute(args);
633
664
  done();
634
665
  if (!types.isAsyncIterable(result)) {
635
666
  result.extensions = result.extensions || {};
667
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
668
+ // @ts-ignore GraphQL.js types contextValue as unknown
636
669
  result.extensions.envelopTracing = args.contextValue._envelopTracing;
637
670
  }
638
671
  else {
@@ -659,6 +692,8 @@ function traceOrchestrator(orchestrator) {
659
692
  subscribeFieldResolver,
660
693
  }
661
694
  : argsOrSchema;
695
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
696
+ // @ts-ignore GraphQL.js types contextValue as unknown
662
697
  const done = createTracer('subscribe', args.contextValue || {});
663
698
  try {
664
699
  return await orchestrator.subscribe(args);
@@ -683,7 +718,8 @@ function traceOrchestrator(orchestrator) {
683
718
  }
684
719
 
685
720
  function envelop(options) {
686
- let orchestrator = createEnvelopOrchestrator(options.plugins);
721
+ const plugins = options.plugins.filter(isPluginEnabled);
722
+ let orchestrator = createEnvelopOrchestrator(plugins);
687
723
  if (options.enableInternalTracing) {
688
724
  orchestrator = traceOrchestrator(orchestrator);
689
725
  }
@@ -699,7 +735,7 @@ function envelop(options) {
699
735
  schema: typedOrchestrator.getCurrentSchema(),
700
736
  };
701
737
  };
702
- getEnveloped._plugins = options.plugins;
738
+ getEnveloped._plugins = plugins;
703
739
  return getEnveloped;
704
740
  }
705
741
 
@@ -911,10 +947,10 @@ const useAsyncSchema = (schemaPromise) => {
911
947
  };
912
948
  };
913
949
 
914
- const makeHandleResult = (errorHandler) => ({ result }) => {
950
+ const makeHandleResult = (errorHandler) => ({ result, args }) => {
915
951
  var _a;
916
952
  if ((_a = result.errors) === null || _a === void 0 ? void 0 : _a.length) {
917
- errorHandler(result.errors);
953
+ errorHandler(result.errors, args);
918
954
  }
919
955
  };
920
956
  const useErrorHandler = (errorHandler) => ({
@@ -951,33 +987,35 @@ const usePayloadFormatter = (formatter) => ({
951
987
  },
952
988
  });
953
989
 
990
+ const DEFAULT_ERROR_MESSAGE = 'Unexpected error.';
954
991
  class EnvelopError extends graphql.GraphQLError {
955
992
  constructor(message, extensions) {
956
993
  super(message, undefined, undefined, undefined, undefined, undefined, extensions);
957
994
  }
958
995
  }
959
- const formatError = err => {
996
+ const formatError = (err, message) => {
960
997
  if (err instanceof graphql.GraphQLError) {
961
998
  if (err.originalError && err.originalError instanceof EnvelopError === false) {
962
- return new graphql.GraphQLError('Unexpected error.', err.nodes, err.source, err.positions, err.path, undefined);
999
+ return new graphql.GraphQLError(message, err.nodes, err.source, err.positions, err.path, undefined);
963
1000
  }
964
1001
  return err;
965
1002
  }
966
- return new graphql.GraphQLError('Unexpected error.');
1003
+ return new graphql.GraphQLError(message);
967
1004
  };
968
- const makeHandleResult$2 = (format) => ({ result, setResult }) => {
1005
+ const makeHandleResult$2 = (format, message) => ({ result, setResult }) => {
969
1006
  if (result.errors != null) {
970
- setResult({ ...result, errors: result.errors.map(error => format(error)) });
1007
+ setResult({ ...result, errors: result.errors.map(error => format(error, message)) });
971
1008
  }
972
1009
  };
973
1010
  const useMaskedErrors = (opts) => {
974
1011
  var _a;
975
1012
  const format = (_a = opts === null || opts === void 0 ? void 0 : opts.formatError) !== null && _a !== void 0 ? _a : formatError;
976
- const handleResult = makeHandleResult$2(format);
1013
+ const message = (opts === null || opts === void 0 ? void 0 : opts.errorMessage) || DEFAULT_ERROR_MESSAGE;
1014
+ const handleResult = makeHandleResult$2(format, message);
977
1015
  return {
978
1016
  onPluginInit(context) {
979
1017
  context.registerContextErrorHandler(({ error, setError }) => {
980
- setError(formatError(error));
1018
+ setError(formatError(error, message));
981
1019
  });
982
1020
  },
983
1021
  onExecute() {
@@ -993,7 +1031,7 @@ const useMaskedErrors = (opts) => {
993
1031
  return types.handleStreamOrSingleExecutionResult(payload, handleResult);
994
1032
  },
995
1033
  onSubscribeError({ error, setError }) {
996
- setError(formatError(error));
1034
+ setError(formatError(error, message));
997
1035
  },
998
1036
  };
999
1037
  },
@@ -1008,7 +1046,9 @@ Object.keys(types).forEach(function (k) {
1008
1046
  }
1009
1047
  });
1010
1048
  });
1049
+ exports.DEFAULT_ERROR_MESSAGE = DEFAULT_ERROR_MESSAGE;
1011
1050
  exports.EnvelopError = EnvelopError;
1051
+ exports.enableIf = enableIf;
1012
1052
  exports.envelop = envelop;
1013
1053
  exports.envelopIsIntrospectionSymbol = envelopIsIntrospectionSymbol;
1014
1054
  exports.errorAsyncIterator = errorAsyncIterator;
@@ -1018,6 +1058,7 @@ exports.isIntrospectionDocument = isIntrospectionDocument;
1018
1058
  exports.isIntrospectionOperation = isIntrospectionOperation;
1019
1059
  exports.isIntrospectionOperationString = isIntrospectionOperationString;
1020
1060
  exports.isOperationDefinition = isOperationDefinition;
1061
+ exports.isPluginEnabled = isPluginEnabled;
1021
1062
  exports.makeExecute = makeExecute;
1022
1063
  exports.makeSubscribe = makeSubscribe;
1023
1064
  exports.mapAsyncIterator = mapAsyncIterator;
package/index.mjs CHANGED
@@ -2,6 +2,23 @@ import { isAsyncIterable, handleStreamOrSingleExecutionResult } from '@envelop/t
2
2
  export * from '@envelop/types';
3
3
  import { isIntrospectionType, isObjectType, defaultFieldResolver, Kind, visit, BREAK, parse, specifiedRules, validate, execute, subscribe, GraphQLSchema, getOperationAST, GraphQLError } from 'graphql';
4
4
 
5
+ /**
6
+ * This enum is used only internally in order to create nominal type for the disabled plugin
7
+ */
8
+ var EnableIfBranded;
9
+ (function (EnableIfBranded) {
10
+ EnableIfBranded[EnableIfBranded["DisabledPlugin"] = 0] = "DisabledPlugin";
11
+ })(EnableIfBranded || (EnableIfBranded = {}));
12
+ function isPluginEnabled(t) {
13
+ return t !== EnableIfBranded.DisabledPlugin && t !== null;
14
+ }
15
+ /**
16
+ * Utility function to enable a plugin.
17
+ */
18
+ function enableIf(condition, plugin) {
19
+ return condition ? plugin : EnableIfBranded.DisabledPlugin;
20
+ }
21
+
5
22
  const trackedSchemaSymbol = Symbol('TRACKED_SCHEMA');
6
23
  const resolversHooksSymbol = Symbol('RESOLVERS_HOOKS');
7
24
  function prepareTracedSchema(schema) {
@@ -397,11 +414,14 @@ function createEnvelopOrchestrator(plugins) {
397
414
  let result = await subscribeFn({
398
415
  ...args,
399
416
  contextValue: context,
417
+ // Casted for GraphQL.js 15 compatibility
418
+ // Can be removed once we drop support for GraphQL.js 15
400
419
  });
401
420
  const onNextHandler = [];
402
421
  const onEndHandler = [];
403
422
  for (const afterCb of afterCalls) {
404
423
  const hookResult = afterCb({
424
+ args: args,
405
425
  result,
406
426
  setResult: newResult => {
407
427
  result = newResult;
@@ -419,7 +439,11 @@ function createEnvelopOrchestrator(plugins) {
419
439
  if (onNextHandler.length && isAsyncIterable(result)) {
420
440
  result = mapAsyncIterator(result, async (result) => {
421
441
  for (const onNext of onNextHandler) {
422
- await onNext({ result, setResult: newResult => (result = newResult) });
442
+ await onNext({
443
+ args: args,
444
+ result,
445
+ setResult: newResult => (result = newResult),
446
+ });
423
447
  }
424
448
  return result;
425
449
  });
@@ -501,6 +525,7 @@ function createEnvelopOrchestrator(plugins) {
501
525
  const onEndHandler = [];
502
526
  for (const afterCb of afterCalls) {
503
527
  const hookResult = afterCb({
528
+ args: args,
504
529
  result,
505
530
  setResult: newResult => {
506
531
  result = newResult;
@@ -518,7 +543,11 @@ function createEnvelopOrchestrator(plugins) {
518
543
  if (onNextHandler.length && isAsyncIterable(result)) {
519
544
  result = mapAsyncIterator(result, async (result) => {
520
545
  for (const onNext of onNextHandler) {
521
- await onNext({ result, setResult: newResult => (result = newResult) });
546
+ await onNext({
547
+ args: args,
548
+ result,
549
+ setResult: newResult => (result = newResult),
550
+ });
522
551
  }
523
552
  return result;
524
553
  });
@@ -624,12 +653,16 @@ function traceOrchestrator(orchestrator) {
624
653
  typeResolver,
625
654
  }
626
655
  : argsOrSchema;
656
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
657
+ // @ts-ignore GraphQL.js types contextValue as unknown
627
658
  const done = createTracer('execute', args.contextValue || {});
628
659
  try {
629
660
  const result = await orchestrator.execute(args);
630
661
  done();
631
662
  if (!isAsyncIterable(result)) {
632
663
  result.extensions = result.extensions || {};
664
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
665
+ // @ts-ignore GraphQL.js types contextValue as unknown
633
666
  result.extensions.envelopTracing = args.contextValue._envelopTracing;
634
667
  }
635
668
  else {
@@ -656,6 +689,8 @@ function traceOrchestrator(orchestrator) {
656
689
  subscribeFieldResolver,
657
690
  }
658
691
  : argsOrSchema;
692
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
693
+ // @ts-ignore GraphQL.js types contextValue as unknown
659
694
  const done = createTracer('subscribe', args.contextValue || {});
660
695
  try {
661
696
  return await orchestrator.subscribe(args);
@@ -680,7 +715,8 @@ function traceOrchestrator(orchestrator) {
680
715
  }
681
716
 
682
717
  function envelop(options) {
683
- let orchestrator = createEnvelopOrchestrator(options.plugins);
718
+ const plugins = options.plugins.filter(isPluginEnabled);
719
+ let orchestrator = createEnvelopOrchestrator(plugins);
684
720
  if (options.enableInternalTracing) {
685
721
  orchestrator = traceOrchestrator(orchestrator);
686
722
  }
@@ -696,7 +732,7 @@ function envelop(options) {
696
732
  schema: typedOrchestrator.getCurrentSchema(),
697
733
  };
698
734
  };
699
- getEnveloped._plugins = options.plugins;
735
+ getEnveloped._plugins = plugins;
700
736
  return getEnveloped;
701
737
  }
702
738
 
@@ -908,10 +944,10 @@ const useAsyncSchema = (schemaPromise) => {
908
944
  };
909
945
  };
910
946
 
911
- const makeHandleResult = (errorHandler) => ({ result }) => {
947
+ const makeHandleResult = (errorHandler) => ({ result, args }) => {
912
948
  var _a;
913
949
  if ((_a = result.errors) === null || _a === void 0 ? void 0 : _a.length) {
914
- errorHandler(result.errors);
950
+ errorHandler(result.errors, args);
915
951
  }
916
952
  };
917
953
  const useErrorHandler = (errorHandler) => ({
@@ -948,33 +984,35 @@ const usePayloadFormatter = (formatter) => ({
948
984
  },
949
985
  });
950
986
 
987
+ const DEFAULT_ERROR_MESSAGE = 'Unexpected error.';
951
988
  class EnvelopError extends GraphQLError {
952
989
  constructor(message, extensions) {
953
990
  super(message, undefined, undefined, undefined, undefined, undefined, extensions);
954
991
  }
955
992
  }
956
- const formatError = err => {
993
+ const formatError = (err, message) => {
957
994
  if (err instanceof GraphQLError) {
958
995
  if (err.originalError && err.originalError instanceof EnvelopError === false) {
959
- return new GraphQLError('Unexpected error.', err.nodes, err.source, err.positions, err.path, undefined);
996
+ return new GraphQLError(message, err.nodes, err.source, err.positions, err.path, undefined);
960
997
  }
961
998
  return err;
962
999
  }
963
- return new GraphQLError('Unexpected error.');
1000
+ return new GraphQLError(message);
964
1001
  };
965
- const makeHandleResult$2 = (format) => ({ result, setResult }) => {
1002
+ const makeHandleResult$2 = (format, message) => ({ result, setResult }) => {
966
1003
  if (result.errors != null) {
967
- setResult({ ...result, errors: result.errors.map(error => format(error)) });
1004
+ setResult({ ...result, errors: result.errors.map(error => format(error, message)) });
968
1005
  }
969
1006
  };
970
1007
  const useMaskedErrors = (opts) => {
971
1008
  var _a;
972
1009
  const format = (_a = opts === null || opts === void 0 ? void 0 : opts.formatError) !== null && _a !== void 0 ? _a : formatError;
973
- const handleResult = makeHandleResult$2(format);
1010
+ const message = (opts === null || opts === void 0 ? void 0 : opts.errorMessage) || DEFAULT_ERROR_MESSAGE;
1011
+ const handleResult = makeHandleResult$2(format, message);
974
1012
  return {
975
1013
  onPluginInit(context) {
976
1014
  context.registerContextErrorHandler(({ error, setError }) => {
977
- setError(formatError(error));
1015
+ setError(formatError(error, message));
978
1016
  });
979
1017
  },
980
1018
  onExecute() {
@@ -990,11 +1028,11 @@ const useMaskedErrors = (opts) => {
990
1028
  return handleStreamOrSingleExecutionResult(payload, handleResult);
991
1029
  },
992
1030
  onSubscribeError({ error, setError }) {
993
- setError(formatError(error));
1031
+ setError(formatError(error, message));
994
1032
  },
995
1033
  };
996
1034
  },
997
1035
  };
998
1036
  };
999
1037
 
1000
- export { EnvelopError, envelop, envelopIsIntrospectionSymbol, errorAsyncIterator, finalAsyncIterator, formatError, isIntrospectionDocument, isIntrospectionOperation, isIntrospectionOperationString, isOperationDefinition, makeExecute, makeSubscribe, mapAsyncIterator, useAsyncSchema, useEnvelop, useErrorHandler, useExtendContext, useLazyLoadedSchema, useLogger, useMaskedErrors, usePayloadFormatter, useSchema, useTiming };
1038
+ export { DEFAULT_ERROR_MESSAGE, EnvelopError, enableIf, envelop, envelopIsIntrospectionSymbol, errorAsyncIterator, finalAsyncIterator, formatError, isIntrospectionDocument, isIntrospectionOperation, isIntrospectionOperationString, isOperationDefinition, isPluginEnabled, makeExecute, makeSubscribe, mapAsyncIterator, useAsyncSchema, useEnvelop, useErrorHandler, useExtendContext, useLazyLoadedSchema, useLogger, useMaskedErrors, usePayloadFormatter, useSchema, useTiming };
package/orchestrator.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ArbitraryObject, EnvelopContextFnWrapper, GetEnvelopedFn, Plugin } from '@envelop/types';
1
+ import { ArbitraryObject, EnvelopContextFnWrapper, GetEnvelopedFn, Plugin, DefaultContext } from '@envelop/types';
2
2
  import { GraphQLSchema } from 'graphql';
3
3
  import { Maybe } from 'graphql/jsutils/Maybe';
4
4
  export declare type EnvelopOrchestrator<InitialContext extends ArbitraryObject = ArbitraryObject, PluginsContext extends ArbitraryObject = ArbitraryObject> = {
@@ -10,4 +10,4 @@ export declare type EnvelopOrchestrator<InitialContext extends ArbitraryObject =
10
10
  contextFactory: EnvelopContextFnWrapper<ReturnType<GetEnvelopedFn<PluginsContext>>['contextFactory'], PluginsContext>;
11
11
  getCurrentSchema: () => Maybe<GraphQLSchema>;
12
12
  };
13
- export declare function createEnvelopOrchestrator<PluginsContext = any>(plugins: Plugin[]): EnvelopOrchestrator<any, PluginsContext>;
13
+ export declare function createEnvelopOrchestrator<PluginsContext extends DefaultContext>(plugins: Plugin[]): EnvelopOrchestrator<any, PluginsContext>;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@envelop/core",
3
- "version": "1.1.0",
3
+ "version": "1.4.0-alpha-e8998c9.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "graphql": "^14.0.0 || ^15.0.0"
6
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
7
7
  },
8
8
  "dependencies": {
9
- "@envelop/types": "1.1.0"
9
+ "@envelop/types": "1.3.0-alpha-e8998c9.0"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
@@ -1,4 +1,4 @@
1
- import { Plugin } from '@envelop/types';
1
+ import { Plugin, DefaultContext } from '@envelop/types';
2
2
  import { GraphQLError } from 'graphql';
3
- export declare type ErrorHandler = (errors: readonly GraphQLError[]) => void;
4
- export declare const useErrorHandler: (errorHandler: ErrorHandler) => Plugin;
3
+ export declare type ErrorHandler = (errors: readonly GraphQLError[], context: Readonly<DefaultContext>) => void;
4
+ export declare const useErrorHandler: <ContextType>(errorHandler: ErrorHandler) => Plugin<ContextType>;
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from '@envelop/types';
2
- import { envelopIsIntrospectionSymbol } from '..';
2
+ import { envelopIsIntrospectionSymbol } from '../utils';
3
3
  declare type LoggerPluginOptions = {
4
4
  logFn: typeof console.log;
5
5
  skipIntrospection?: boolean;
@@ -1,11 +1,13 @@
1
1
  import { Plugin } from '@envelop/types';
2
2
  import { GraphQLError } from 'graphql';
3
+ export declare const DEFAULT_ERROR_MESSAGE = "Unexpected error.";
3
4
  export declare class EnvelopError extends GraphQLError {
4
5
  constructor(message: string, extensions?: Record<string, any>);
5
6
  }
6
- export declare type FormatErrorHandler = (error: GraphQLError | unknown) => GraphQLError;
7
+ export declare type FormatErrorHandler = (error: GraphQLError | unknown, message: string) => GraphQLError;
7
8
  export declare const formatError: FormatErrorHandler;
8
9
  export declare type UseMaskedErrorsOpts = {
9
10
  formatError?: FormatErrorHandler;
11
+ errorMessage?: string;
10
12
  };
11
13
  export declare const useMaskedErrors: (opts?: UseMaskedErrorsOpts | undefined) => Plugin;
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from '@envelop/types';
2
2
  import { DocumentNode, ExecutionArgs, GraphQLResolveInfo, Source, SubscriptionArgs } from 'graphql';
3
- import { envelopIsIntrospectionSymbol } from '..';
3
+ import { envelopIsIntrospectionSymbol } from '../utils';
4
4
  export declare type ResultTiming = {
5
5
  ms: number;
6
6
  ns: number;
package/utils.d.ts CHANGED
@@ -9,11 +9,11 @@ export declare function isIntrospectionOperationString(operation: string | Sourc
9
9
  /**
10
10
  * Utility function for making a subscribe function that handles polymorphic arguments.
11
11
  */
12
- export declare const makeSubscribe: (subscribeFn: (args: SubscriptionArgs) => PromiseOrValue<AsyncIterableIterator<ExecutionResult> | ExecutionResult>) => SubscribeFunction;
13
- export declare function mapAsyncIterator<TInput, TOutput = TInput>(asyncIterable: AsyncIterableIterator<TInput>, map: (input: TInput) => Promise<TOutput> | TOutput): AsyncIterableIterator<TOutput>;
12
+ export declare const makeSubscribe: (subscribeFn: (args: SubscriptionArgs) => PromiseOrValue<AsyncIterableIterator<ExecutionResult>>) => SubscribeFunction;
13
+ export declare function mapAsyncIterator<TInput, TOutput = TInput>(asyncIterable: AsyncIterable<TInput>, map: (input: TInput) => Promise<TOutput> | TOutput): AsyncIterableIterator<TOutput>;
14
14
  /**
15
15
  * Utility function for making a execute function that handles polymorphic arguments.
16
16
  */
17
17
  export declare const makeExecute: (executeFn: (args: ExecutionArgs) => PromiseOrValue<AsyncIterableIteratorOrValue<ExecutionResult>>) => ExecuteFunction;
18
- export declare function finalAsyncIterator<TInput>(asyncIterable: AsyncIterableIterator<TInput>, onFinal: () => void): AsyncIterableIterator<TInput>;
19
- export declare function errorAsyncIterator<TInput>(asyncIterable: AsyncIterableIterator<TInput>, onError: (err: unknown) => void): AsyncIterableIterator<TInput>;
18
+ export declare function finalAsyncIterator<TInput>(asyncIterable: AsyncIterable<TInput>, onFinal: () => void): AsyncIterableIterator<TInput>;
19
+ export declare function errorAsyncIterator<TInput>(asyncIterable: AsyncIterable<TInput>, onError: (err: unknown) => void): AsyncIterableIterator<TInput>;