
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@kiwicom/graphql-resolve-wrapper
Advanced tools
Utility which enables to wrap GraphQL resolvers with your custom functions.
This package allows you to do basically whatever you want with the resolvers.
Do you like our open source? We are looking for skilled JavaScript developers to help us build it. Check our open positions: https://jobs.kiwi.com/
yarn add @kiwicom/graphql-resolve-wrapper
Note: this function mutates the GraphQL schema (it replaces the resolve function).
const Schema = new GraphQLSchema({
query: RootQuery,
mutation: RootMutation,
});
wrapResolvers(Schema, resolveFn => async (...args) => {
const value = await resolveFn(...args);
return typeof value === 'string' ? value.toUpperCase() : value;
});
export default Schema;
This wrapper would uppercase every string in the response. There are of course more interesting and practical use-cases:
try/catch and mask only server-side errors)resolve function behaviorThe simplest resolver wrapper is this (it just calls the resolver):
function defaultWrapper(resolveFn) {
return (...args) => resolveFn(...args);
}
Query:
query Test($search: String!) {
allLocations(first: 10, search: $search) {
edges {
node {
id
name
}
}
}
}
Wrapper:
wrapResolvers(Schema, resolveFn => async (ancestor, args, context, info) => {
const startAt = process.hrtime.bigint();
const response = await resolveFn(ancestor, args, context, info);
console.warn(process.hrtime.bigint() - startAt, JSON.stringify(info.path));
return response;
});
Output:
567425567n '{"key":"allLocations"}'
301331n '{"prev":{"prev":{"prev":{"prev":{"key":"allLocations"},"key":"edges"},"key":0},"key":"node"},"key":"id"}'
250083n '{"prev":{"prev":{"prev":{"prev":{"key":"allLocations"},"key":"edges"},"key":0},"key":"node"},"key":"name"}'
237656n '{"prev":{"prev":{"prev":{"prev":{"key":"allLocations"},"key":"edges"},"key":1},"key":"node"},"key":"id"}'
262972n '{"prev":{"prev":{"prev":{"prev":{"key":"allLocations"},"key":"edges"},"key":1},"key":"node"},"key":"name"}'
280750n '{"prev":{"prev":{"prev":{"prev":{"key":"allLocations"},"key":"edges"},"key":2},"key":"node"},"key":"id"}'
305839n '{"prev":{"prev":{"prev":{"prev":{"key":"allLocations"},"key":"edges"},"key":2},"key":"node"},"key":"name"}'
325893n '{"prev":{"prev":{"prev":{"prev":{"key":"allLocations"},"key":"edges"},"key":3},"key":"node"},"key":"id"}'
351468n '{"prev":{"prev":{"prev":{"prev":{"key":"allLocations"},"key":"edges"},"key":3},"key":"node"},"key":"name"}'
FAQs
Utility which enables to wrap GraphQL resolvers with your custom functions.
We found that @kiwicom/graphql-resolve-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 12 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
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.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.