Skip to content

Instantly share code, notes, and snippets.

@alyssoncm
Created September 23, 2019 20:54
Show Gist options
  • Save alyssoncm/cf04a89aaaee00cc3530da5742187781 to your computer and use it in GitHub Desktop.
Save alyssoncm/cf04a89aaaee00cc3530da5742187781 to your computer and use it in GitHub Desktop.
apolloSwift2
// 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