Begin migration to @reasonml-community/graphql-ppx, starting with client.execute* methods. #221
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 beings to address #219. Thanks to @jfrolich and @jeddeloh for their ideas and help here 🙌
Summary
Now that the Reason community is beginning to coalesce around a standard (from what I can tell) for a GraphQL PPX rewriter, we want to ensure
reason-urql
is compatible with that standard. Because this process will lead to breaking changes, I'm planning to roll it into av3
release alongside fixes for #220 and #206.Major Changes
The major breaking changes in this particular PR involve those related to working with the
graphql-ppx
API. Fortunately the changes aren't that wild. Previously we'd do:The new API uses a feature of OCaml called first-class modules to allows us to use a
graphql-ppx
module almost like a regular variable. The new API looks like this:I like this quite a bit more! It would allow us to match
urql
naming a bit more closely as well by changing~request
to~query
if we like.Drawbacks
I'm not sure if you'd necessarily call this a drawback, but this change does make the source less approachable for newcomers. Supporting
graphql-ppx
in this way requires the use of GADTs. Succinctly, GADTs allows us to specify the type of the output of a function based on the type of the input – a great way to handle polymorphism! However, they do take a bit of work to understand. Similarly, first-class modules require some ramping up on to get comfortable with (though I do think they are more approachable than functors)!Next Steps
After this PR gets merged, we can begin moving the hooks APIs over to the use of first-class modules. When that is complete, we'll migrate
urql
to a peerDependency and complete the last steps of v3!