Last active
December 27, 2017 11:11
-
-
Save smmoosavi/7bb5e3ce7adc9b76f6c6da45f63b40e5 to your computer and use it in GitHub Desktop.
graphql example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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') | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutation { | |
changePassword(input: { | |
oldPassword: "wrongPassword" | |
newPassword: "some-password" | |
}) { | |
success | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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