Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error data from binding is not available #213

Closed
terion-name opened this issue Dec 21, 2018 · 5 comments
Closed

error data from binding is not available #213

terion-name opened this issue Dec 21, 2018 · 5 comments

Comments

@terion-name
Copy link

const delegate = new Binding({schema: service.remoteSchema});
let response = null;
    try {
      response = await delegate.delegate(infoCopy.operation.operation, infoCopy.fieldName, args, infoCopy, {context: ctx ? ctx : {}});
    } catch (e) {
      console.log(e);
      console.log(JSON.stringify(e));
    }

I run a mutation. Underlying service returns error with data:

  "data": {
    "createMunicipality": null
  },
  "errors": [
    {
      "message": "validation",
      "locations": [
        {
          "line": 29,
          "column": 2
        }
      ],
      "data": {
        "data.alias": [
          "Таке посилання вже зареєстровано, будь-ласка, оберіть інше."
        ]
      }
    }
  ]
}

But here I get the following:

{ Error: validation
    at new CombinedError (CONVERT($1 using utf8mb4)/node_modules/graphql-binding/node_modules/graphql-tools/src/stitching/errors.ts:90:5)
    at Object.checkResultAndHandleErrors (CONVERT($1 using utf8mb4)/node_modules/graphql-binding/node_modules/graphql-tools/src/stitching/errors.ts:111:11)
    at CheckResultAndHandleErrors.transformResult (CONVERT($1 using utf8mb4)/node_modules/graphql-binding/node_modules/graphql-tools/src/transforms/CheckResultAndHandleErrors.ts:15:12)
    at CONVERT($1 using utf8mb4)/node_modules/graphql-binding/node_modules/graphql-tools/src/transforms/transforms.ts:37:45
    at Array.reduce (<anonymous>)
    at applyResultTransforms (CONVERT($1 using utf8mb4)/node_modules/graphql-binding/node_modules/graphql-tools/src/transforms/transforms.ts:35:21)
    at CONVERT($1 using utf8mb4)/node_modules/graphql-binding/node_modules/graphql-tools/src/stitching/delegateToSchema.ts:104:12
    at step (CONVERT($1 using utf8mb4)/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:31:23)
    at Object.next (CONVERT($1 using utf8mb4)/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:12:53)
    at fulfilled (CONVERT($1 using utf8mb4)/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:3:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  message: 'validation',
  locations: [ { line: 1, column: 12 } ],
  path: [ 'MunicipalityPrivate', 'createMunicipality' ] }

{"message":"validation","locations":[{"line":1,"column":12}],"path":["MunicipalityPrivate","createMunicipality"]}

Thus, error data from underlying service is not available. How can I get it?

@maticzav
Copy link
Collaborator

@terion-name I believe this is a duplicate of #173. Please review other issues next time before submitting new ones.

If you believe this is not related to the referenced issue, please reopen this issue and provide a reproduction Github repository or CodeSandbox, whichever works best for you. 🙂

@terion-name
Copy link
Author

@maticzav no, it is not a duplicate, read carefully please. I don't get [Object object], I get a proper error with proper message string. My issue that error from delegator does not contain additional arbitrary data that is included in error payload by underlying service and what is allowed by graphql spec as far as I am concerned. This kind of errors that we use specifically is Apollo errors standart (https://www.npmjs.com/package/apollo-errors).

And this looks like a design flaw, because I get only those data pieces that are in generic GraphqlError type. So it seems that delegator builds a GraphqlError from error payload and simply drops all other data and gives no way to access raw error data makeing just impossible to properly handling any custom errors, e.g. validation, authorization or others.

And no, I can't reopen issues in this repo

@maticzav
Copy link
Collaborator

Hey @terion-name, yes, you are getting a proper error because you are logging it and #173 gets [Object object] because GraphQL handles it.

If you still believe this issue should be treated differently from the referenced one, please provide a thorough reproduction repository as mentioned above. Thanks 🙂

@terion-name
Copy link
Author

@maticzav it has nothing to do with that issue and has nothing to do with handling it in graphql renderer! just read what am I writing about and what the issue is about!

@abhiaiyer91
Copy link
Collaborator

abhiaiyer91 commented Dec 23, 2018

this issue and the other are different symptoms of the same bug in the underlying graphql-tools. The way graphql tools decorates and forwards errors seems to miss out on some properties. @terion-name
probably best to track the progress of this issue in #173!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants