vuejs / apollo

🚀 Apollo/GraphQL integration for VueJS
http://apollo.vuejs.org
MIT License
6.01k stars 521 forks source link

No update data returned when query has both errors and data #931

Open frankchen211 opened 4 years ago

frankchen211 commented 4 years ago

When gql return query results with errors, empty object returned from update or result option.

How can I get the data by calling apollo query even query has some errors?

Results returned from GrahqiQL:

{
  "errors": [
    {
      "message": "'NoneType' object has no attribute 'value'",
      "locations": [
        {
          "line": 7,
          "column": 11
        }
      ],
      "path": [
...
      ]
    },
    {
      "message": "17 is not a valid shotgun server id.",
      "locations": [
        {
          "line": 7,
          "column": 11
        }
      ],
      "path": [
...
      ]
    }
  ],
  "data": {
    "ple_asset": {
      "entities": {
        "edges": [
          {
            "node": {
              "name": "TST",
              "shotgun_model": null
            }
          },
          {
            "node": {
              "name": "NIJ",
...

Results from apollo smart query:

Global error handler {error: Error: GraphQL error: 'NoneType' object has no attribute 'value'
GraphQL error: 17 is not a valid s…}
update: {}
We got some result! {}__proto__: Object false 7
We've got an error! Error: GraphQL error: 'NoneType' object has no attribute 'value'
GraphQL error: 17 is not a valid shotgun server id.
    at new ApolloError (bundle.esm.js?74ca:63)
    at eval (bundle.esm.js?74ca:1641)
    at Object.next (Observable.js?a7b2:308)
    at notifySubscription (Observable.js?a7b2:130)
    at onNotify (Observable.js?a7b2:165)
    at SubscriptionObserver.next (Observable.js?a7b2:219)
    at eval (bundle.esm.js?74ca:858)
    at Set.forEach (<anonymous>)
    at Object.next (bundle.esm.js?74ca:858)
    at notifySubscription (Observable.js?a7b2:130)
Narretz commented 4 years ago

Have you set the errorPolicy? https://www.apollographql.com/docs/react/data/error-handling/

disarticulate commented 3 months ago

have same issue, but with $apollo.mutate, I can confirm options { errorPolicy: 'all' } is passed into the client.mutate and i've tried to set it as the defaultOptions, function but e.graphQLErrors?.length === 0 is empty. I can see the error coming back from the response:

{
    "errors": [
        {
            "message": "Variable \"$documents\" is never used in operation \"CreateCertificationLog\".",
            "locations": [
                {
                    "line": 1,
                    "column": 154
                }
            ],
            "stack": "GraphQLError: Variable \"$documents\" is never used in operation \"CreateCertificationLog\".\n    at Object.leave (/app/node_modules/graphql/validation/rules/NoUnusedVariablesRule.js:38:33)\n    at Object.leave (/app/node_modules/graphql/language/visitor.js:344:29)\n    at Object.leave (/app/node_modules/graphql/utilities/TypeInfo.js:390:21)\n    at visit (/app/node_modules/graphql/language/visitor.js:243:26)\n    at Object.validate (/app/node_modules/graphql/validation/validate.js:69:24)\n    at parseQuery (/app/node_modules/postgraphile/build/postgraphile/http/createPostGraphileHttpRequestHandler.js:270:48)\n    at /app/node_modules/postgraphile/build/postgraphile/http/createPostGraphileHttpRequestHandler.js:680:63\n    at Array.map (<anonymous>)\n    at graphqlRouteHandler (/app/node_modules/postgraphile/build/postgraphile/http/createPostGraphileHttpRequestHandler.js:643:52)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
        }
    ]
}

Trying to trace the error seems impossible, as all the client function calls for mutate don't appear to be used. Somehow, whatever $apollo.mutate is using to perform the mutation is bypassing everything and not taking the options.

quite confusing.