0xPlaygrounds / 0xPlaygrounds/subgrounds

Better `FieldPath` argument validation

Đang mở
#10 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
73
Fork
12
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**Is your feature request related to a problem? Please describe.** Yes. When constructing `FieldPaths` with arguments, any extra arguments (i.e.: arguments which don't exist in the subgraph schema) are silently ignored, leading to harder debugging in case of errors like typos.

Moreover, although the values of real arguments are type-checked, the exceptions are cryptic and uninformative.

**Describe the solution you'd like** When constructing `FieldPaths` with arguments, for each argument, Subgrounds should check whether:

1. The argument exists in the schema
2. The type of the argument's value matches the type indicated in the schema
3. If using relative `FieldPaths` (e.g.: `subgraph.Query.entities(orderBy=subgraph.Entity.field)`), validate that the field type on which that argument is applied matches the type of the relative `FieldPath` (i.e.: the type of `entities` matches the `Entity` object).

Error messages should also be clear and informative. E.g.: "X is not a valid value for argument orderBy".

**Describe alternatives you've considered** None

**Additional context** None

**Implementation checklist**

* [ ] Validate arguments
* [ ] Check whether the argument exists in the schema
* [ ] Check whether the value given to the argument matches the type specified in the schema
* [ ] Check whether relative `FieldPaths` match the type of the field
* [ ] Improved error messages

*Originally from: cvauclair*

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Look at the FieldPath class and its argument handling. The subgraph schema is used for validation. Start by understanding how arguments are currently passed and ignored. Check the schema for argument definitions and types. Write validation logic that raises clear error messages for missing arguments or type mismatches. Test with a subgraph query to ensure errors are informative.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
graphql, python
Lĩnh vực
backend-api-design, devtools
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.