Skip to content

Commit 331790e

Browse files
committed
ValidationContext: Remove deprecated 'getErrors' and make 'onEr… (graphql#2130)
1 parent 84cb5b7 commit 331790e

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

src/validation/ValidationContext.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,24 @@ type VariableUsage = {|
4141
*/
4242
export class ASTValidationContext {
4343
_ast: DocumentNode;
44-
_onError: ?(err: GraphQLError) => void;
45-
_errors: Array<GraphQLError>;
44+
_onError: (err: GraphQLError) => void;
4645
_fragments: ?ObjMap<FragmentDefinitionNode>;
4746
_fragmentSpreads: Map<SelectionSetNode, $ReadOnlyArray<FragmentSpreadNode>>;
4847
_recursivelyReferencedFragments: Map<
4948
OperationDefinitionNode,
5049
$ReadOnlyArray<FragmentDefinitionNode>,
5150
>;
5251

53-
constructor(ast: DocumentNode, onError?: (err: GraphQLError) => void): void {
52+
constructor(ast: DocumentNode, onError: (err: GraphQLError) => void): void {
5453
this._ast = ast;
55-
this._errors = [];
5654
this._fragments = undefined;
5755
this._fragmentSpreads = new Map();
5856
this._recursivelyReferencedFragments = new Map();
5957
this._onError = onError;
6058
}
6159

6260
reportError(error: GraphQLError): void {
63-
this._errors.push(error);
64-
if (this._onError) {
65-
this._onError(error);
66-
}
67-
}
68-
69-
// @deprecated: use onError callback instead - will be removed in v15.
70-
getErrors(): $ReadOnlyArray<GraphQLError> {
71-
return this._errors;
61+
this._onError(error);
7262
}
7363

7464
getDocument(): DocumentNode {
@@ -175,7 +165,7 @@ export class ValidationContext extends ASTValidationContext {
175165
schema: GraphQLSchema,
176166
ast: DocumentNode,
177167
typeInfo: TypeInfo,
178-
onError?: (err: GraphQLError) => void,
168+
onError: (err: GraphQLError) => void,
179169
): void {
180170
super(ast, onError);
181171
this._schema = schema;

tstypes/validation/ValidationContext.d.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ type VariableUsage = {
3333
* validation rule.
3434
*/
3535
export class ASTValidationContext {
36-
constructor(ast: DocumentNode);
36+
constructor(ast: DocumentNode, onError: (err: GraphQLError) => void);
3737

3838
reportError(error: GraphQLError): undefined;
3939

40-
getErrors(): ReadonlyArray<GraphQLError>;
41-
4240
getDocument(): DocumentNode;
4341

4442
getFragment(name: string): Maybe<FragmentDefinitionNode>;
@@ -54,7 +52,7 @@ export class SDLValidationContext extends ASTValidationContext {
5452
constructor(
5553
ast: DocumentNode,
5654
schema: Maybe<GraphQLSchema>,
57-
onError?: (err: GraphQLError) => void,
55+
onError: (err: GraphQLError) => void,
5856
);
5957

6058
getSchema(): Maybe<GraphQLSchema>;
@@ -67,7 +65,7 @@ export class ValidationContext extends ASTValidationContext {
6765
schema: GraphQLSchema,
6866
ast: DocumentNode,
6967
typeInfo: TypeInfo,
70-
onError?: (err: GraphQLError) => void,
68+
onError: (err: GraphQLError) => void,
7169
);
7270

7371
getSchema(): GraphQLSchema;

0 commit comments

Comments
 (0)