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

Add NO_INTROSPECTION to ApolloServerErrorCode and set the code when throwing #7033

Closed
barryhagan opened this issue Oct 12, 2022 · 2 comments
Closed
Labels
📚 good-first-issue Issues that are more approachable for first-time contributors. 🍐 error-handling Pertaining to error handling (or lack thereof), not just for just general errors/bugs.

Comments

@barryhagan
Copy link
Contributor

When introspection is disabled, a ValidationRule is added that will throw a GraphQLError if an introspection request is received. If you are logging server errors, there can be a lot of noise if someone is attempting to introspect your production servers. To date, we have needed to filter these errors by string matching on the error message, which is not great.

Apollo Server v4 introduced the ApolloServerErrorCode enum. It would be nice to see NO_INTROSPECTION added to this enum and then used as the error.extensions.code when you throw the NoIntrospection validation rule here:
https://github.com/apollographql/apollo-server/blob/main/packages/server/src/ApolloServer.ts#L77

Perhaps add a concrete NoIntrospectionError to internalErrorClasses as well, although that doesn't help someone who would like to use an exported type to check

if (error instanceof NoIntrospectionError)
@glasser
Copy link
Member

glasser commented Oct 12, 2022

That's a nice idea! Would you like to send a PR?

We explicitly don't want instanceof checks — we found that ran into too many problems when npm installed multiple copies of a library.

The only downside is that in theory graphql-js might implement this natively and it might in that case be hard to detect the error.

@glasser glasser added 📚 good-first-issue Issues that are more approachable for first-time contributors. 🍐 error-handling Pertaining to error handling (or lack thereof), not just for just general errors/bugs. labels Oct 12, 2022
@trevor-scheer
Copy link
Member

trevor-scheer commented Oct 20, 2022

Fixed via #7035

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
📚 good-first-issue Issues that are more approachable for first-time contributors. 🍐 error-handling Pertaining to error handling (or lack thereof), not just for just general errors/bugs.
Projects
None yet
Development

No branches or pull requests

3 participants