Skip to content

Instantly share code, notes, and snippets.

@a7v8x
Last active October 5, 2017 19:05
Show Gist options
  • Save a7v8x/b3541131895560395bd125abde93db08 to your computer and use it in GitHub Desktop.
Save a7v8x/b3541131895560395bd125abde93db08 to your computer and use it in GitHub Desktop.
const userMutations = {
createUser: {
type: UserType,
args: {
input: {
type: new GraphQLNonNull(UserInputType),
},
},
resolve: async (rootValue, { input }) => {
if (input.email && !isEmail(input.email)) {
throw new Error('Email is not in valid format');
}
const result = await new Promise((resolve) => {
setTimeout(() =>
resolve(Object.assign(input, {
id: random.uuid(),
})), 100);
});
return result;
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment