Support `custom root type names` in schema (e.g. query_root instead of Query)

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

Maintainer thường phản hồi trong vòng 1 ngày

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
58/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
kotlin
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu bằng cách xác định cấu hình codegen và điểm vào của quá trình xử lý schema, nơi phát hiện các kiểu root của query, mutation và subscription. Tái hiện vấn đề với schema theo kiểu Hasura được hiển thị ở đây; hoàn thành khi các tên root tùy chỉnh có thể cấu hình tạo ra mã client mà không cần viết lại schema thủ công.

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

Mô tả

Hi DGS team 👋

We’re currently using DGS Codegen to generate Java client code from a GraphQL schema that is generated by Hasura.

Hasura generates a valid GraphQL schema with custom root type names, such as query_root, mutation_root, and subscription_root, instead of the usual Query, Mutation, and Subscription.

Example schema:

schema {
  query: query_root
  mutation: mutation_root
  subscription: subscription_root
}

type query_root {
  # some fields here
}

type mutation_root {
  # some fields here
}

type subscription_root {
  # some fields here
}

While this is perfectly valid according to the GraphQL spec (see GraphQL spec 3.2), it seems that DGS Codegen relies on the root types being named Query, Mutation, and Subscription, and does not generate code for these custom root types.

Our current workaround

As a workaround, we manually rewrite the schema before passing it to DGS Codegen:

schema {
  query: Query
  mutation: Mutation
  subscription: Subscription
}

# then copy contents from query_root to Query, etc.

This allows client code generation to work properly, but it’s a manual.

Feature request

Would it be possible for DGS Codegen to allow users to configure the names of the root types (query, mutation, subscription) via codegen config ?

Motivation

This would improve compatibility with Hasura and any other GraphQL server that uses valid non-standard root type names, without requiring manual schema rewriting.

Sources

https://github.com/deweyjose/graphqlcodegen/issues/245#issuecomment-2944055960

Ngôn ngữ chính
Kotlin
Star
220
Fork
123
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
23

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

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 Netflix/dgs-codegen

Tất cả issue của Netflix/dgs-codegen

Issue tương tự

Thêm issue về Kotlin

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.