Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const customBuildQuery = introspectionResults => {
const buildQuery = buildQueryFactory(introspectionResults);
return (type, resource, params) => {
if (type === DELETE) {
return {
query: gql`mutation remove${resource}($id: ID!) {
remove${resource}(id: $id)
}`,
variables: { id: params.id },
parseResponse: ({ data }) => {
if (data[`remove${resource}`]) {
return { data: { id: params.id } };
}
throw new Error(`Could not delete ${resource}`);
}
}