prisma-archive / graphcool-templates

📗 Collection of Graphcool Templates
MIT License
361 stars 100 forks source link

Can't distinguish expired tokens from empty responses #148

Open sreuter opened 6 years ago

sreuter commented 6 years ago

Issue type:

I am submitting:

Issue Questions:

What OS and OS version are you experiencing the issue(s) on?

iOS

What is the expected behavior?

I wanted to implement a custom fetch for my Apollo httpLink to handle expired or soon to be expired idTokens. Unfortunately, whenever a request to graph.cool is made with an expired token, there's nothing distinguishable in the payload I get back that I could use to determine if the request failed because of an expired token.

For the following query, using an expired idToken...

const userQuery = gql`
  query {
    user {
      id,
      name
    }
  }
`;

I get this as result...

{ data: { user: null } }

In this case, I wouldn't be able to tell if the access token expired, or if the user didn't get created before using the createUser() mutation.

What is the actual behavior?

I'd like to be able to distinguish (token expiry) errors from empty responses

What steps may we take to reproduce the behavior?

See "expected behaviour"