Guest User

Untitled

a guest
May 27th, 2018
145
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. password: "12345"
  3. )
  4.  
  5. let mutation = Storefront.buildMutation { $0
  6. .customerAccessTokenCreate(input: input) { $0
  7. .customerAccessToken { $0
  8. // [SUCCESS] Properties to get from response
  9. .accessToken()
  10. .expiresAt()
  11. }
  12. .userErrors { $0
  13. // [ERROR] Properties to get from response
  14. .field()
  15. .message()
  16. }
  17. }
  18. }
  19.  
  20. let task = client.mutateGraphWith(mutation) { response, error in
  21. if let mutation = response?.customerAccessTokenCreate, let accessToken = mutation.customerAccessToken {
  22. print("[INFO] Login success: \(accessToken)")
  23. } else {
  24. print("[ERROR] Login failed: \(error)")
  25. }
  26. }
  27. task.resume()
Add Comment
Please, Sign In to add comment