Major Changes
-
Remove
defaultExchanges
from@urql/core
and makeexchanges
a required property onClient
construction.
In doing so we make theurql
package more tree-shakeable as the three default exchanges are in no code paths
meaning they can be removed if not used.
A migration would look as follows if you are currently creating a client without exchangesimport { createClient, cacheExchange, fetchExchange } from '@urql/core'; const client = createClient({ url: '', exchanges: [cacheExchange, fetchExchange], });
Submitted by @JoviDeCroock (See #3033)
-
Update
subscriptionExchange
to receiveFetchBody
instead. In the usual usage ofsubscriptionExchange
(for instance withgraphql-ws
) you can expect no breaking changes. However, thekey
andextensions
field has been removed and instead theforwardSubscription
function receives the fullOperation
as a second argument
Submitted by @kitten (See #3054) -
Remove dependence on
graphql
package and replace it with@0no-co/graphql.web
, which reduces the default bundlesize impact ofurql
packages to a minimum. All types should remain compatible, even if you usegraphql
elsewhere in your app, and if other dependencies are usinggraphql
you may alias it tographql-web-lite
Submitted by @kitten (See #3097) -
Update
OperationResult.hasNext
andOperationResult.stale
to be required fields. If you have a custom exchange creating results, you'll have to add these fields or use themakeResult
,mergeResultPatch
, ormakeErrorResult
helpers
Submitted by @kitten (See #3061) -
Remove
getOperationName
export from@urql/core
Submitted by @kitten (See #3062)
Minor Changes
- Return a new
OperationResultSource
from allClient
methods (which replacesPromisifiedSource
on shortcut methods). This allows not onlytoPromise()
to be called, but it can also be used as an awaitablePromiseLike
and has a.subscribe(onResult)
method aliasing the subscribe utility fromwonka
Submitted by @kitten (See #3060) - Update
subscriptionExchange
to support incremental results out of the box. If a subscription proactively completes, results are also now updated withhasNext: false
Submitted by @kitten (See #3055) - Implement
text/event-stream
response support. This generally adheres to the GraphQL SSE protocol and GraphQL Yoga push responses, and is an alternative tomultipart/mixed
Submitted by @kitten (See #3050) - Implement GraphQL Multipart Request support in
@urql/core
. This adds the File/Blob upload support to@urql/core
, which effectively deprecates@urql/exchange-multipart-fetch
Submitted by @kitten (See #3051) - Support
GraphQLRequest.extensions
as spec-extensions input to GraphQL requests
Submitted by @kitten (See #3054) - Allow subscriptions to be handled by the
fetchExchange
whenfetchSubscriptions
is turned on
Submitted by @kitten (See #3106) - Deprecate the
dedupExchange
. The functionality of deduplicating queries and subscriptions has now been moved into and absorbed by theClient
.
Previously, theClient
already started doing some work to share results between
queries, and to avoid dispatching operations as needed. It now only dispatches operations
strictly when thededupExchange
would allow so as well, moving its logic into the
Client
Submitted by @kitten (See #3058)
Patch Changes
- Deduplicate operations as the
dedupExchange
did; by filtering out duplicate operations until either the original operation has been cancelled (teardown) or a first result (withouthasNext: true
) has come in
Submitted by @kitten (See #3101) ⚠️ Fix source maps included with recently published packages, which lost theirsourcesContent
, including additional source files, and had incorrect paths in some of them
Submitted by @kitten (See #3053)- Allow
makeOperation
to be called with a partialOperationContext
when it’s called to copy an operation. When it receives anOperation
as a second argument now, the third argument, the context, will be spread into the prioroperation.context
Submitted by @kitten (See #3081) - Move
multipart/mixed
to end ofAccept
header to avoid cauing Yoga to unnecessarily use it
Submitted by @JoviDeCroock (See #3039) - Upgrade to
wonka@^6.3.0
Submitted by @kitten (See #3104) - Update
Exchange
contract andcomposeExchanges
utility to remove the need to manually callshare
on either incomingSource<Operation>
orforward()
’sSource<OperationResult>
. This is now taken care of internally incomposeExchanges
and should make it easier for you to create custom exchanges and for us to explain them
Submitted by @kitten (See #3082) - Add support for
graphql
’s built-inTypedQueryDocumentNode
typings for type inference
Submitted by @kitten (See #3085) - Add missing type exports of SSR-related types (
SerializedResult
,SSRExchangeParams
,SSRExchange
, andSSRData
) to@urql/core
's type exports
Submitted by @kitten (See #3079) - Allow any object fitting the
GraphQLError
shape to rehydrate without passing through aGraphQLError
constructor inCombinedError
Submitted by @kitten (See #3087) - Add missing
hasNext
andstale
passthroughs on caching exchanges
Submitted by @kitten (See #3059) ⚠️ Fix incremental results not mergingerrors
from subsequent non-incremental results
Submitted by @kitten (See #3055)- Add logic for
request.extensions.persistedQuery
to@urql/core
to omit sendingquery
as needed
Submitted by @kitten (See #3057) ⚠️ Fix incorrect operation name being picked from queries that contain multiple operations
Submitted by @kitten (See #3062)- Replace fetch source implementation with async generator implementation, based on Wonka's
fromAsyncIterable
.
This also further hardens our support for the "Incremental Delivery" specification and
refactors its implementation and covers more edge cases
Submitted by @kitten (See #3043) - Ensure network errors are always issued with
CombinedError
s, while downstream errors are re-thrown
Submitted by @kitten (See #3063) - Refactor
Client
result source construction code and allow multiple mutation
results, ifresult.hasNext
on a mutation result is set totrue
, indicating
deferred or streamed results
Submitted by @kitten (See #3102) - Remove dependence on
import { visit } from 'graphql';
with smaller but functionally equivalent alternative
Submitted by @kitten (See #3097)