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

Need context access in formatError #2355

Closed
barry-dutton-ck opened this issue Feb 21, 2019 · 5 comments
Closed

Need context access in formatError #2355

barry-dutton-ck opened this issue Feb 21, 2019 · 5 comments

Comments

@barry-dutton-ck
Copy link

barry-dutton-ck commented Feb 21, 2019

Applies to: apollo-server-hapi (and probably more)

The formatError function which you can pass into ApolloServer when starting has no way to gain access to context (or request). In previous versions (the old graphql-server-hapi), we had access to this. In our workflows, this is necessary because we log these errors using the request log (which we have access to in context) and then mask the errors going back to the client them depending on the environment. Is there any way you could add the capability to access context as an argument to this function?

@barry-dutton-ck barry-dutton-ck changed the title No context access in formatError Need context access in formatError Mar 4, 2019
@vincentdesmares
Copy link

We have the same issue with express. We use the context to know in which language the error should be translated.

It would be awesome to have it as a second argument.

@barry-dutton-ck
Copy link
Author

@bigmaster Awesome! That's definitely a helpful workaround to get a usable error formatter. I would still love to see it be a part of the actual exposed function from apollo-server though. Doubly so because I believe the one apollo exposes is actually created the same way that the one you created is!

@martijnwalraven
Copy link
Contributor

formatError isn't the right place to report errors from, but we've recently exposed a didEncounterErrors function as part of the new request pipeline API: #2719

@arizonatribe

This comment has been minimized.

@Sytten
Copy link

Sytten commented Jun 30, 2020

@martijnwalraven The errors of this hook are readonly, what if you need to modify errors with information from the context?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants