![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@urql/exchange-graphcache
Advanced tools
Readme
An exchange for normalized caching support in urql
@urql/exchange-graphcache
is a normalized cache exchange for the urql
GraphQL client.
This is a drop-in replacement for the default cacheExchange
that, instead of document
caching, caches normalized data by keys and connections between data.
urql
is already quite a comprehensive GraphQL client. However in several cases it may be
desirable to have data update across the entirety of an app when a response updates some
known pieces of data. This cache also provides configurable APIs to:
⚠️ Note:
@urql/exchange-graphcache
is still in beta. Some features may be temporarily unstable and others are not yet done. Please check the Future Features section for more details and report any bugs or feature requests on Spectrum.
First install @urql/exchange-graphcache
alongside urql
:
yarn add @urql/exchange-graphcache
# or
npm install --save @urql/exchange-graphcache
You'll then need to add the cacheExchange
, that this package exposes, to your urql
Client,
by replacing the default cache exchange with it:
import {
createClient,
dedupExchange,
fetchExchange,
} from 'urql';
import { cacheExchange } from '@urql/exchange-graphcache;
const client = createClient({
url: 'http://localhost:1234/graphql',
exchanges: [
dedupExchange,
// Replace the default cacheExchange with the new one
cacheExchange({ /* config */ }),
fetchExchange,
],
});
cache-only
and cache-and-network
policiesSchema awareness is important so that we can offer safe offline results that are partially cached instead of fully. The schema is also necessary to know how to match interface or enum fragments correctly. Currently a heuristic is in place that matches if all fields of the fragment are present in the cache
You can currently configure:
resolvers
: A nested ['__typename'][fieldName]
map to resolve results from cacheupdates
: A mutation field map to apply side-effect updates to the cacheoptimistic
: A mutation field map to supply optimistic mutation responseskeys
: A __typename
map of functions to generate keys withNote that you don't need any of these options to get started
Keys are used when you need a slight alteration to the value of your identifier or when the identifier is a non-traditional property.
Resolvers are needed when you want to do additional resolving, for example do some custom date formatting.
The graph cache will automatically handle updates but some things are quite hard to incorporate. Let's say you delete/add an item, it's hard for us to know you wanted to delete or where to add an item in a list.
Here you can configure optimistic responses, this means that we don't wait for the server to respond but offer the user to instantly replace the data with the variables from the mutation.
Active: Formidable is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.
FAQs
A normalized and configurable cache exchange for urql
The npm package @urql/exchange-graphcache receives a total of 63,184 weekly downloads. As such, @urql/exchange-graphcache popularity was classified as popular.
We found that @urql/exchange-graphcache demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 19 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.