Skip to content

Instantly share code, notes, and snippets.

@aswinmprabhu
Last active August 17, 2018 12:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aswinmprabhu/6b3902ed6193cefcd4f0c9c3902d7c3b to your computer and use it in GitHub Desktop.
const makeCustomResolver = (userSchema) => {
// Create custom resolvers
const customResolver = {
Mutation: {
insert_user(parent, args, context, info){
let newArgs = { objects:[] };
// Convert the email to lower case and append each object to the new arguments array
for (const user of args.objects) {
user.email = user.email.toLowerCase();
newArgs.objects.push(user);
}
// Delegate after sanitization
return info.mergeInfo.delegateToSchema({
schema: userSchema,
operation: 'mutation',
fieldName: 'insert_user',
args: newArgs,
context,
info,
});
}
}
};
return customResolver;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment