Created
September 23, 2019 20:54
-
-
Save alyssoncm/cf04a89aaaee00cc3530da5742187781 to your computer and use it in GitHub Desktop.
apolloSwift2
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
// Perform the SignUpUser mutation, passing the parameters we just got from our TextFields | |
apollo.perform(mutation: SignUpUserMutation(username: self.username, password: self.password, email: self.email)){ result in | |
// Let's switch the result so we can separate a successful one from an error | |
switch result { | |
// In case of success | |
case .success(let graphQLResult): | |
// We try to parse our result | |
if let objId = graphQLResult.data?.users?.signUp.objectId { | |
print ("User created with ObjectId: " + objId) | |
} | |
// but in case of any GraphQL errors we present that message | |
else if let errors = graphQLResult.errors { | |
// GraphQL errors | |
print(errors) | |
} | |
// In case of failure, we present that message | |
case .failure(let error): | |
// Network or response format errors | |
print(error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment