Guest User

Untitled

a guest
May 27th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. let input = Storefront.CustomerAccessTokenCreateInput.create(
  2. email: "johndoe@gmail.com",
  3. password: "12345"
  4. )
  5.  
  6. let mutation = Storefront.buildMutation { $0
  7. .customerAccessTokenCreate(input: input) { $0
  8. .customerAccessToken { $0
  9. // [SUCCESS] Properties to get from response
  10. .accessToken()
  11. .expiresAt()
  12. }
  13. .userErrors { $0
  14. // [ERROR] Properties to get from response
  15. .field()
  16. .message()
  17. }
  18. }
  19. }
  20.  
  21. let task = client.mutateGraphWith(mutation) { response, error in
  22. if let mutation = response?.customerAccessTokenCreate, let accessToken = mutation.customerAccessToken {
  23. print("[INFO] Login success: \(accessToken)")
  24. } else {
  25. print("[ERROR] Login failed: \(error)")
  26. }
  27. }
  28. task.resume()
Add Comment
Please, Sign In to add comment