queryCustomer.go 543 B

12345678910111213141516171819202122232425
  1. package graphql
  2. import (
  3. "context"
  4. "github.com/gshopify/service-wrapper/auth"
  5. "gshopper.com/gshopify/customer/graphql/generated"
  6. "gshopper.com/gshopify/customer/model"
  7. )
  8. func (r *queryResolver) Customer(ctx context.Context, t string) (*generated.Customer, error) {
  9. var (
  10. claims *model.Claims
  11. err error
  12. )
  13. if _, claims, err = r.decodeAccessToken(ctx, t); err != nil {
  14. return nil, err
  15. }
  16. if _, err = auth.SessionManager().Token(ctx, claims.SessionId); err != nil {
  17. return nil, err
  18. }
  19. return r.customer(ctx, claims.Sub)
  20. }