The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
MIT License
Bot releases are hidden (Show)
generateHash
option, by @JoviDeCroock (See #887)__type
, by @kitten (See #919)__typename
as expected, by @JoviDeCroock (See #927)generateHash
option to the exchange, by @lorenries (See #870)formatDocument
mutating parts of the DocumentNode
which may be shared by other documents and queries. Also ensure that a formatted document will always generate the same key in createRequest
as the original document, by @kitten (See #880)ssrExchange
invalidating results on the client-side too eagerly, by delaying invalidation by a tick, by @kitten (See #885)Client
when we aren't using react-ssr-prepass
, by @JoviDeCroock (See #884)// Standard Usage:
mutate({ query, variables })()
// Subscribable Usage:
$: result = mutate({ query, variables });
// Curried Usage
const executeMutation = mutate({ query, variables });
const onClick = () => executeMutation();
// Curried Usage with overrides
const executeMutation = mutate({ query });
const onClick = () => await executeMutation({ variables });
// Subscribable Usage (as before):
$: result = query({ query: TestQuery, variables });
// Subscribable Usage which preserves state over time:
const testQuery = query({ query: TestQuery });
// - this preserves the state even when the variables change!
$: result = testQuery({ variables });
// Promise-based callback usage:
const testQuery = query({ query: TestQuery });
const doQuery = async () => await testQuery;
// Promise-based usage updates the subscribables!
const testQuery = query({ query: TestQuery });
const doQuery = async () => await testQuery;
// - doQuery will also update this result
$: result = query({ query: TestQuery, variables });
@urql/exchange-graphcache/default-storage
implementation, which will be incompatible with the old one, by @kitten (See #866)scheduleTask
polyfill with inline Promise.resolve().then(fn)
calls, by @kitten (See #861)client.reexecuteOperation
calls. This would surface in asynchronous caching scenarios, where no result would be delivered by the cache synchronously, while it still calls client.reexecuteOperation
for e.g. a network-only
request, which happens for cache-and-network
. This issue becomes especially obvious in highly synchronous frameworks like Svelte, by @kitten (See #860)scheduleTask
polyfill with inline Promise.resolve().then(fn)
calls, by @kitten (See #861)Client
for withUrqlClient
even if the target component doesn't have a getInitialProps
method. Before this caused the client to not be initialised correctly on the client-side, by @JoviDeCroock (See #857)To migrate to the new version, you will now have to pass a single function argument, instead
of two arguments to the withUrqlClient
HOC helper. For instance, you would have to transform this:
export default withUrqlClient(
ctx => ({
url: '',
}),
ssrExchange => [dedupExchange, cacheExchange, ssrExchange, fetchExchange]
);
To look like the following:
export default withUrqlClient((ssrExchange, ctx) => ({
url: '',
exchanges: [dedupExchange, cacheExchange, ssrExchange, fetchExchange]
}), { ssr; true });
The second argument may now be used to pass { ssr: true }
explicitly, when you are
wrapping a page without another getInitialProps
method. This gives you better support
when you're implement custom methods like getStaticProps
.
getInitialProps
to be applied when the wrapped page getInitialProps
or when { ssr: true }
is passed as a second options object. This is to better support alternative methods like getStaticProps
. By @JoviDeCroock (See #797)withUrqlClient
function to remove the second argument formerly called mergeExchanges
and merges it with the first argument.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.
client.subscription
shortcut method, similar to client.query
and client.mutation
, by @FredyC (See #838)This major release comes with a couple of fixes and new experimental offline support, which
we're very excited for! Please give it a try if your application is targeting Offline First!
To migrate to this new major version, check the major breaking changes below. Mainly you will have
to watch out for cache.invalidateQuery
which has been removed. Instead you should now invalidate
individual entities and fields using cache.invalidate
. Learn more about this method on our
docs.
populateExchange
export from @urql/exchange-graphcache
.populateExchange
, please install the seprate @urql/exchange-populate
package and import it from there, by @kitten (See #840)cache.invalidateQuery()
method has been removed. Please migrate over to cache.invalidate()
instead, which operates on individual fields instead of queries, by @kitten (See #840)opts
configuration to help spot typos.opts.keys
, opts.updates
, opts.resolvers
and opts.optimistic
. (See #820 and #826)