You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Throwing a ForbiddenError with extra fields as described here does not work and the errors array received by the client contains an extensions field with only the standard Apollo fields.
However the extra fields do appear in the response if using a UserInputError but I would expect them to be consistent.
Perhaps this is by design but if that is the case it would be good to update the docs at url above. And we do have a use case where a ForbiddenError is the right choice semantically but we need to include extra data in the response as well.
It looks like ForbiddenError's constructor doesn't pass through an extensions argument to its superclass like UserInputError does. Adding that (I'd say to all the ApolloError subclasses except the two persisted query ones which probably shouldn't be thrown from end-user code) sounds reasonable. Feel free to file a PR against the release-3.0 branch!
glasser
changed the title
ForbiddenError does not include extra custom fields
Most of the predefined ApolloError subclasses fail to pass through extensions to ApolloError
Jun 15, 2021
"apollo-server": "^2.18.2",
"apollo-server-express": "^2.24.0",
Throwing a ForbiddenError with extra fields as described here does not work and the errors array received by the client contains an extensions field with only the standard Apollo fields.
Results in:
However the extra fields do appear in the response if using a
UserInputError
but I would expect them to be consistent.Perhaps this is by design but if that is the case it would be good to update the docs at url above. And we do have a use case where a
ForbiddenError
is the right choice semantically but we need to include extra data in the response as well.Code sandbox: https://codesandbox.io/s/eloquent-mclean-f9v1l?file=/index.js:264-445
Thanks,
Jon
The text was updated successfully, but these errors were encountered: