Add generic type parameter to GraphQLError for typed extensions#4480
Open
raymondwang wants to merge 1 commit intographql:16.x.xfrom
Open
Add generic type parameter to GraphQLError for typed extensions#4480raymondwang wants to merge 1 commit intographql:16.x.xfrom
raymondwang wants to merge 1 commit intographql:16.x.xfrom
Conversation
|
|
11463b1 to
670dc7b
Compare
Contributor
|
From my survey of the current code status, for extensions for execution results, library users can type the extensions via a generic parameter, but with all the other extensions, we provide a generic extensions object for each individual extension and library users must cast to their own type or use declaration merging. I am not sure the history here, but I think if declaration merging is good enough for your use case, that would seem the path of least change across the code base. For consistency, can introduce a new type for the execution result extensions and set the default to that. What do you think? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per the spec:
However, the
GraphQLErrortype currently does not expose an option to extend theextensionsfield in the type system. This makes interacting with error extensions tedious, as consumers must explicitly cast theextensionsfor each error manually.Before
After
This could be added to a few other places — I've added it to
ExecutionResult, for instance — but I wanted to get a pulse check on this approach first.