Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@urql/exchange-persisted
Advanced tools
An exchange that allows for persisted queries support when fetching queries
The persistedExchange
is an exchange that allows other terminating exchanges to support Persisted Queries, and is as such placed in front of either the default fetchExchange
or
other terminating exchanges.
First install @urql/exchange-persisted
alongside urql
:
yarn add @urql/exchange-persisted
# or
npm install --save @urql/exchange-persisted
You'll then need to add the persistedExchange
function, that this package exposes,
to your exchanges
.
import { createClient, fetchExchange, cacheExchange } from 'urql';
import { persistedExchange } from '@urql/exchange-persisted';
const client = createClient({
url: 'http://localhost:1234/graphql',
exchanges: [
cacheExchange,
persistedExchange({
/* optional config */
}),
fetchExchange,
],
});
The persistedExchange
supports three configuration options:
preferGetForPersistedQueries
: Enforce GET
method to be used by the default fetchExchange
for persisted queriesenforcePersistedQueries
: This disables automatic persisted queries and disables any retry logic for how the API responds to persisted queries. Instead it's assumed that they'll always succeed.generateHash
: A function that takes a GraphQL query and returns the hashed result. This defaults to the window.crypto
API in the browser and the crypto
module in Node.enableForMutation
: By default, the exchange only handles query
operations, but enabling this allows it to handle mutations as well.If you want to generate hashes at build-time you can use a webpack-loader to achieve this, when using this all you need to do in this exchange is the following:
import { createClient, fetchExchange, cacheExchange } from 'urql';
import { persistedExchange } from '@urql/exchange-persisted';
const client = createClient({
url: 'http://localhost:1234/graphql',
exchanges: [
cacheExchange,
persistedExchange({
generateHash: (_, document) => document.documentId,
}),
fetchExchange,
],
});
FAQs
An exchange that allows for persisted queries support when fetching queries
The npm package @urql/exchange-persisted receives a total of 10,812 weekly downloads. As such, @urql/exchange-persisted popularity was classified as popular.
We found that @urql/exchange-persisted demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.