-
-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2edc713
commit df16233
Showing
1 changed file
with
35 additions
and
0 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,35 @@ | ||
Release type: minor | ||
|
||
Added new `PartialResultsExtension` to allow adding exceptions to `info.context.partial_errors` to get added to the result after execution, allowing users to add errors to the errors array from a field resolver while still resolving that field. | ||
|
||
**Usage example:** | ||
|
||
```python | ||
import strawberry | ||
from strawberry.extensions import PartialResultsExtension | ||
|
||
schema = strawberry.Schema(Query, extensions=[PartialResultsExtension]) | ||
|
||
# ... | ||
|
||
|
||
@strawberry.field | ||
def query(self, info) -> bool: | ||
info.context.partial_errors.append(Exception("Partial failure")) | ||
return True | ||
``` | ||
|
||
Results: | ||
|
||
```json | ||
{ | ||
"data": { | ||
"query": true | ||
}, | ||
"errors": [ | ||
{ | ||
"message": "Partial failure" | ||
} | ||
] | ||
} | ||
``` |