Skip to content

Instantly share code, notes, and snippets.

@knightbenax
Created July 22, 2023 20:26
Show Gist options
  • Save knightbenax/211e550ed803c1dd0101731c55dc5a0b to your computer and use it in GitHub Desktop.
Save knightbenax/211e550ed803c1dd0101731c55dc5a0b to your computer and use it in GitHub Desktop.
Example GraphQL implementation
class AuthViewModel : BaseViewModel {
func loginUser(email: String, password: String, completion: @escaping (_ success : Bool, _ error : NSError?) -> Void){
Network.shared.apollo.perform(mutation: BundulAPI.LoginUserMutation(loginInput: NameOfAPI.LoginInput(email: email, password: password))) { result in
switch result {
case .success(let graphQLResult):
print("Success! Result: \(graphQLResult)")
completion(true, nil)
case .failure(let error):
print("Failure! Error: \\(error)")
completion(false, error)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment