-
-
Notifications
You must be signed in to change notification settings - Fork 810
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(federation): prevent execution if query plan fails
- Loading branch information
Showing
9 changed files
with
112 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@graphql-tools/federation': patch | ||
'@graphql-tools/delegate': patch | ||
--- | ||
|
||
Fail on query planning phase if the query plan is not successful before the actual execution |
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,44 @@ | ||
--- | ||
'@graphql-tools/executor': minor | ||
--- | ||
|
||
Ability to create critical errors that prevents to return a partial results | ||
|
||
```ts | ||
import { CRITICAL_ERROR } from '@graphql-tools/executor'; | ||
|
||
const schema = makeExecutableSchema({ | ||
typeDefs: ` | ||
type Query { | ||
hello: String | ||
} | ||
`, | ||
resolvers: { | ||
Query: { | ||
hello: () => new GraphQLError('Critical error', { | ||
extensions: { | ||
[CRITICAL_ERROR]: true | ||
} | ||
}) | ||
} | ||
} | ||
}); | ||
``` | ||
|
||
This will prevent to return a partial results and will return an error instead. | ||
|
||
```ts | ||
const result = await execute({ | ||
schema, | ||
document: parse(`{ hello }`) | ||
}); | ||
|
||
expect(result).toEqual({ | ||
errors: [ | ||
{ | ||
message: 'Critical error', | ||
} | ||
], | ||
data: null, // Instead of { hello: null } | ||
}); | ||
``` |
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
File renamed without changes.
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