-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
Announcement: urql v4 Major Releases #3114
Comments
File upload seems to be broken as I found the key |
@negezor: I just checked this against our example for file uploads and it works just fine 😅 (although noting that the example API currently is down for uploads). The behaviour of variables serialisation hasn't changed, so However, as long as a (btw, If you'd like help, please open an issue, discussion or feel free to chat on Discord ✌️) Edit: Ah, you know what; I didn't realise this but I believe the input file Edit 2: Fix is out. I think it's pretty trivial, so I'll just yeet it out quickly 😄 |
@kitten Specifically, in my case, this does not work, I get a response from the server: If you look at the specification, null is expected there Using the old |
Again, please do stick to issues please for bug reports 😅 |
My issue #3144 was closed and redirected here. I still don't understand what needs to be done to resolve the issue I am having. I don't think the docs have been updated. I'll be forced to roll back until I have a clear view of what needs to be done. In the meantime, if anyone else has a similar issue (and using yarn), I resolved it with this in package.json "resolutions": {
"@urql/core": "3.2.2"
}, Be sure to remove |
@hawkeye64 your issue was not closed, just fyi, as stated there it was converted to a Q&A discussion: #3145 The section there I've linked you is the "No More Default Exchanges" section on this page. The section up here will tell you what to do, namely to specify an explicit exchanges array option when creating the client, as the default has been removed for better treeshaking when the defaults aren't in use. So, pass A resolution is not good practice in this case at least, and while it should work it will force the bindings to work with a core package that is out of their explicitly set range. Furthermore, even if your resolution is in range, you'll from then on often miss out on updates and many tools will fail to notify you about them or override the resolution. (Also for clarity's sake, this is Yarn's syntax; other package managers may have other solutions for resolutions, so careful if someone here copies this) To also repeat this here, since it has come up in other issues. Each package manager supports upgrading and updating. When updating a bindings package (e.g. for React, Vue, or urql) with the "upgrade" command or "add/install" commands, If not, all package managers have an "update" command, to update a transitive dependency like Afterwards, you may accidentally have old versions of
This is always in the migration guides and we add these commands when we bump out of range and duplicates become more likely. Hope this clarifies some FAQs 😸 |
@kitten Fair enough on converting it to a discussion. I guess GitHub closes it and then recreates it as a discussion. Thanks for the info. I'll have to read up more on the exchanges. |
Source documentation is here: urql-graphql/urql#3114 (comment)
fix `Cannot read properties of undefined (reading 'reduceRight')` error according v4 as mention in `https://github.com/urql-graphql/urql/issues/3114#no-more-defaultexchanges-`
It’s only been seven months since we’ve launched our urql v3 batch of major releases, but today, we’re even more excited to talk about our next batch of urql v4 releases!
What happened in the last episode of
urql
?Expand for a quick summary of changes made in the prior urql v3 releases.
General changes
Variables
generics typings across our bindingsgraphql
imports have been removed since they caused build issues in rare cases@urql/core
ClientOptions
are now reflects as properties on theClient
createOperationContext
method was removed from theClient
ClientOptions.url
must now always be a string and defined@urql/exchange-graphcache
optimistic
functionsoptimistic
functions now may return objects that contain more, nestedoptimistic
functionsoptimistic
functionsBack in our last batch of major releases, little changed and little broke, relatively speaking. We chose to save up larger refactors and changes for when we'd be able to ship some big improvements along with them; and today's the day!
Table of Contents
defaultExchanges
(💥)subscriptionExchange
(💥)hasNext
,stale
, and multiple results (💥)@urql/core
ditches thegraphql
package (💥)graphql
library?graphql
myself?dedupExchange
(🦋)@urql/svelte
's missing subscription handler (💥)urql
and@urql/preact
no longer create a default Client (💥)After upgrading with your favourite package manager you may have duplicates of several packages, which you can fix by trying out the following command:
For the full release notes and changelogs, check the Release PR.
Sponsoring and Discord
In case you've missed it or don't come by the repository often, Hiya 👋 Welcome back!
We're also here to say that we now accept sponsorships on GitHub: https://github.com/sponsors/urql-graphql
Sponsorships are important to us of course, but they will take more of a central role in how this project sustains itself moving forward. We have more moving parts now than ever and want to dedicate as much time to the
urql
community as possible! 💖We also now have an easier way to ask help and chat with us and other contributors, by joining our Discord: https://urql.dev/discord
Building a community on Discord allows us to also talk about and support you with our related projects and other libraries, like
wonka
andgraphql-web-lite
!TSDocs... TSDocs everywhere (✨)
We’re replacing our API docs pages with TSDocs! 📚
Every one of our public API will now come with inline comments, called TSDocs, which give you a summary of what the API does, and they're in our opinion a big step forward from clunky, old API docs:
We hope that this will ease the learning curve of having to learn
urql
's APIs, and reduces common misconceptions and questions from popping up early on, when you're starting to adopturql
.We're preparing to launch a web app that allows you to browse the APIs of our packages as well. More news on this soon...
No more
defaultExchanges
(💥)In prior versions we didn't need you to explicitly pass
exchanges
to the client we would automatically make these to be[dedupExchange, cacheExchange, fetchExchange]
.We have now removed this and need you to explicitly pass us the exchanges, in doing so we have reduced the default budndle size for folks not using these exchanges. You can fix the missing exchanges by doing the following:
A rewrite of our default fetch/HTTP transport (✨)
urql
's defaultfetchExchange
used to come with a humble but extensible set of features. In@urql/core@^3.0.0
, we're moving and adding more features into the core package:@urql/exchange-multipart-fetch
(a now deprecated package)text/event-stream
protocol (also known as GraphQL SSE for Incremental Delivery responses.multipart/mixed
response protocol is still supported as before.With
multipart/mixed
andtext/event-stream
, we’re now supporting more protocol options for APIs, which enable APIs to use more transport methods for@defer
,@stream
,@live
, and subscriptions and give API authors more options without having to add custom exchanges tourql
.Persisted Query Support is changing (✨)
As for, (Automatic) Persisted Queries support, this used to be implemented using the
@urql/exchange-persisted-fetch
library, which didn’t work for thesubscriptionExchange
, as it simply made a fetch/HTTP request on its own.Instead, we’re deprecating the package and replacing it with
@urql/exchange-persisted
.The API of this package will match the old one exactly, but it will only annotate query (and optionally, mutation) operations to have persisted query extensions on them.
Source Code
File Upload Support goes built-in (✨)
Multipart File Uploads are now supported in
@urql/core
and are activated when your variables contain aFile
or aBlob
.You won't have to install
@urql/exchange-multipart-fetch
anymore and this package has been deprecated.hasNext
,stale
, and multiple results (💥)@urql/core
contains two subtle yet important changes to howOperationResult
s are defined and delivered in response toOperation
s.In this version we're tightening our guarantees around results that are marked as
hasNext: true
and when results are marked asstale: true
.Any API transport that delivers multiple results may mark its
ExecutionResult
s withhasNext: true
. This for instance happens when:@defer
-ed or@streasm
-ed results.@live
query is delivering updated results.When the
Client
seeshasNext
, it nows consistently knows to expect updated results.Furthermore,
stale: true
, as before, indicates that theClient
expects an updated API result for a given query soon. For instance, this may mean that an operation is being sent and will replace an existing result with a new one as soon as the API responds.Knock-on changes to the
subscriptionExchange
(💥)The
subscriptionExchange
had to be changed a little to accommodate the new@urql/exchange-persisted
support above and to fix some issues we were seeing in how it's being used.Internally,
@urql/core/internal
contains amakeFetchBody
function (and other fetch utilities that are reusable) which constructs the JSON data that will be sent to the GraphQL API. This function is aware of how to handle persisted queries.Unfortunately, our
subscriptionExchange
'sforwardSubscription
function was instead accepting anOperation
-like structure. That's why this has changed to now accept aFetchBody
as the first argument.This helps transports like
graphql-ws
to function correctly, as they pass this input on 1:1 without filtering it, expecting it to basically be like ourFetchBody
structure, ready to be accepted by GraphQL APIs.If you were previously relying on this first argument having a
context
property — theOperationContext
— we're now instead passing the entireOperation
as a second argument toforwardSubscription
@urql/core
ditches thegraphql
package (💥)@urql/core
doesn’t rely on a peer dependency ongraphql
anymore.When you installed
@urql/core@^3.2.2
, you will at least add17.3kB
(gzip) to your bundlesize, since it not only includes its own code but also parts ofgraphql
(andwonka
, our stream utilities.) We wouldn't consider this bad, but we can do better.In
@urql/core@^4.0.0
, we’re replacing the parts ofgraphql
we used to use (which includesparse
,print
, andGraphQLError
). Instead, we’re now relying on a homegrown, spec-compliant implementation of the GraphQL query language, the@0no-co/graphql.web
package.This small change means
@urql/core@^4.0.0
will only add at most9.9kB
(gzip) to your bundlesize!How does this affect TypeScript and the standard
graphql
library?Any output from
@0no-co/graphql.web
is tested (with 100% test coverage; if this puts you at ease) to be compatible with the reference output from thegraphql
library. This means all ASTs will remain compatible.When you have the standard
graphql
library installed, all@urql/core
APIs will also automatically accept types fromgraphql
(e.g.import('graphql').DocumentNode
) and@0no-co/graphql.web
will additionally switch to usinggraphql
’s AST types as well.How do I reduce my bundlesize if I depend on
graphql
myself?If any of the rest of your app uses
graphql
already, we do have another trick up our sleeves, if you want to avoid a slight increase in bundlesize of2kB
(gzip).You can use the
graphql-web-lite
package and aliasgraphql
imports to it.The
graphql-web-lite
repostory contains instructions using which you can alias thegraphql
package in just a few minutes! ⏲️ We hope, even faster than it’d take you to make a coffee.The
graphql-web-lite
package is built to slim down the default build ofgraphql
, and is built against thegraphql
library, but also uses@0no-co/graphql.web
internally. Once you’ve aliasedgraphql
tographql-web-lite
, you’ll continue to be able to use its API, but keep size to a minimum.@0no-co/graphql.web
graphql-web-lite
Easier core-usage (🦋)
Sources now have
.then()
set which means that you can leverageawait
by default on sources returned by urql, this enable you to performawait client.mutation()
.Sources also have
.subscribe()
now which accepts a callback that allows you to see all values passed back from theexchanges
.No more need for the
dedupExchange
(🦋)The
dedupExchange
has long been needed in@urql/core
as a way to avoid sending multiple requests for operations subscribed to from multiple locations. This has now been added as default behavior to the client.This means you can drop the
dedupExchange
all together, the exchange will be a noop in this major.Integrations
Fixing
@urql/svelte
's missing subscription handler (💥)When refactoring our Svelte bindings in a prior revision, we accidentally misplaced the
handleSubscription
support and it wasn't possible to merge subscription events like on our other bindings.This has now been fixed and the
subscriptionStore
accepts it again as a second argument.urql
and@urql/preact
no longer create a default Client (💥)In prior versions,
urql
and@urql/preact
would create a default Client when noProvider
was used in the tree. This by default would send GraphQL requests to/graphql
. This wasn't really useful as you would need to add aProvider
anyway when you went to production. We have removed this in this major and instead throw an error when we miss aProvider
.The text was updated successfully, but these errors were encountered: