-
Notifications
You must be signed in to change notification settings - Fork 22
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
Disable default ordering in GraphQL queries #5380
Conversation
CodSpeed Performance ReportMerging #5380 will not alter performanceComparing Summary
|
772f747
to
b9e863d
Compare
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.
Great work.
Instead of passing a dict to the function I think it would be best to use a proper dataclass or Pydantic model this way it will be easier to support additional option in the future.
b9e863d
to
5eb2d19
Compare
# Conflicts: # backend/infrahub/core/query/node.py
5eb2d19
to
24270c2
Compare
backend/infrahub/core/query/node.py
Outdated
@@ -901,8 +918,8 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: | |||
self.params["uuid"] = self.filters["id"] | |||
elif not self.has_filters and not self.schema.order_by: | |||
use_simple = True | |||
self.order_by = ["n.uuid"] | |||
|
|||
if self.order is None or self.order.disable is not True: |
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 logic looks surprising to me ...
backend/infrahub/core/query/node.py
Outdated
continue | ||
self.order_by.append(far.node_value_query_variable) | ||
self.order_by.append("n.uuid") | ||
if should_order: |
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.
even if the order is disabled we should also order by uuid to guarantee the pagination
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 did not have that in mind
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.
Some additional context for the self.order_by.append("n.uuid")
: #4704
if far.supports_profile: | ||
self.order_by.append(far.final_value_query_variable) | ||
continue | ||
self.order_by.append(far.node_value_query_variable) |
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.
I let this block within should_order
branch condition as this block seems only related to ordering.
936b255
to
47bcab8
Compare
47bcab8
to
3f53022
Compare
backend/infrahub/core/query/node.py
Outdated
use_simple = True | ||
self.add_to_query(" AND n.uuid = $uuid") | ||
return | ||
if not self.has_filters and not self.schema.order_by: |
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.
should we also check if order is disabled here and exit early ?
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.
If this condition is met, we set self.order_by
to ["n.uuid"]
in order to guarantee pagination, and we exit early. As schema.order_by
is empty, it feels like we do not even need to check for order
?
f5a8a5f
to
928bb42
Compare
928bb42
to
5a4d686
Compare
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.
great work
Implements #5376
Later PR will come to support it within SDK