-
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
Extensions in ApolloError can only contain code #2917
Comments
Ok so i have determined this is due to the |
@joepuzzo I experience the same issue in my project. My hacky solution was to overwrite the |
@SekibOmazic Yeah i ended up Extending |
Hi @joepuzzo, Can you show an example of how did you extend
|
|
@Benrozenberg Remember all the stuff in
|
@joepuzzo thanks, it seems like we are doing the same thing. Unfortunately even with your code I still cannot get the exception in the client. |
Hi @Benrozenberg! I was able to get around this problem this way
However, I am wondering whether Apollo tooling (e.g. Engine, Apollo-client) would be sensitive to |
Hi @yuchristina, I think your solution should not cause any problem and you can do both but if you think it might why don't you create a new property (myCode) instead of overriding code property? anyways if it helps i ended up doing as follow :
After formating error this allows me to send different messages to the server and to the client |
Hey @joepuzzo, @yuchristina, @SekibOmazic, @Benrozenberg, and other interested parties 👋 I've opened a PR to make sure I'm understanding the issue(s) at hand correctly. It seems that we have multiple issues to address, so I've started with a couple test cases for validation from you all. These tests are currently failing as expected. Please feel free to @ me here or comment on the PR with anything that's incorrect or overlooked. Confirmed ✅
Uncertain / needs clarification: |
So I had made this comment a while ago and now noticed that apollo seems to correctly set the additional fields in extensions. |
According to the graphql spec.
"GraphQL services may provide an additional entry to errors with key extensions. This entry, if set, must have a map as its value. This entry is reserved for implementors to add additional information to errors however they see fit, and there are no additional restrictions on its contents."
"GraphQL services should
NOT
provide any additional entries to the error format since they could conflict with additional entries that may be added in future versions of this specification."SPEC >>> https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md
But it looks like when constructing an Apollo Error it will only allow you to shove the code into extensions. Why don't additional properties end up on extensions OR will the constructor allow you to pass extensions.
apollo-server/packages/apollo-server-errors/src/index.ts
Line 35 in 6ffec8e
The text was updated successfully, but these errors were encountered: