Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rh389-feature/graphql-15-compat'
- Loading branch information
Showing
20 changed files
with
114 additions
and
1,158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { GraphQLError, TypeInfo, ValidationContext } from "graphql"; | ||
import { GraphQLSchema } from "graphql/type/schema"; | ||
import { DocumentNode } from "graphql/language/ast"; | ||
|
||
/** | ||
* This class is used to test that validation errors are raised correctly | ||
* | ||
* A compatibility layer is necessary to support graphql versions since 15.0.0 | ||
* *as well as* versions prior to 14.5.0 with the same test, because older | ||
* versions of `ValidationContext` only expose a `getErrors` API and newer | ||
* versions only expose the `onError` API via a fourth constructor argument. | ||
* | ||
* Once we drop support for versions older than 14.5.0 this layer will no | ||
* longer be necessary and tests may use `ValidationContext` directly using the | ||
* `onError` API. | ||
*/ | ||
export class CompatibleValidationContext extends ValidationContext { | ||
private errors: GraphQLError[] = [] | ||
|
||
constructor(schema: GraphQLSchema, ast: DocumentNode, typeInfo: TypeInfo) { | ||
super(schema, ast, typeInfo, err => this.errors.push(err)); | ||
} | ||
|
||
getErrors(): ReadonlyArray<GraphQLError> { | ||
// @ts-ignore | ||
return super.getErrors ? super.getErrors() : this.errors | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.