timhall / svelte-apollo

Svelte integration for Apollo GraphQL
MIT License
945 stars 67 forks source link

ReadableQuery<T>.result function doesn't contain the errors property #105

Closed grodasgomez closed 3 years ago

grodasgomez commented 3 years ago

I'm trying to get the errors from the server. The server responds:

{
  "errors": [
    {
      "message": "Error message"
    }
  ],
  "data": null
}

So, I have the code that executes the query:

 const queryData = query<T>(graphqlQuery, variables);
 const resp = await queryData.result();
 console.log(resp);

And the console shows: svelte

How I can get the errors property or am I missing something?

grodasgomez commented 3 years ago

Reading from the apollo's docs, I realized that I didn't set any policies to the query. Initializing the query in this way: const queryData = query<T>(graphqlQuery, {errorPolicy: 'none'}); I could get the errors from the response, handling the error in a try/catch