Seeing empty graphQLErrors when reading apolloError in reason-apollo

reasonreact

#1

We have created query that looks like:

module Query = [%graphql
  {|
  query getAllPokemon($trainerId: String!) {
      trainerId (id: $trainerId) {
      pokemon (limit: -1) {
        totalCount
        edges {
          node {
            pokemonName
          }
        }
      }
    }
  }
|}
];

module Container = ReasonApollo.CreateQuery(Query);

We are forcing our system to respond with an error as the limit is set to -1.

When we use the Query and are trying to read our custom graphQL errors by logging err##graphQLErrors, we get an empty array back in the network console.

let pokemonQuery = Query.make(~id="A123", ());
<Container
  variables=pokemonQuery##variables
  errorPolicy="all"
  notifyOnNetworkStatusChange=true>
  ...(
        ({error, result, data, loading, networkStatus, refetch}) => {
            switch (result) {
            | Loading => <div> "Loading..." </div>
            | Error(err) =>
              Js.log(err##message);          // (1)
              Js.log(err##graphQLErrors);    // (2)
              Js.log(err##networkError);     // (3)
              Js.log(networkStatus);         // (4)
               <div> "Error" </div>
            | Data(_response) => <div> "Loaded" </div>
            };
         }
      )
</Container>

The network console looks like:

(1). Network error: Response not successful: Received status code 401
(2). []
(3). Error: Response not successful: Received status code 401
    at throwServerError (index.js:41)
    at eval (index.js:67)
(4). 8

When I make this request in graphQL, I get:

{
  "errors": [
    {
      "type": "INVALID_REQUEST",
      "message": "java.lang.IllegalArgumentException: invalid limit value: -1",
    }
  ]
}

Could someone please explain why I am not getting the above error in my front-end application? Is there an issue logging the raw graphQL error?


#2

Response with status code 401 is considered as a network error by apollo.
If this is not the case in your application, you must configure it in apollo.

More informations here: https://www.apollographql.com/docs/react/features/error-handling.html