-
Notifications
You must be signed in to change notification settings - Fork 222
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
DRAFT / WIP: Limit number of errors returned (when variables are used) #1022
DRAFT / WIP: Limit number of errors returned (when variables are used) #1022
Conversation
@@ -43,7 +44,9 @@ case class Executor[Ctx, Root]( | |||
userContext, | |||
exceptionHandler, | |||
scalarMiddleware, | |||
false)(um) | |||
false, | |||
errorsLimit = queryValidator.errorsLimit |
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.
The idea was to define errorsLimit only once (e.g. on the queryValidator) and re-use in other places
.flatMap(v => | ||
def isValidValue[In](tpe: InputType[_], input: Option[In], errors: ListBuffer[Violation])(implicit | ||
um: InputUnmarshaller[In]): Vector[Violation] = { | ||
// TODO: NEED TO ADD VALUES TO `errors` to make it work properly |
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.
This code doesn't work correctly because I don't mutate errors buffer, but this is one of the options how it can be implemented
val errors = errorsLimit match { | ||
case Some(limit) => allErrors.take(limit) | ||
case _ => allErrors | ||
} |
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 seems like there are other places where violations could be returned, but I'm not sure if they should be updated as well.
@@ -12,6 +12,7 @@ import scala.reflect.{ClassTag, classTag} | |||
|
|||
trait QueryValidator { | |||
def validateQuery(schema: Schema[_, _], queryAst: ast.Document): Vector[Violation] | |||
def errorsLimit: Option[Int] |
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.
Making it public so it can be re-used?
Thanks for PR. |
Got it! I was looking for some guidance on the best way/place to fix it. I guess I will need to dig deeper into the logic then 😃 |
Closing in favor of #1034 |
Follow up to #1017
The solution from the previous PR works only for cases where input is specified (hardcoded) as a part of the query but doesn't work/executed when variables are used. For example, the following query will still return an unlimited number of errors:
@yanns I'd appreciate your guidance here on the best way to design it 🙂