Skip to content

Commit 60b42cc

Browse files
committed
Revert "Elevate ErrorBehavior to be a specified enum"
This reverts commit 726b4ba.
1 parent 726b4ba commit 60b42cc

23 files changed

+68
-131
lines changed

src/__tests__/starWarsIntrospection-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Star Wars Introspection Tests', () => {
3737
{ name: 'Droid' },
3838
{ name: 'Query' },
3939
{ name: 'Boolean' },
40-
{ name: 'ErrorBehavior' },
40+
{ name: '__ErrorBehavior' },
4141
{ name: '__Schema' },
4242
{ name: '__Type' },
4343
{ name: '__TypeKind' },

src/error/ErrorBehavior.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
export type ErrorBehavior = 'NO_PROPAGATE' | 'PROPAGATE' | 'ABORT';
1+
export type GraphQLErrorBehavior = 'NO_PROPAGATE' | 'PROPAGATE' | 'ABORT';
22

3-
export function isErrorBehavior(onError: unknown): onError is ErrorBehavior {
3+
export function isErrorBehavior(
4+
onError: unknown,
5+
): onError is GraphQLErrorBehavior {
46
return (
57
onError === 'NO_PROPAGATE' || onError === 'PROPAGATE' || onError === 'ABORT'
68
);

src/error/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export type {
99
export { syntaxError } from './syntaxError';
1010

1111
export { locatedError } from './locatedError';
12-
export type { ErrorBehavior } from './ErrorBehavior';
12+
export type { GraphQLErrorBehavior } from './ErrorBehavior';

src/execution/execute.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { promiseForObject } from '../jsutils/promiseForObject';
1313
import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
1414
import { promiseReduce } from '../jsutils/promiseReduce';
1515

16-
import type { ErrorBehavior } from '../error/ErrorBehavior';
16+
import type { GraphQLErrorBehavior } from '../error/ErrorBehavior';
1717
import { isErrorBehavior } from '../error/ErrorBehavior';
1818
import type { GraphQLFormattedError } from '../error/GraphQLError';
1919
import { GraphQLError } from '../error/GraphQLError';
@@ -117,7 +117,7 @@ export interface ExecutionContext {
117117
typeResolver: GraphQLTypeResolver<any, any>;
118118
subscribeFieldResolver: GraphQLFieldResolver<any, any>;
119119
errors: Array<GraphQLError>;
120-
errorBehavior: ErrorBehavior;
120+
errorBehavior: GraphQLErrorBehavior;
121121
}
122122

123123
/**
@@ -133,6 +133,7 @@ export interface ExecutionResult<
133133
> {
134134
errors?: ReadonlyArray<GraphQLError>;
135135
data?: TData | null;
136+
onError?: GraphQLErrorBehavior;
136137
extensions?: TExtensions;
137138
}
138139

@@ -163,7 +164,7 @@ export interface ExecutionArgs {
163164
*
164165
* @experimental
165166
*/
166-
onError?: ErrorBehavior;
167+
onError?: GraphQLErrorBehavior;
167168
/** Additional execution options. */
168169
options?: {
169170
/** Set the maximum number of errors allowed for coercing (defaults to 50). */

src/graphql.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { isPromise } from './jsutils/isPromise';
33
import type { Maybe } from './jsutils/Maybe';
44
import type { PromiseOrValue } from './jsutils/PromiseOrValue';
55

6-
import type { ErrorBehavior } from './error/ErrorBehavior';
6+
import type { GraphQLErrorBehavior } from './error/ErrorBehavior';
77

88
import { parse } from './language/parser';
99
import type { Source } from './language/source';
@@ -76,7 +76,7 @@ export interface GraphQLArgs {
7676
*
7777
* @experimental
7878
*/
79-
onError?: ErrorBehavior;
79+
onError?: GraphQLErrorBehavior;
8080
}
8181

8282
export function graphql(args: GraphQLArgs): Promise<ExecutionResult> {

src/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ export {
5555
GraphQLString,
5656
GraphQLBoolean,
5757
GraphQLID,
58-
// Standard GraphQL Enums
59-
specifiedEnumTypes,
60-
GraphQLErrorBehavior,
6158
// Int boundaries constants
6259
GRAPHQL_MAX_INT,
6360
GRAPHQL_MIN_INT,
@@ -82,6 +79,7 @@ export {
8279
__InputValue,
8380
__EnumValue,
8481
__TypeKind,
82+
__ErrorBehavior,
8583
// Meta-field definitions.
8684
SchemaMetaFieldDef,
8785
TypeMetaFieldDef,
@@ -109,7 +107,6 @@ export {
109107
isRequiredArgument,
110108
isRequiredInputField,
111109
isSpecifiedScalarType,
112-
isSpecifiedEnumType,
113110
isIntrospectionType,
114111
isSpecifiedDirective,
115112
// Assertions
@@ -399,7 +396,7 @@ export {
399396
} from './error/index';
400397

401398
export type {
402-
ErrorBehavior,
399+
GraphQLErrorBehavior,
403400
GraphQLErrorOptions,
404401
GraphQLFormattedError,
405402
GraphQLErrorExtensions,

src/type/__tests__/introspection-test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('Introspection', () => {
102102
inputFields: null,
103103
interfaces: null,
104104
kind: 'ENUM',
105-
name: 'ErrorBehavior',
105+
name: '__ErrorBehavior',
106106
possibleTypes: null,
107107
specifiedByURL: null,
108108
},
@@ -213,7 +213,7 @@ describe('Introspection', () => {
213213
name: null,
214214
ofType: {
215215
kind: 'ENUM',
216-
name: 'ErrorBehavior',
216+
name: '__ErrorBehavior',
217217
ofType: null,
218218
},
219219
},
@@ -1059,7 +1059,7 @@ describe('Introspection', () => {
10591059
name: null,
10601060
ofType: {
10611061
kind: 'ENUM',
1062-
name: 'ErrorBehavior',
1062+
name: '__ErrorBehavior',
10631063
ofType: null,
10641064
},
10651065
},

src/type/__tests__/predicate-test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ import {
6565
isDirective,
6666
isSpecifiedDirective,
6767
} from '../directives';
68-
import { GraphQLErrorBehavior, isSpecifiedEnumType } from '../enums';
6968
import {
7069
GraphQLBoolean,
7170
GraphQLFloat,
@@ -167,16 +166,6 @@ describe('Type predicates', () => {
167166
});
168167
});
169168

170-
describe('isSpecifiedEnumType', () => {
171-
it('returns true for specified enums', () => {
172-
expect(isSpecifiedEnumType(GraphQLErrorBehavior)).to.equal(true);
173-
});
174-
175-
it('returns false for custom scalar', () => {
176-
expect(isSpecifiedEnumType(EnumType)).to.equal(false);
177-
});
178-
});
179-
180169
describe('isObjectType', () => {
181170
it('returns true for object type', () => {
182171
expect(isObjectType(ObjectType)).to.equal(true);

src/type/__tests__/schema-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ describe('Type System: Schema', () => {
296296
'ASub',
297297
'Boolean',
298298
'String',
299-
'ErrorBehavior',
299+
'__ErrorBehavior',
300300
'__Schema',
301301
'__Type',
302302
'__TypeKind',

src/type/definition.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
1414
import { suggestionList } from '../jsutils/suggestionList';
1515
import { toObjMap } from '../jsutils/toObjMap';
1616

17-
import type { ErrorBehavior } from '../error/ErrorBehavior';
17+
import type { GraphQLErrorBehavior } from '../error/ErrorBehavior';
1818
import { GraphQLError } from '../error/GraphQLError';
1919

2020
import type {
@@ -990,7 +990,7 @@ export interface GraphQLResolveInfo {
990990
readonly operation: OperationDefinitionNode;
991991
readonly variableValues: { [variable: string]: unknown };
992992
/** @experimental */
993-
readonly errorBehavior: ErrorBehavior;
993+
readonly errorBehavior: GraphQLErrorBehavior;
994994
}
995995

996996
/**

0 commit comments

Comments
 (0)