nuxt-modules / apollo

Nuxt.js module to use Vue-Apollo. The Apollo integration for GraphQL.
https://apollo.nuxtjs.org
MIT License
956 stars 198 forks source link

How to get data from response with errors? #484

Closed talaxasy closed 1 year ago

talaxasy commented 1 year ago

Environment


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.

@nuxtjs/apollo

image image image

nuxt-graphql-client

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

Ok, I found that it can configured by defaultOptions property in nuxt.config

//nuxt.config.ts
apollo: {
      defaultOptions: {
        query: {
          errorPolicy: 'all',
        },
      },
}