Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const useMutation = (mutation, toRefetch) => {
const apolloClient = useApolloContext();
const [queryResultState, queryResultApi] = useQueryResult();
const { receiveResponse } = queryResultApi;
/**
* A callback function that performs a query either as an effect or in response to user interaction.
*
* @function API.runQuery
*
* @param {DocumentNode} query A GraphQL document
*/
const runMutation = useCallback(
async ({ variables }) => {
let payload;
try {
console.log(`Do we have variables? `, variables);
payload = await apolloClient.mutate({ mutation, variables, refetchQueries: toRefetch });