Skip to content

Commit f96492c

Browse files
committed
Rename to @experimental_disableErrorPropagation
1 parent 6409cf6 commit f96492c

File tree

3 files changed

+11
-142
lines changed

3 files changed

+11
-142
lines changed

src/execution/__tests__/onerror-test.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.

src/execution/execute.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ import {
4545
isObjectType,
4646
} from '../type/definition.js';
4747
import {
48-
ErrorAction,
49-
GraphQLOnErrorDirective,
48+
GraphQLDisableErrorPropagationDirective,
5049
GraphQLStreamDirective,
5150
} from '../type/directives.js';
5251
import type { GraphQLSchema } from '../type/schema.js';
@@ -320,9 +319,12 @@ export function executeQueryOrMutationOrSubscriptionEvent(
320319
}
321320

322321
function errorPropagation(operation: OperationDefinitionNode): boolean {
323-
const value = getDirectiveValues(GraphQLOnErrorDirective, operation);
322+
const directiveNode = operation.directives?.find(
323+
(directive) =>
324+
directive.name.value === GraphQLDisableErrorPropagationDirective.name,
325+
);
324326

325-
return value?.action !== ErrorAction.NULL;
327+
return directiveNode === undefined;
326328
}
327329

328330
export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(

src/type/directives.ts

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@ import { toObjMapWithSymbols } from '../jsutils/toObjMap.js';
99

1010
import type { DirectiveDefinitionNode } from '../language/ast.js';
1111
import { DirectiveLocation } from '../language/directiveLocation.js';
12-
import { Kind } from '../language/kinds.js';
1312

1413
import { assertName } from './assertName.js';
1514
import type {
1615
GraphQLArgumentConfig,
1716
GraphQLFieldNormalizedConfigArgumentMap,
1817
GraphQLSchemaElement,
1918
} from './definition.js';
20-
import {
21-
GraphQLArgument,
22-
GraphQLEnumType,
23-
GraphQLNonNull,
24-
} from './definition.js';
19+
import { GraphQLArgument, GraphQLNonNull } from './definition.js';
2520
import { GraphQLBoolean, GraphQLInt, GraphQLString } from './scalars.js';
2621

2722
/**
@@ -282,51 +277,16 @@ export const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({
282277
});
283278

284279
/**
285-
* Possible error handling actions.
280+
* Disables error propagation (experimental).
286281
*/
287-
export const ErrorAction = {
288-
PROPAGATE: 'PROPAGATE' as const,
289-
NULL: 'NULL' as const,
290-
} as const;
291-
292-
// eslint-disable-next-line @typescript-eslint/no-redeclare
293-
export type ErrorAction = (typeof ErrorAction)[keyof typeof ErrorAction];
294-
295-
export const _ErrorAction = new GraphQLEnumType({
296-
name: '_ErrorAction',
297-
description: 'Possible error handling actions.',
298-
values: {
299-
PROPAGATE: {
300-
value: ErrorAction.PROPAGATE,
301-
description:
302-
'Non-nullable positions that error cause the error to propagate to the nearest nullable ancestor position. The error is added to the "errors" list.',
303-
},
304-
NULL: {
305-
value: ErrorAction.NULL,
306-
description:
307-
'Positions that error are replaced with a `null` and an error is added to the "errors" list.',
308-
},
309-
},
310-
});
311-
312-
/**
313-
* Controls how the executor handles errors.
314-
*/
315-
export const GraphQLOnErrorDirective = new GraphQLDirective({
316-
name: 'onError',
317-
description: 'Controls how the executor handles errors.',
282+
export const GraphQLDisableErrorPropagationDirective = new GraphQLDirective({
283+
name: 'experimental_disableErrorPropagation',
284+
description: 'Disables error propagation.',
318285
locations: [
319286
DirectiveLocation.QUERY,
320287
DirectiveLocation.MUTATION,
321288
DirectiveLocation.SUBSCRIPTION,
322289
],
323-
args: {
324-
action: {
325-
type: new GraphQLNonNull(_ErrorAction),
326-
description: 'The action to execute when a field error is encountered.',
327-
default: { literal: { kind: Kind.ENUM, value: 'PROPAGATE' } },
328-
},
329-
},
330290
});
331291

332292
/**

0 commit comments

Comments
 (0)