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

Using with GraphQl (resolver) #9

Closed
renehauck opened this issue Mar 27, 2019 · 5 comments
Closed

Using with GraphQl (resolver) #9

renehauck opened this issue Mar 27, 2019 · 5 comments

Comments

@renehauck
Copy link

First of all many thanks for this great package 👍 Now I have a problem using this package with grapqhl (resolver).
I always get the following output when a graphql error occurs:

{
  "errors": [
    {
      "message": "Cannot read property 'raw' of undefined",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "ArticleListAll"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "TypeError: Cannot read property 'raw' of undefined",
            "    at RenderFilter.<anonymous> (/home/rene/Projects/SmashoBase/nest/smasho-base/node_modules/nest-next/dist/render.filter.js:36:33)",
            "    at Generator.next (<anonymous>)",
            "    at /home/rene/Projects/SmashoBase/nest/smasho-base/node_modules/nest-next/dist/render.filter.js:16:71",
            "    at new Promise (<anonymous>)",
            "    at __awaiter (/home/rene/Projects/SmashoBase/nest/smasho-base/node_modules/nest-next/dist/render.filter.js:12:12)",
            "    at RenderFilter.catch (/home/rene/Projects/SmashoBase/nest/smasho-base/node_modules/nest-next/dist/render.filter.js:28:16)",
            "    at ExternalExceptionsHandler.invokeCustomFilters (/home/rene/Projects/SmashoBase/nest/smasho-base/node_modules/@nestjs/core/exceptions/external-exceptions-handler.js:33:32)",
            "    at ExternalExceptionsHandler.next (/home/rene/Projects/SmashoBase/nest/smasho-base/node_modules/@nestjs/core/exceptions/external-exceptions-handler.js:12:29)",
            "    at /home/rene/Projects/SmashoBase/nest/smasho-base/node_modules/@nestjs/core/helpers/external-proxy.js:12:42",
            "    at process._tickCallback (internal/process/next_tick.js:68:7)"
          ]
        }
      }
    }
  ],
  "data": {
    "ArticleListAll": null
  }
}

Also "setErrorHandler" is not triggered. A normal controller triggers it.

Thanks for your help

@kyle-mccarthy
Copy link
Owner

This is pretty interesting... I get the request and response from nest by calling ctx.getArgs() but this is saying that your request is undefined (which I didn't know is possible).

Would you provide me with a minimal reproducible example?

@renehauck
Copy link
Author

Of course... Here is the example:

https://github.com/renehauck/nest-next-render-error

Just start, open the page "http://localhost:3000/graphql" and execute the query

{
  Hello
}

Normally the error "Ups" should appear, but instead the error "Cannot read property 'raw' of undefined" is thrown again.

@kyle-mccarthy
Copy link
Owner

Thank you for that example, it was extremely helpful. I just released v0.6.1 with a fix for your bug. Let me know if you have any other issues!

@renehauck
Copy link
Author

renehauck commented Mar 29, 2019

ok, the ".raw"-error is gone, but now I don't get any more errors which are thrown in the resolvers. 😃

   if (response && request) {
      const requestHandler = this.service.getRequestHandler();
      const errorRenderer = this.service.getErrorRenderer();
       ....
       return errorRenderer(err, req, res, pathname, query);
      }
    }
    else throw err;
   ^^^^^^^^^^^^^^^^

I think there's an "else throw err;" missing at the end, right? 😊

@kyle-mccarthy
Copy link
Owner

Yes, you are correct! I pushed v0.6.3 with this, sorry for prematurely closing the issue.

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

2 participants