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.
This PR adds a functor API for
reason-urql
's hooks. The goal of the functor API is to address concerns raised in #128 concerning dynamic variables for mutations, where we want to pass variables at execution time rather than when the hook is ran. This is closer to howurql
actually works – theexecuteMutation
function returned by theuseMutation
hook accepts an optionalvariables
argument that will be applied when the function is called.The functor API would look to consumers like the following:
In addition to adding a functor API for
useMutation
, I also added them foruseQuery
anduseSubscription
. This is more to offer folks the option of using the functor APIs if they like them, since folks coming fromreason-apollo
orreason-apollo-hooks
will likely be most used to that approach.Ideally, I'd love for us to find a way of achieving the above without the use of functors to keep the API simpler, but at this moment I think the functor API gets us closest to how
urql
actually works without sacrificing type inference. I'm very curious to see what people think here.Note: Don't be alarmed by the "breaking build" in these commits. GitHub changed its billing structure and Formidable's plan doesn't give us access to GitHub Actions. So we're going to be switching back to Travis here soon.
cc/ @robinweser tagging you as well to take a peek!