-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
Resolve empty union objects within Sum schema derivation & cleanups #2121
Resolve empty union objects within Sum schema derivation & cleanups #2121
Conversation
// NOTE: This object extends AbstractFunction1 to maintain binary compatibility for Scala 2.13. | ||
// TODO: Remove inheritance in the next major version | ||
object __DeprecatedArgs extends AbstractFunction1[Option[Boolean], __DeprecatedArgs] { | ||
val include: __DeprecatedArgs = __DeprecatedArgs(Some(true)) | ||
|
||
def apply(v: Option[Boolean] = None): __DeprecatedArgs = new __DeprecatedArgs(v) | ||
} |
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.
Fairly annoying we have to extend AbstractFunction1
to make MiMA happy with Scala 2.13. We can remove this for 2.6.0
@@ -1,10 +1,11 @@ | |||
package caliban.schema | |||
|
|||
import caliban.ResponseValue.ObjectValue |
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.
Are imports right?
@@ -1,7 +1,8 @@ | |||
package caliban.schema | |||
|
|||
import caliban.CalibanError.ExecutionError | |||
import caliban.Value.NullValue | |||
import caliban.ResponseValue.ObjectValue |
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.
Unused imports ?
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.
Removed. By the way shall we add a linter to check for unused imports and run it during CI only? It's pretty easy to miss them unfortunately
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.
Yeah that'd be nice.
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.
Ok I'll add it in a separate PR 👍
The main optimization in this PR is that we avoid matching on
PureStep(EnumValue(v))
for all steps by delegating this responsibility to the derived Sum schema.Other cleanups & minor optimizations that I came across while working on this PR:
__DeprecatedArgs.include
since we've been using__DeprecatedArgs(Some(true))
quite a lotField#allFieldsUniqueNameAndCondition
by avoiding creation of the HashSet when there's only 1 queried field in the objectWith these changes, we see ~10% improvement in execution of simple queries (where only the top-level field is effectful) and ~5% for cases that fields contain ZQueries