Bad typing of the execute function #10324
tomashauser
started this conversation in
Docs Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The docs mention the execute function which serves as a lightweight fetch wrapper taking in typed GraphQL queries and returning the result.
TResult
. GraphQL returns the data in a wrapper that always contains thedata
field and usually alsoerrors
. TheTResult
is the contents of thedata
field, not the whole json response.Promise<TResult>
. I'm not sure that this is needed though, so correct me if I'm wrong here.I suggest we edit the return type to
GraphQLResponse<Promise<TResult>>
. This makes it possible to access the data and error fields and also properly maintains that the result is aPromise
.We can then make the example below the execute function use the data like this:
Beta Was this translation helpful? Give feedback.
All reactions