Custom GraphQlQuery using set_limit on nested edge field can result in the limit turning negative when querying
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Bắt đầu trong ayon_api/graphql.py, đặc biệt là ở đường dẫn xây dựng truy vấn xung quanh lệnh gọi truy vấn bị lỗi tại dòng 376. Chạy bản tái hiện thư mục/sản phẩm lồng nhau được cung cấp với các giá trị folder_limit và product_limit khác nhau, sau đó xác minh rằng các giới hạn được tạo không bao giờ trở thành số âm và máy chủ nhận được giới hạn con được yêu cầu mà không có GraphQlQueryFailed.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is there an existing issue for this?
- I have searched the existing issues and added correct labels.
Description
Current Behavior
When creating a custom GraphQlQuery object, if you use set_limit on a nested edge field (e.g products in folders), the edge field limit can turn negative unexpectedly if you query some amount of entities from the parent edge field and will raise this error.
File "C:\Users\user\AppData\Local\Ynput\AYON\app\AYON 1.6.3\dependencies\ayon_api\graphql.py", line 376, in query
raise GraphQlQueryFailed(response.errors, query_str, variables)
ayon_api.exceptions.GraphQlQueryFailed: GraphQl query Failed: LIMIT must not be negative on item 'project/folders/edges/0/node/products' (Line 7 Column 11)
Expected Behavior
The limit should be calculated correctly when querying the server and match the one given.
Steps To Reproduce:
Here is a script you can use in the AYON Launcher's Console or with ayon_api with the right env vars set up. This assumes you have a project already containing a certain amount folders and products, this example uses folder and products but you can apply it to any parent/child edge field case.
Exact conditions in which the error occur seem to depend on the contents of the project, however running the script as is should trigger it, as it queries all folders from the project and sets a limit to queried products. Setting a high limit for the parent field and a lower one for the child field should also trigger it. You can mess with the folder_limit and product_limit arguments to see different results.
from ayon_api.graphql import GraphQlQuery
from ayon_api import get_server_api_connection, get_folders
from pprint import pprint
project_name = "projectname"
def simple_graphql_query(
project_name,
folder_limit=None,
product_limit=None,
):
"""Creates a simple GraphQL query to get products from
a list of folder ids.
"""
simple_query = GraphQlQuery("SimpleQuery")
# Project field
project_field = simple_query.add_field("project")
project_field.set_filter("name", project_name)
# Folders field
folders_field = project_field.add_field_with_edges("folders")
if folder_limit:
folders_field.set_limit(folder_limit)
folders_field.add_field("name")
# Products field
products_field = folders_field.add_field_with_edges("products")
if product_limit:
products_field.set_limit(product_limit)
products_field.add_field("name")
return simple_query
my_query = simple_graphql_query(
project_name=project_name,
folder_limit=None, # parent edge field
product_limit=5 # nested child edge field
)
con = get_server_api_connection()
my_query_data = my_query.query(con)
pprint(my_query_data)
The conditions in which the problem manifest depend also on the ayon_api version coming with the launcher :
- 1.2.4 (1.4.2 launcher) : If the number of parent edge field entities queried is strictly superior to 300 then
ayon_api.exceptions.GraphQlQueryFailedwill be raised. - 1.2.22 (1.6.3 launcher) and 1.2.23 : condition seem to vary much more but a parent edge field amount higher than that of the nested child edge seem to trigger it.
Additional context:
Version
Server : 1.15.17
Launcher : 1.4.2 and 1.6.3
ayon-python-api : 1.2.4, 1.2.22 and 1.2.23
Platforms
Windows, Mac
Relevant log output:
- Ngôn ngữ chính
- Python
- Star
- 16
- Fork
- 15
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 10
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ynput/ayon-python-api
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ynput/ayon-python-api#351 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
ynput/ayon-python-api#199 ·
-
ynput/ayon-python-api#198 · 1 người được giao ·
-
Implement ayon uris endpoint Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 50/100
ynput/ayon-python-api#182 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 55/100
ynput/ayon-python-api#181 ·
Tất cả issue của ynput/ayon-python-api
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100