Diizzayy / nuxt-graphql-client

⚡️ Minimal GraphQL Client + Code Generation for Nuxt3
https://nuxt-graphql-client.web.app
MIT License
366 stars 44 forks source link

How to get data from response with errors? #314

Open talaxasy opened 1 year ago

talaxasy commented 1 year ago

Environment

Nuxt project info:


Describe the bug

I try to get data from response with errors. I can't extract "data" from the response when there are more "errors" next to it, I have already tried 2 libraries nuxt-graphql-client and @nuxt/apollo, both have the same situation.

nuxt-graphql-client

image image

@nuxtjs/apollo

image image

Expected behaviour

In addition to the error, I also expect to receive the data that is in the response

Reproduction

No response

Additional context

No response

Logs

No response

talaxasy commented 1 year ago

I found that by default, Apollo Client throws away partial data - link. In order to get these partial results I should define an error policy for my operation. But how is this done specifically in this library?

talaxasy commented 1 year ago

I also found in the graphql-request library that is used as the base for this library, that in order to get partial data from a request, you have to set errorPolicy: 'all' like this:

const client = new GraphQLClient(endpoint, { errorPolicy: 'all' })

source: https://github.com/jasonkuhrt/graphql-request#errorpolicy

But I can't pass any options instead of headers in this library