Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

intelligible errors on schema creation.

Đang mở
#1,315 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api, backend-api-design

Hướng nghiên cứu

Traceback trỏ đến graphene/types/schema.py, graphene/types/typemap.py và graphql/type/definition.py; hãy bắt đầu bằng cách lần theo quá trình tạo schema đến bước xác thực các trường của Query. Hãy để các lỗi xác định lớp Query/ObjectType không hợp lệ và xác minh rằng exception kết quả có chứa tên của lớp đó.

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

Mô tả

✨ enhancement

When creating a schema, if there is a problem with one of your QueryObjects, the resulting error message and traceback does not give any indication as to which ObjectType class is broken.

ex)

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/user/sonicsd/src/api/graphql.py", line 30, in schema
  File "/usr/local/lib/python3.7/dist-packages/graphene/types/schema.py", line 78, in __init__
    self.build_typemap()
  File "/usr/local/lib/python3.7/dist-packages/graphene/types/schema.py", line 168, in build_typemap
    initial_types, auto_camelcase=self.auto_camelcase, schema=self
  File "/usr/local/lib/python3.7/dist-packages/graphene/types/typemap.py", line 80, in __init__
    super(TypeMap, self).__init__(types)
  File "/usr/local/lib/python3.7/dist-packages/graphql/type/typemap.py", line 31, in __init__
    self.update(reduce(self.reducer, types, OrderedDict()))  # type: ignore
  File "/usr/local/lib/python3.7/dist-packages/graphene/types/typemap.py", line 88, in reducer
    return self.graphene_reducer(map, type)
  File "/usr/local/lib/python3.7/dist-packages/graphene/types/typemap.py", line 117, in graphene_reducer
    return GraphQLTypeMap.reducer(map, internal_type)
  File "/usr/local/lib/python3.7/dist-packages/graphql/type/typemap.py", line 109, in reducer
    field_map = type_.fields
  File "/usr/local/lib/python3.7/dist-packages/graphql/pyutils/cached_property.py", line 22, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.7/dist-packages/graphql/type/definition.py", line 198, in fields
    return define_field_map(self, self._fields)
  File "/usr/local/lib/python3.7/dist-packages/graphql/type/definition.py", line 217, in define_field_map
    ).format(type_)
AssertionError: Query fields must be a mapping (dict / OrderedDict) with field names as keys or a function which returns such a mapping.

In the error there should at least be the name of the Query class whose fields are invalid.
In this case I believe the error turned out to be that the root Query had no fields because I was improperly dynamically generating them.

Ngôn ngữ chính
Python
Star
8.2k
Fork
822
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của graphql-python/graphene

Tất cả issue của graphql-python/graphene

Issue tương tự

Thêm issue về Python

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.