- Remove
addMetadata
transform where we'd strip out metadata for production environments, this particularly affectsOperationResult.context.metadata.cacheOutcome
Submitted by @alpavlove (See #3714)
⚠️ FixdeepMerge
regression on array values Submitted by @JoviDeCroock (See #3696)
- Remove
for-of
syntax from@urql/core
helpers for JSC memory reduction Submitted by @kitten (See #3690)
- Allow empty error messages when re-hydrating GraphQL errors Submitted by @JoviDeCroock (See #3650)
- Change how we calculate the
OperationKey
to take files into account, before we would encode them tonull
resulting in every mutation with the same variables (excluding the files) to have the same key. This resulted in mutations that upload different files at the same time to share a result in GraphCache Submitted by @JoviDeCroock (See #3601)
- Use
documentId
from persisted documents for document keys, when it's available Submitted by @kitten (See #3575)
⚠️ Fix issue where a reexecute on an in-flight operation would lead to multiple network-requests. For example, this issue presents itself when Graphcache is concurrently updating multiple, inter-dependent queries with shared entities. One query completing while others are still in-flight may lead to duplicate operations being issued Submitted by @JoviDeCroock (See #3573)
⚠️ Fix@ts-ignore
on TypeScript peer dependency import in typings not being applied due to a leading!
character Submitted by @kitten (See #3567)
- Remove deprecated
dedupExchange
Submitted by @JoviDeCroock (See #3520) - Remove deprecated
maskTypename
Submitted by @JoviDeCroock (See #3520)
- Support Apollo Federation's format for subscription results in
multipart/mixed
responses (result properties essentially are namespaced on apayload
key) Submitted by @JoviDeCroock (See #3499) - Add support for sending persisted documents. Any
DocumentNode
with no/empty definitions and adocumentId
property is considered a persisted document. When this is detected adocumentId
parameter rather than aquery
string is sent to the GraphQL API, similar to Automatic Persisted Queries (APQs). However, APQs are only supported via@urql/exchange-persisted
, while support fordocumentId
is now built-in Submitted by @kitten (See #3515)
- Allow
url
to be a plain, non-URL pathname (i.e./api/graphql
) to be used withpreferGetMethod
Submitted by @akrantz01 (See #3514) - Correctly support the
Headers
class being used infetchOptions
Submitted by @JoviDeCroock (See #3505)
- Add back our cache-outcome on the document-cache, this was behind a development flag however in our normalized cache we always add it already Submitted by @JoviDeCroock (See #3464)
⚠️ Fix the defaultcacheExchange
crashing oncache-only
request policies with cache misses due toundefined
results Submitted by @JoviDeCroock (See #3459)
⚠️ Fix incorrect JSON stringification of objects from different JS contexts. This could lead to invalid variables being generated in the Vercel Edge runtime specifically Submitted by @SoraKumo001 (See #3453)
- Try to parse
text/plain
content-type as JSON before bailing out with an error Submitted by @JoviDeCroock (See #3430)
- Implement new
@defer
/@stream
transport protocol spec changes Submitted by @JoviDeCroock (See #3389) - Support non spec-compliant error bodies, i.e. the Shopify API does return
errors
but as an object. Adding a check whether we are really dealing with an Array of errors enables this Submitted by @JoviDeCroock (See #3395) ⚠️ FixpreferGetMethod: 'force' | 'within-url-limit'
not being applied correctly by theClient
Submitted by @Burbenog (See #3403)
⚠️ Fix missingteardown
operation handling in thessrExchange
. This could lead to duplicate network operations being executed Submitted by @kitten (See #3386)
- Explicitly unblock
client.reexecuteOperation
calls to allow stalled operations from continuing and re-executing. Previously, this could cause@urql/exchange-graphcache
to stall if an optimistic mutation led to a cache miss Submitted by @kitten (See #3363)
- Add case for
subscriptionExchange
to handleGraphQLError[]
received in theerror
observer callback. Note: This doesn't strictly check for theGraphQLError
shape and only checks for arrays and receiving errors in theExecutionResult
on thenext
observer callback is preferred and recommended for transports Submitted by @kitten (See #3346)
- Update
formatDocument
to outputFormattedNode
type mapping. The formatter will now annotate added__typename
fields with_generated: true
, place selection nodes' directives onto a_directives
dictionary, and will filter directives to not include"_"
underscore prefixed directives in the final query. This prepares us for a feature that allows enhanced client-side directives in Graphcache Submitted by @kitten (See #3317)
- Add
OperationContext.optimistic
flag as an internal indication on whether a mutation triggered an optimistic update in@urql/exchange-graphcache
'scacheExchange
Submitted by @kitten (See #3308)
- Re-order
maskTypename
to apply masking earlier in the chain Submitted by @kitten (See #3298) ⚠️ FixssrExchange
not formatting query documents usingformatDocument
. Without this call we'd run the risk of not having__typename
available on the client-side when rehydrating Submitted by @kitten (See #3288)- Add deprecation notice for
maskTypename
option. Masking typenames in a result is no longer recommended. It’s only useful when multiple pre-conditions are applied and inferior to mapping to an input object manually Submitted by @kitten (See #3299)
- Add missing
fetchSubscriptions
entry toOperationContext
. The Client’sfetchSubscriptions
now works properly and can be used to execute subscriptions as multipart/event-stream requests Submitted by @kitten (See #3244) ⚠️ FixfetchSource
not working for subscriptions sincehasNext
isn’t necessarily set Submitted by @kitten (See #3244)
- Return
AbortController
invocation to previous behaviour where it used to be more forceful. It will now properly abort outside of when our generator yields results, and hence now also cancels requests again that have already delivered headers but are currently awaiting a response body Submitted by @kitten (See #3239)
- Respect
additionalTypenames
on subscriptions and re-execute queries for them as well, as one would intuitively expect Submitted by @kitten (See #3230) - Update build process to generate correct source maps Submitted by @kitten (See #3201)
- Don't allow
isSubscriptionOperation
option insubscriptionExchange
to includeteardown
operations, to avoid confusion Submitted by @kitten (See #3206)
- Handle
multipart/mixed
variations starting with boundary rather than CRLF and a boundary Submitted by @kitten (See #3172) ⚠️ Fix regression which would disallownetwork-only
operations aftercache-and-network
completed Submitted by @kitten (See #3174)
- Replace
File
andBlob
objects withnull
in variables if multipart request will be started Submitted by @kitten (See #3169) - Strictly deduplicate
cache-and-network
andnetwork-only
operations, while a non-stale response is being waited for Submitted by @kitten (See #3157) ⚠️ Fix boundary stoppingmultipart/mixed
streams when it randomly occurs in response payloads Submitted by @kitten (See #3155)- Improve dispatching of arbitrary operations using
reexecuteOperation
Submitted by @kitten (See #3159)
⚠️ FixhasNext
being defaulted tofalse
when a new subscription event is received on thesubscriptionExchange
that doesn't havehasNext
set Submitted by @kitten (See #3137)
- Handle
fetch
rejections inmakeFetchSource
and properly hand them over toCombinedError
s Submitted by @kitten (See #3131)
⚠️ Fix incremental delivery payloads not merging data correctly, or not handling patches on root results Submitted by @kitten (See #3124)
⚠️ Fix format ofmap
form data field on multipart upload requests. This was erroneously set to a string rather than a string tuple Submitted by @kitten (See #3118)
-
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)
- 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 theClient
Submitted by @kitten (See #3058)
- 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)
⚠️ Fix generated emptyVariables
type as passed to generics, that outputs a type of{ [var: string]: never; }
. A legacy/unsupported version oftypescript-urql
, which wrapsurql
's React hooks, generates empty variables types as the following code snippet, which is not detected:Submitted by @kitten (See #3029)type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }; type Variables = Exact<{ [key: string]: never }>;
- Bump to
@urql/[email protected]
due to invalid3.2.0
release Submitted by @kitten (Seea84268db
)
- Update support for the "Incremental Delivery" payload specification, accepting the new
incremental
property on execution results, as per the specification. This will expand support for newer APIs implementing the more up-to-date specification Submitted by @kitten (See #3007) - Update default
Accept
header to includemultipart/mixed
andapplication/graphql-response+json
. The former seems to now be a defactor standard-accepted indication for support of the "Incremental Delivery" GraphQL over HTTP spec addition/RFC, and the latter is an updated form of the olderContent-Type
of GraphQL responses, so both the old and new one should now be included Submitted by @kitten (See #3007)
- Add TSDoc annotations to all external
@urql/core
APIs Submitted by @kitten (See #2962) ⚠️ Fix subscriptions not being duplicated whenhasNext
isn't set. ThehasNext
field is an upcoming "Incremental Delivery" field. When a subscription result doesn't set it we now set it totrue
manually. This indicates to thededupExchange
that no duplicate subscription operations should be started Submitted by @kitten (See #3015)- Expose consistent
GraphQLRequestParams
utility type from whichGraphQLRequest
s are created in all bindings Submitted by @kitten (See #3022)
- Correctly mark cache-hits from the ssr-exchange, by @JoviDeCroock (See #2872)
⚠️ Fix type-generation, with a change in TS/Rollup the type generation took the paths as src and resolved them into the types dir, by @JoviDeCroock (See #2870)⚠️ Fix regression in@urql/core
'sstringifyDocument
that caused some formatted documents to not be reprinted, by @JoviDeCroock (See #2871)
- Implement
mapExchange
, which replaceserrorExchange
, allowingonOperation
andonResult
to be called to either react to or replace operations and results. For backwards compatibility, this exchange is also exported aserrorExchange
and supportsonError
, by @kitten (See #2846)
- Move remaining
Variables
generics over fromobject
default toVariables extends AnyVariables = AnyVariables
. This has been introduced previously in #2607 but some missing ports have been missed due to TypeScript not catching them previously. Depending on your TypeScript version theobject
default is incompatible withAnyVariables
, by @kitten (See #2843) - Reuse output of
stringifyDocument
in place of repeatedprint
. This will mean that we now prevent callingprint
repeatedly for identical operations and are instead only reusing the result once. This change has a subtle consequence of our internals. Operation keys will change due to this refactor and we will no longer sanitise strip newlines from queries that@urql/core
has printed, by @kitten (See #2847) - Update to
wonka@^6.1.2
to fix memory leak infetch
caused in Node.js by a lack of clean up after initiating a request, by @kitten (See #2850)
- Update typings of the client to encompass the changes of #2692, by @c-schwan (See #2758)
⚠️ Fix case where our transform-debug-target babel plugin would override the root dispatchDebug incompose.ts
with the latest found exchange, in this casefetchExchange
, by @JoviDeCroock (See #2762)
⚠️ FixssrExchange
bug which preventedstaleWhileRevalidate
from sending off requests as network-only requests, and caused unrelatednetwork-only
operations to be dropped, by @kitten (See #2691)- Allow URL limit for GET requests to be bypassed using
preferGetMethod: 'force'
rather than the defaulttrue
or'within-url-limit'
value, by @kitten (See #2692) ⚠️ Fix operation identities preventing users from deeply cloning operation contexts. Instead, we now use a client-wide counter (rolling over as needed). While this changes an internal data structure in@urql/core
only, this change also affects theofflineExchange
in@urql/exchange-graphcache
due to it relying on the identity being previously an object rather than an integer, by @kitten (See #2732)
⚠️ Fix variable types in core makeOperation, by @JoviDeCroock (See #2665)
⚠️ Fix case wheremaskTypename
would not traverse down when the root query-field does not contain a__typename
, by @mlecoq (See #2643)
⚠️ fix setting a client default requestPolicy, we setcontext.requestPolicy: undefined
from our bindings which makes a spread override the client-set default, by @JoviDeCroock (See #2634)
- Goodbye IE11! 👋 This major release removes support for IE11. All code that is shipped will be transpiled much less and will not be ES5-compatible anymore, by @kitten (See #2504)
- Remove support for options on the
Client
andClient.createOperationContext
. We've noticed that there's no real need forcreateOperationContext
or the options on theClient
and that it actually encourages modifying properties on theClient
that are really meant to be modified dynamically via exchanges, by @kitten (See #2619) - Implement stricter variables types, which require variables to always be passed and match TypeScript types when the generic is set or inferred. This is a breaking change for TypeScript users potentially, unless all types are adhered to, by @kitten (See #2607)
- Upgrade to Wonka v6 (
wonka@^6.0.0
), which has no breaking changes but is built to target ES2015 and comes with other minor improvements. The library has fully been migrated to TypeScript which will hopefully help with making contributions easier!, by @kitten (See #2504)
- Remove the
babel-plugin-modular-graphql
helper, this because the graphql package hasn't converted to ESM yet which gives issues in node environments, by @JoviDeCroock (See #2551)
⚠️ Fix missing React updates after an incoming response that schedules a mount. We now prevent dispatched operations from continuing to flush synchronously when the original source that runs the queue has terminated. This is important for the React bindings, because an update (e.g.setState
) may recursively schedule a mount, which then disabled othersetState
updates from being processed. Previously we assumed that React used a trampoline scheduler for updates, however it appears thatsetState
can recursively start more React work, by @kitten (See #2556)
- Add
Accept
header to GraphQL HTTP requests. This complies to the specification but doesn't go as far as sendingContent-Type
which would throw a lot of APIs off. Instead, we'll now be sending an accept header forapplication/graphql+json, application/json
to indicate that we comply with the GraphQL over HTTP protocol. This also fixes headers merging to allow overridingAccept
andContent-Type
regardless of the user options' casing, by @kitten (See #2457)
- Support aborting in
withPromise
cases, by @JoviDeCroock (See #2446) - Passthrough responses with content type of
text/*
as error messages, by @kitten (See #2456)
- cut off
url
when using the GET method at 2048 characters (lowest url-size coming from chromium), by @JoviDeCroock (See #2384) ⚠️ Fix issue where a synchronoustoPromise()
return would not result in the stream tearing down, by @JoviDeCroock (See #2386)
- Prevent ignored characters in GraphQL queries from being replaced inside strings and block strings. Previously we accepted sanitizing strings via regular expressions causing duplicate hashes as acceptable, since it'd only be caused when a string wasn't extracted into variables. This is fixed now however, by @kitten (See #2295)
- Undo logic to catch errors from incremental fetching and forking the response stream, introduce logic to detect results, by @JoviDeCroock (See #2287)
⚠️ Fix mutation operation being used as compared identity and instead add a stand-in comparison, by @kitten (See #2228)
- Allow for repeated mutations that have similar inputs which results in the same key, this is for instance the case with file uploads, by @JoviDeCroock (See #2189)
- Bump
@graphql-typed-document-node/core
to 3.1.1 forgraphql@16
support, by @JoviDeCroock (See #2153) ⚠️ Fix error bubbling, when an error happened in the exchange-pipeline we would treat it as a GraphQL-error, by @JoviDeCroock (See #2210)- Filter
network-only
requests from thessrExchange
, this is to enablestaleWhileRevalidated
queries to successfully dispatch their queries, by @JoviDeCroock (See #2198)
- Extend peer dependency range of
graphql
to include^16.0.0
. As always when upgrading across many packages ofurql
, especially including@urql/core
we recommend you to deduplicate dependencies after upgrading, usingnpm dedupe
ornpx yarn-deduplicate
, by @kitten (See #2133)
⚠️ Fix issue wheremaskTypename
would ignore array shapes, by @JoviDeCroock (See #2074)
- Prevent
Buffer
from being polyfilled by an automatic detection in Webpack. Instead of referencing theBuffer
global we now simply check the constructor name, by @kitten (See #2027) ⚠️ Fix error-type of anExecutionResult
to line up with subscription-libs, by @JoviDeCroock (See #1998)
- Adding option to
ssrExchange
to include theextensions
field of operation results in the cache, by @dios-david (See #1985)
⚠️ Fix issue where the ssr-exchange would loop due to checking network-only revalidations, by @JoviDeCroock (See #1944)
⚠️ Fix markquery.__key
as non-enumerable soformatDocument
does not restore previous invocations when cloning the gql-ast, by @JoviDeCroock (See #1870)⚠️ Fix: update toPromise to excludehasNext
results. This change ensures that when we call toPromise() on a query we wont serve an incomplete result, the user will expect to receive a non-stale full-result when using toPromise(), by @JoviDeCroock (See #1880)
- Add experimental support for
@defer
and@stream
responses for GraphQL. This implements the "GraphQL Defer and Stream Directives" and "Incremental Delivery over HTTP" specifications. If a GraphQL API supportsmultipart/mixed
responses for deferred and streamed delivery of GraphQL results,@urql/core
(and all its derived fetch implementations) will attempt to stream results. This is only supported on browsers supporting streamed fetch responses, which excludes IE11. The implementation of streamed multipart responses is derived frommeros
by@maraisr
, and is subject to change if the RFCs end up changing, by @kitten (See #1854)
- Add a
staleWhileRevalidate
option to thessrExchange
, which allows the client to immediately refetch a new result on hydration, which may be used for cached / stale SSR or SSG pages. This is different from usingcache-and-network
by default (which isn't recommended) as thessrExchange
typically acts like a "replacement fetch request", by @kitten (See #1852)
⚠️ Fix prevent mangling embedded strings in queries sent using theGET
method, by @JoviDeCroock (See #1851)- The single-source behavior previously wasn't effective for implementations like React, where the issue presents itself when the state of an operation is first polled. This led to the operation being torn down erroneously. We now ensure that operations started at the same time still use a shared single-source, by @JoviDeCroock (See #1850)
- Warn for invalid operation passed to query/subscription/mutation, by @JoviDeCroock (See #1829)
- Prevent
ssrExchange().restoreData()
from adding results to the exchange that have already been invalidated. This may happen whenrestoreData()
is called repeatedly, e.g. per page. When a prior run has already invalidated an SSR result then the result is 'migrated' to the user'scacheExchange
, which means thatrestoreData()
should never attempt to re-add it again, by @kitten (See #1776) ⚠️ Fix accidental change in passivestale: true
, where acache-first
operation issued by Graphcache wouldn't yield an affected query and update its result to reflect the loading state withstale: true
. This is a regression fromv2.1.0
and mostly becomes unexpected whencache.invalidate(...)
is used, by @kitten (See #1755)
- Prevent stale results from being emitted by promisified query sources, e.g.
client.query(...).toPromise()
yielding a partial result withstale: true
set. Instead,.toPromise()
will now filter out stale results, by @kitten (See #1709)
- Treat empty variables the same as no variables in
@urql/core
'screateRequest
, by @kitten (See #1695)
⚠️ Fix a condition under which theClient
would hang when a query is started and consumed withtoPromise()
, by @kitten (See #1634)- Refactor
Client
to hide some implementation details and to reduce size, by @kitten (See #1638)
⚠️ Fix a regression in@urql/[email protected]
that prevented concurrent operations from being dispatched with differing request policies, which for instance prevented the explicitexecuteQuery
calls on bindings to fail, by @kitten (See #1626)
- With the "single-source behavior" the
Client
will now also avoid executing an operation if it's already active, has a previous result available, and is either run with thecache-first
orcache-only
request policies. This is similar to a "short circuiting" behavior, where unnecessary work is avoided by not issuing more operations into the exchange pipeline than expected, by @kitten (See #1600) - Add consistent "single-source behavior" which makes the
Client
more forgiving when duplicate sources are used, which previously made it difficult to use the same operation across an app together withcache-and-network
; This was a rare use-case, and it isn't recommended to overfetch data across an app, however, the newClient
implementation of shared sources ensures that when an operation is active that theClient
distributes the last known result for the active operation to any new usages of it (which is called “replaying stale results”) (See #1515)
- Remove closure-compiler from the build step (See #1570)
⚠️ Fix inconsistency in generating keys forDocumentNode
s, especially when using GraphQL Code Generator, which could cause SSR serialization to fail, by @zenflow (See #1509)
- Breaking: Remove
pollInterval
feature fromOperationContext
. Instead consider using a source that usesWonka.interval
andWonka.switchMap
overclient.query()
's source, by @kitten (See #1374) - Remove deprecated
operationName
property fromOperation
s. The newOperation.kind
property is now preferred. If you're creating new operations you may also use themakeOperation
utility instead. When upgrading@urql/core
please ensure that your package manager didn't install any duplicates of it. You may deduplicate it manually usingnpx yarn-deduplicate
(for Yarn) ornpm dedupe
(for npm), by @kitten (See #1357)
- Reemit an
OperationResult
asstale: true
if it's being reexecuted asnetwork-only
operation to give bindings immediate feedback on background refetches, by @kitten (See #1375)
- Add a workaround for
graphql-tag/loader
, which provides filtered query documents (where the original document contains multiple operations) without updating or providing a correctdocument.loc.source.body
string, by @kitten (See #1315)
- Add fragment deduplication to
gql
tag. Identical fragments can now be interpolated multiple times without a warning being triggered or them being duplicated ingql
's output, by @kitten (See #1225)
- Add a built-in
gql
tag function helper to@urql/core
. This behaves similarly tographql-tag
but only warns about locally duplicated fragment names rather than globally. It also primes@urql/core
's key cache with the parsedDocumentNode
, by @kitten (See #1187)
⚠️ Fix edge case informatDocument
, which fails to add a__typename
field if it has been aliased to a different name, by @kitten (See #1186)- Cache results of
formatDocument
by the input document's key, by @kitten (See #1186)
- Don't add
undefined
to any property of thessrExchange
's serialized results, as this would crash in Next.js, by @JoviDeCroock (See #1168)
- Export
getOperationName
from@urql/core
and use it in@urql/exchange-execute
, fixing several imports, by @JoviDeCroock (See #1135)
- Improve the Suspense implementation, which fixes edge-cases when Suspense is used with subscriptions, partially disabled, or used on the client-side. It has now been ensured that client-side suspense functions without the deprecated
suspenseExchange
and uncached results are loaded consistently. As part of this work, theClient
itself does now never throw Suspense promises anymore, which is functionality that either way has no place outside of the React/Preact bindings, by @kitten (See #1123)
- Use
Record
overobject
type for subscription operation variables. Theobject
type is currently hard to use (see this issue), by @enisdenjo (See #1119) - Add support for
TypedDocumentNode
to infer the type of theOperationResult
andOperation
for all methods, functions, and hooks that either directly or indirectly accept aDocumentNode
. Seegraphql-typed-document-node
and the corresponding blog post for more information., by @kitten (See #1113) - Refactor
useSource
hooks which powersuseQuery
anduseSubscription
to improve various edge case behaviour. This will not change the behaviour of these hooks dramatically but avoid unnecessary state updates when any updates are obviously equivalent and the hook will furthermore improve continuation from mount to effects, which will fix cases where the state between the mounting and effect phase may slightly change, by @kitten (See #1104)
⚠️ Fix the production build overwriting the development build. Specifically in the previous release we mistakenly replaced all development bundles with production bundles. This doesn't have any direct influence on how these packages work, but prevented development warnings from being logged or full errors from being thrown, by @kitten (See #1097)
This version of @urql/core
renames Operation.operationName
to Operation.kind
. For now the old
property is merely deprecated and will issue a warning if it's used directly. That said, all
exchanges that are released today also need this new version of @urql/core@>=1.14.0
, so if you
upgrade to any of the following packages, you will also need to upgrade @urql/core
. If you upgrade
and see the deprecation warning, check whether all following exchanges have been upgraded:
@urql/[email protected]
@urql/[email protected]
@urql/[email protected]
@urql/[email protected]
@urql/[email protected]
@urql/[email protected]
@urql/[email protected]
@urql/[email protected]
@urql/[email protected]
Once you've upgraded @urql/core
please also ensure that your package manager hasn't accidentally
duplicated the @urql/core
package. If you're using npm
you can do so by running npm dedupe
,
and if you use yarn
you can do so by running yarn-deduplicate
.
If you have a custom exchange, you can mute the deprecation warning by using Operation.kind
rather
than Operation.operationName
. If these exchanges are copying or altering operations by spreading
them this will also trigger the warning, which you can fix by using the new makeOperation
helper
function.
- Deprecate the
Operation.operationName
property in favor ofOperation.kind
. This name was previously confusing asoperationName
was effectively referring to two different things. You can safely upgrade to this new version, however to mute all deprecation warnings you will have to upgrade allurql
packages you use. If you have custom exchanges that spread operations, please use the newmakeOperation
helper function instead, by @bkonkle (See #1045)
- Add missing
.mjs
extension to all imports fromgraphql
to fix Webpack 5 builds, which require extension-specific import paths for ESM bundles and packages. This change allows you to safely upgrade to Webpack 5., by @kitten (See #1094)
- Allow
client.reexecuteOperation
to be called with mutations which skip the active operation minimums, by @kitten (See #1011)
Please note that this release changes the data structure of the ssrExchange
's
output. We don't treat this as a breaking change, since this data is considered
a private structure, but if your tests or other code relies on this, please check
the type changes and update it.
- Adds an error exchange to urql-core. This allows tapping into all graphql errors within the urql client. Useful for logging, debugging, handling authentication errors etc, by @kadikraman (See #947)
⚠️ Fix condition where mutated result data would be picked up by thessrExchange
, for instance as a result of mutations by Graphcache. Instead thessrExchange
now serializes data early, by @kitten (See #962)- Omit the
Content-Type: application/json
HTTP header when using GET in thefetchExchange
,persistedFetchExchange
, ormultipartFetchExchange
, by @JoviDeCroock (See #957)
- Remove whitespace and comments from string-queries, by @JoviDeCroock (See #911)
- Remove redundant whitespaces when using GET for graphql queries, by @JoviDeCroock (See #908)
⚠️ FixformatDocument
mutating parts of theDocumentNode
which may be shared by other documents and queries. Also ensure that a formatted document will always generate the same key increateRequest
as the original document, by @kitten (See #880)⚠️ FixssrExchange
invalidating results on the client-side too eagerly, by delaying invalidation by a tick, by @kitten (See #885)
⚠️ Fix timing for out-of-bandclient.reexecuteOperation
calls. This would surface in asynchronous caching scenarios, where no result would be delivered by the cache synchronously, while it still callsclient.reexecuteOperation
for e.g. anetwork-only
request, which happens forcache-and-network
. This issue becomes especially obvious in highly synchronous frameworks like Svelte, by @kitten (See #860)- Replace unnecessary
scheduleTask
polyfill with inlinePromise.resolve().then(fn)
calls, by @kitten (See #861)
As always, please ensure that you deduplicate @urql/core
when upgrading. Additionally
deduplicating the versions of wonka
that you have installed may also reduce your bundlesize.
- Expose a
client.subscription
shortcut method, similar toclient.query
andclient.mutation
, by @FredyC (See #838)
- Upgrade to a minimum version of wonka@^4.0.14 to work around issues with React Native's minification builds, which use uglify-es and could lead to broken bundles, by @kitten (See #842)
- Add operationName to GET queries, by @jakubriedl (See #798)
- Add
source
debug name to alldispatchDebug
calls during build time to identify events by which exchange dispatched them, by @JoviDeCroock (See #780)
- Add a
"./package.json"
entry to thepackage.json
's"exports"
field for Node 14. This seems to be required by packages likerollup-plugin-svelte
to function properly, by @JoviDeCroock (See #771)
- Hoist variables in unminified build output for Metro Bundler builds which otherwise fails for
process.env.NODE_ENV
if-clauses, by @kitten (See #737) - Add a babel-plugin that removes empty imports from the final build output, by @JoviDeCroock (See #735)
Sorry for the many updates; Please only upgrade to >=1.11.4
and don't use the deprecated 1.11.3
and 1.11.2
release.
⚠️ Fix nested package path for @urql/core/internal and @urql/exchange-graphcache/extras, by @kitten (See #734)
- Make the extension of the main export unknown, which fixes a Webpack issue where the resolver won't pick
module
fields inpackage.json
files once it's importing from another.mjs
file, by @JoviDeCroock (See #733)
⚠️ Fix missing@urql/core/internal
entrypoint in the npm-release, which was previously not included, by @JoviDeCroock (See #731)
- Add debugging events to exchanges that add more detailed information on what is happening internally, which will be displayed by devtools like the urql Chrome / Firefox extension, by @andyrichardson (See #608)
- Add @urql/core/internal entrypoint for internally shared utilities and start sharing fetchExchange-related code, by @kitten (See #722)
- Pick modules from graphql package, instead of importing from graphql/index.mjs, by @kitten (See #700)
- Add graphql@^15.0.0 to peer dependency range, by @kitten (See #688)
⚠️ Fix non-2xx results never being parsed as GraphQL results. This can result in valid GraphQLErrors being hidden, which should take precedence over generic HTTP NetworkErrors, by @kitten (See #678)
⚠️ Fix oversight in edge case for #662. The operation queue wasn't marked as being active which causedstale
results andcache-and-network
operations from reissuing operations immediately (unqueued essentially) which would then be filtered out by thededupExchange
, by @kitten (See #669)
⚠️ Fix critical bug in operation queueing that can lead to unexpected teardowns and swallowed operations. This would happen when a teardown operation kicks off the queue, by @kitten (See #662)
- Refactor a couple of core helpers for minor bundlesize savings, by @kitten (See #658)
- Add support for variables that contain non-plain objects without any enumerable keys, e.g.
File
orBlob
. In this casestringifyVariables
will now use a stable (but random) key, which means that mutations containingFile
s — or other objects like this — will now be distinct, as they should be, by @kitten (See #650)
⚠️ Fix node resolution when using Webpack, which experiences a bug where it only resolvespackage.json:main
instead ofmodule
when an.mjs
file imports a package, by @JoviDeCroock (See #642)
⚠️ Fix Node.js Module support for v13 (experimental-modules) and v14. If your bundler doesn't support.mjs
files and fails to resolve the new version, please double check your configuration for Webpack, or similar tools, by @JoviDeCroock (See #637)
- Add a guard to "maskTypenames" so a null value isn't considered an object, by @JoviDeCroock (See #621)
- Add
additionalTypenames
to theOperationContext
, which allows the document cache to invalidate efficiently when the__typename
is unknown at the initial fetch, by @JoviDeCroock (See #601) You can learn more about this change in our docs.
- Add missing GraphQLError serialization for extensions and path field to ssrExchange, by @kitten (See #607)
⚠️ Fixcache-only
operations being forwarded and triggering fetch requests, by @JoviDeCroock (See #551)- Adds a one-tick delay to the subscriptionExchange to prevent unnecessary early tear downs, by @JoviDeCroock (See #542)
- Add enableAllOperations option to subscriptionExchange to let it handle queries and mutations as well, by @kitten (See #544)
- Adds the
maskTypename
export to urql-core, this deeply masks typenames from the given payload. Masking__typename
properties is also available as amaskTypename
option on theClient
. Setting this to true will strip typenames from results, by @JoviDeCroock (See #533) - Add support for sending queries using GET instead of POST method (See #519)
- Add client.readQuery method (See #518)