-
-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
urql v3 Major Releases: ES2015+ and more! #2621
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Edit: We previously left this issue unlocked for quick feedback, but realised, it's likely better to lock it, for notices like the below 😅 Please open an issue if you find a regression or issue. Patch NotesWe had a couple of reports of regressions, which have been addressed in the last few days over patch releases (Thanks for the reports!).
|
As part of the latest major releases across all packages we'd like to highlight some of the differences and provide some context and instructions around this release!
Backwards Compatibility
urql
has always been architected to be a "stable core" project. This meant that the architecture, as we first set it has seen very little change since the inception of the project.We still stand by this and would like to highlight that the coming major releases still remain mostly backwards compatible.
We make some exceptions here, and all breaking changes are listed later. However, while Wonka has been updated to v6, all your exchanges and usages of the
Client
should mostly remain unchanged!While we're avoiding breaking changes as much as possible (and even more so when it comes to our core architecture and protocols), we're taking this opportunity to introduce some breakage to clean up old behaviour we wanted to adjust and tweak for a while.
First up, we do recommend you to upgrade all packages at once, however, you'll also able to upgrade partially. All exchanges and packages remain intercompatible across versions, and you'd only be duplicating the
wonka
package.Client and Exchanges
No internal API contracts have been broken, and exchanges and how they interact with the
Client
still remain the same.Wonka and Streams
If you only upgrade some packages you may temporarily have two installations of
wonka
, namelywonka@4.0.15
andwonka@6.0.0
.Wonka is a streaming library, inspired by the Callbag specification, similar to Observables, but written to be more minimal and small in size. It drives our internal logic in the
Client
, how you interact with it, and how exchanges work.Both versions are 100% intercompatible and can coexist in the same app. Its internal data structures and API contracts have also not changed.
Wonka has been rewritten in TypeScript to ensure its future longevity and make it more beginner friendly to new contributors. It was previously written in ReScript/ReasonML, an OCaml derivative and compiled with BuckleScript to JavaScript.
Breaking Changes
We'd like to take a second to highlight the changes that definitely are breaking and that you should take special note of.
Goodbye IE11 / Targeting ES2015
Most importantly, in this batch of releases, we're deprecating our support for Internet Explorer 11 and are instead targeting ES2015+ from now on. This will likely not affect you to much.
If you want to compare what we support to what you support, we're basically sticking to evergreen browsers with some exceptions. In a browserslist rules format this looks like this:
The tl;dr of the above is that we support ES6 / ES2015 and that you should expect our code to not work in Internet Explorer 11 any longer. Other browsers like Chromium, Firefox, and Safari are therefore unaffected.
Stricter Variable Types
Previously, if you've used type generatords (like GraphQL Code Generator with a React hooks output for
TypedDocumentNode
s) you were unfortunately able to leave outvariables
from your GraphQL operations when passing in thequery
argument.This was a mistake and we're explicitly removing this behaviour. We're now enforcing
client.query(query, variables)
to require variables when thequery
is typed.Graphcache Optimistic Updates
When writing optimistic updates, you previously had to match your optimistic objects to the field aliases of the mutation that you defined. This was our previous mechanism to ensure that you could support multiple mutations with different selection sets.
This was a poor workaround and instead, we now properly look every field up by its name in your optimistic objects, as you'd expect, since it matches the behaviour of resolvers.
You may still support multiple mutations with different selection sets by passing in nested optimistic functions in your optimistic objects! In short, this is now possible:
Graphcache's Offline Rehydration
Previously, Graphcache would block all operations while it's rehydrating from its offline storage. Our default storage strategy is based on IndexedDB and your alternative storages (for instance for React Native via
@urql/storage-rn
) may also be asynchronous.To deal with this we used to queue up operations and would only allow execution to continue once rehydration was complete. However, this made server-side rendering rehydration impossible, as it'd interfere with the first render.
We now instead eagerly execute operations, even sending network requests as necessary and "race" the offline storage against network requests.
Slimming down the
Client
@urql/core
'sClient
, the centre of all GraphQL operations, previously had a lot of properties and methods it didn't need anymore, which were leftovers of its first implementation, believe it or not.Since, they weren't used a lot and are just sitting there, waiting to be monkey-patched in unintended ways, and are just adding to our bundle-size, we've removed them. They were already not documented before, but we still waited for a major release to fully get rid of them.
The properties that are now gone are:
Client.createOperationContext()
Client.url
Client.fetch
Client.fetchOptions
Client.maskTypename
Client.preferGetMethod
Client.requestPolicy
Accept for the first one here, as you can see, all of these were
ClientOptions
that were copied over to theClient
instance and could be modified on the fly. This wasn't an intentional feature, and we now recommend you to instead use the new@urql/context
'scontextExchange
instead, if you reply on updating any of theOperationContext
options dynamically.ClientOptions.url is assumed to be a URL
In previous versions of
urql
we refrained from doing anything fancy to theurl
option that was passed in. It'd simplt end up being whatfetch(url)
would be called with.However, when we in the past introduced
preferGetMethod
and@urql/exchange-persisted-fetch
this meant thatGET
methods were becoming part of@urql/core
. This in turn meant that URL manipulation became necessary.In this major release of
@urql/core
we've switched over to using the Web Standard built-insURL
andURLSearchParams
. This is less error prone. (Previously we didn't supportpreferGetMethod
being enabled while search parameters were passed toClientOptions.url
, for instance)As the name implies,
ClientOptions.url
was always meant to be a qualified URL, but'/graphql'
(in fact, not a full URL) made its way into several parts of the documentation.We do in fact recommend to always construct a full URL string before passing it to
urql
.At the very least, passing
'/graphql'
can be replaced (when no server-side use is involved) withnew URL('/graphql', document.location.origin).toString()
.Edit: We forgot to mention this breaking change on our list currently. But you'll only run into it if you're using GET methods with GraphQL
Removing Granular Imports
Previously, we used to resolve imports from
graphql
in our output bundles to granular imports. This meant that our bundles could contain imports like:While this was great for bundlesize, at least for bundlers that failed at correctly treeshaking
graphql
, it wasn't great for our Node.js support.That's why we're removing this, and if you rely on treeshaking to work correctly, please make sure that your bundler is able to only leave around the parts of
graphql
that you're actually using.Alternatively, you could alias
graphql
in production tographql-web-lite
.The text was updated successfully, but these errors were encountered: