Cannot throw error with custom properties #5345
-
Hi, according to the Error handling page in the Apollo Server docs, it's possible to add arbitrary fields to the error's However, looking at the source of the apollo-server-error package, I see that only Code that can be used to validate this: import { AuthenticationError, UserInputError} from "apollo-server-errors";
// this works fine
throw new UserInputError('Invalid argument value', {
argumentName: 'id'
});
// typescript compiler raises error (TS2554: Expected 1 arguments, but got 2.)
throw new AuthenticationError('Invalid authentication', {
argumentName: 'id'
}); Is this intentional behavior or a bug? Thought I should mention it here first before issuing a bug report just in case I'm misinterpreting the docs somehow. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
See #5307 / #5309 |
Beta Was this translation helpful? Give feedback.
See #5307 / #5309
This is being improved in the imminent 3.0.0. Some other errors haven't had that added yet; you can look into the concerns @bristoljon ran into with the other error classes if you'd like.