GithubHelp home page GithubHelp logo

Comments (12)

kamilmysliwiec avatar kamilmysliwiec commented on April 19, 2024 1

This isn't AuthGuard issue. I did a small research and it seems that this is how apollo serializes thrown error. If you throw "Test", it would print the following output:

Error: Test

Whilst message property of the HttpException is an object. Regardless of this weird console output, the GraphQL response looks perfectly fine:
image

from passport.

kamilmysliwiec avatar kamilmysliwiec commented on April 19, 2024

Duplicate of #4 🙂

from passport.

cdiaz avatar cdiaz commented on April 19, 2024

They are different bugs.
I've updated to version v1.0.9 and this still persists.

from passport.

kamilmysliwiec avatar kamilmysliwiec commented on April 19, 2024

Please, make sure to get rid of internal @nestjs/common package installed by @nestjs/passport (full path: node_modules/@nestjs/passport/node_modules/@nestjs/common)

from passport.

cdiaz avatar cdiaz commented on April 19, 2024

node_modules/@nestjs/passport/node_modules/@nestjs/common is not present, and still the error keeps appearing

nestjs tree

from passport.

ph55 avatar ph55 commented on April 19, 2024

Okay.

But in general, if framework handled exception and proper response returned -
why it should be displayed in console ?

I mean, exception usually means something wrong happened in your application - and you want to crash it.

Don't you agree, @kamilmysliwiec ?

from passport.

kamilmysliwiec avatar kamilmysliwiec commented on April 19, 2024

This output comes from the Apollo server @ph55

from passport.

ph55 avatar ph55 commented on April 19, 2024

I understand that.

But, you have power of suppressing such errors when wrapping it, don't you? Or am I wrong.
It's just question of design.

from passport.

kamilmysliwiec avatar kamilmysliwiec commented on April 19, 2024

@ph55, yeah, you have, using formatError option from Apollo. It has nothing to do with Nest.

from passport.

ph55 avatar ph55 commented on April 19, 2024

I don't think formatError helps much.
I'll explain in another example.

User authentication service:

    const AuthenticationError = createError('AuthenticationError', {
      message: 'Username or password are incorrect'
    });

    if (!match) {
      throw new AuthenticationError();
    }

Using format error gives me desired result in output:

{
	"data": {
		"login": null
	},
	"errors": [
		{
			"message": "Username or password are incorrect",
			"name": "AuthenticationError",
			"time_thrown": "2018-06-24T13:47:39.214Z",
			"data": {}
		}
	]
}

But error still thrown in console:

[Nest] 4060   - 2018-6-24 16:47:37   [NestApplication] Nest application successfully started +30ms
AuthenticationError: Username or password are incorrect
    at UserService.<anonymous> (C:\Users\alex\Documents\_dev\nest-apps\src\@core\user\user.service.ts:51:13)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\alex\Documents\_dev\nest-apps\src\@core\user\user.service.ts:16:58)
    at <anonymous>

So the questions are:

  1. Why its still thrown.
  2. How to suppress it.
  3. Am I stupid ?

from passport.

ph55 avatar ph55 commented on April 19, 2024

It's apollo-server config.
apollographql/apollo-server#894

Thanks for help.

from passport.

cojack avatar cojack commented on April 19, 2024

Any progress?

from passport.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.