
Research
/Security News
Shai Hulud Strikes Again (v2)
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.
@urql/exchange-context
Advanced tools
An exchange for setting (a)synchronous operation-context in urql
An exchange for setting operation context in urql
@urql/exchange-context is an exchange for the urql GraphQL client which can set the operation context both synchronously as well as asynchronously
First install @urql/exchange-context alongside urql:
yarn add @urql/exchange-context
# or
npm install --save @urql/exchange-context
You'll then need to add the contextExchange, that this package exposes, to your urql Client, the positioning of this exchange depends on whether you set an async setter or not. If you set an async context-setter it's best placed after all the synchronous exchanges (in front of the fetchExchange).
import { createClient, cacheExchange, fetchExchange } from 'urql';
import { contextExchange } from '@urql/exchange-context';
const client = createClient({
url: 'http://localhost:1234/graphql',
exchanges: [
cacheExchange,
contextExchange({
getContext: async operation => {
const token = await getToken();
return { ...operation.context, headers: { authorization: token } };
},
}),
fetchExchange,
],
});
FAQs
An exchange for setting (a)synchronous operation-context in urql
The npm package @urql/exchange-context receives a total of 12,172 weekly downloads. As such, @urql/exchange-context popularity was classified as popular.
We found that @urql/exchange-context 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.

Research
/Security News
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.