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

CustomScalarType validation and GraphQLError handling #1142

Closed
damianopetrungaro opened this issue Dec 13, 2017 · 2 comments
Closed

CustomScalarType validation and GraphQLError handling #1142

damianopetrungaro opened this issue Dec 13, 2017 · 2 comments

Comments

@damianopetrungaro
Copy link

I am having a strange issue (or maybe it's just missing some documentation about it)

In this repo (few days ago) i was returning a GraphQLError when resolving a CustomScalarType if something went wrong and i retrieved the right error message by the playground client.
Here the "old" code
https://github.com/damianopetrungaro/graphql-node/commit/a9946a5df49845e80f80e1d0a29ed10b6339ac4c#diff-2878e9a978828e48f5975c2fa793fe64R153

After some code refactoring, the playground instead of showing the error correctly just show a 500 message with the unhandled Error it does not happen anymore:
https://github.com/damianopetrungaro/graphql-node/blob/master/api/src/usersContext/resolvers/index.js#L35

Any idea where i am wrong, or this is an issue by a new version?

The query for see the differences is:

mutation {
  createUser(name: "John", surname: "Wally", age: 1000) {
    id
    name
    surname
    age
  }
}

For "old" version: git checkout a9946a5
For refactored version: git checkout master

@leebyron
Copy link
Contributor

leebyron commented Jan 8, 2018

Sorry for the delay getting to this, but it looks like your master branch has moved considerably since you opened this.

Some general feedback from looking at the code, you shouldn't need a try/catch/return pattern, just allow the error to be thrown.

I also suggest ensuring you're using the latest version of this library, since the most recently released version fixed some issues with handling errors from custom scalars.

@leebyron leebyron closed this as completed Jan 8, 2018
@damianopetrungaro
Copy link
Author

@leebyron i confirm that a lot of issues has been fixed, now i can throw error as i were doing before the library started to have strange behaviours

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