-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[apollo-server-koa] Error is missing message and properties when thrown inside the parse of a custom scalar type #2399
Comments
Try upgrading |
Thanks for reporting this issue originally! I'm going to close this issue since it hasn't received a lot of traction and could have been resolved already. If this is still a problem, would someone who's experiencing the problem (or anyone who comes across this issue and is able to assist) mind building a reproduction of the problem in to a runnable CodeSandbox reproduction using the latest version of Apollo Server and sharing the link to that CodeSandbox in this issue? I'm happy to re-open if this is still occurring and someone can provide a reproduction. Thanks again! |
Probably similar to #2155, but since that issue hasn't got a response yet and I am experiencing slightly different behaviour I think it justifies opening a separate issue for it.
Any errors thrown in the
parseValue
/parseLiteral
of a custom scalar type swallows part of the original error either when simply throwing anError
orApolloError
instance.I am using apollo-server-koa v2.4.8 as a middleware:
My schema is pretty basic still, but I am using a custom schema directive:
where the
UUIDDirective
is of the formIn the parse methods of
UUIDType
I do some validation on the field value. If it is not in UUID format I throw an error like so:Here
Validator.validate(name, value, ['uuid']);
simply throws aValidationError
when the field value is not in UUID format.ValidationError
is a simple error that extendsError
:The
@uuid
directive is then applied to a query type like so:Everything seems to work fine, but I get inconsistent results using the 3 different ways of throwing an error. Only the 3rd option give me a satisfactory response.
For
ApolloError
I receive the following response:For
ValidationError
I receive the following response:For
GraphQLError
I receive the (desired) response:So to make a long story short: why are the error message (and any additional properties in the case of
ApolloError
) lost when throwing an instance ofApolloError
orError
? I at least would like to have access to the error message, that is pretty essential.On a related note; I found that
formatError
is not called when specifying it on thegraphqlKoa
middleware. There is already an issue open for this #1439 and a PR has been submitted #1662, but it doesn't seem the problem has been solved so far.The text was updated successfully, but these errors were encountered: