Skip to content

Instantly share code, notes, and snippets.

@smmoosavi
Last active December 27, 2017 11:11
Show Gist options
  • Save smmoosavi/7bb5e3ce7adc9b76f6c6da45f63b40e5 to your computer and use it in GitHub Desktop.
Save smmoosavi/7bb5e3ce7adc9b76f6c6da45f63b40e5 to your computer and use it in GitHub Desktop.
graphql example
@classmethod
def mutate_and_get_payload(cls, input, context, info):
user = context.user
old_password = input.get('old_password')
new_password = input.get('new_password')
if user.has_usable_password():
if not user.check_password(old_password):
raise ResponseError(
"Invalid Password",
code='invalid_old_password')
# ...
mutation {
changePassword(input: {
oldPassword: "wrongPassword"
newPassword: "some-password"
}) {
success
}
}
{
"errors": [
{
"message": "Invalid Password",
"code": "invalid-old-password",
"params": null
}
],
"data": {
"changePassword": null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment