-
-
Notifications
You must be signed in to change notification settings - Fork 251
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
Allow skipping ValidationWrapper
for introspection queries
#1837
Conversation
In my opinion we should always skip it for introspection. Not much point of having it in that case, right? |
Ideally I think we should do this, I agree. My main concern though is that our This is the main reason I'm also partially inclined for the method to accept a |
How about something more generic, like |
@ghostdogpr what do you think about making it a final method on |
Method sounds good! |
maxDepth
and maxFields
validations for introspectionValidationWrapper
for introspection queries
@ghostdogpr I'll add a unit test just in case before merging in |
final def skipForIntrospection: ValidationWrapper[R] = new ValidationWrapper[R] { | ||
override val priority: Int = self.priority | ||
|
||
override def wrap[R1 <: R]( | ||
f: Document => ZIO[R1, ValidationError, ExecutionRequest] | ||
): Document => ZIO[R1, ValidationError, ExecutionRequest] = | ||
(doc: Document) => | ||
if (doc.isIntrospection) f(doc) | ||
else self.wrap(f)(doc) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghostdogpr turns out we can't simply override apply
and |+|
. Do we think there might be cases where someone implemented custom logic in those methods?
For apply
, I could get this to work, but looks rather weird so I left it out - let me know if you think we should add it:
override def apply[R1 <: R](that: GraphQL[R1]): GraphQL[R1] = super.apply(self.apply(that))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably okay
Introspection queries are relatively large + deep, so in order for introspection to be allowed we need for these wrappers to allow 250+ fields and 12 levels depth. With this PR, we can disable these checks for introspection queries.One other way that this could be implemented is to be able to set a separate limit for introspections, e.g.,:Thoughts?EDIT: This PR now adds the
skipForIntrospection
method which returns a new ValidationWrapper that is skipped for introspection queries.