Executing a query that only contains a fragment spread causes the root value to be null.
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
- 45/100
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện truy vấn chỉ có fragment với FSharp.Data.GraphQL 2.2.1 và kiểm tra đối số root của resolver organizationField trong quá trình thực thi. So sánh với trường hợp inline-fragment và trường hợp truy vấn có thêm một trường; hoàn tất khi cả ba dạng đều cung cấp cùng một root không null và trường organizations được resolve mà không có lỗi null.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
If you construct a query that only contains a spread fragment, it appears that the resolver's root argument becomes null. This only happens whenever there are no other fields being queried, only the fragment.
Repro steps
The following is an example of such a query:
fragment SidebarFragment on Query {
organizations(first: 10) {
edges {
node {
name
id
}
}
}
}
query MainLayoutMainQuery {
...SidebarFragment
}
The following is the resolver for the organizations field:
let organizationField (organizationType: OutputDef<Organization>) =
Define.AsyncField(
"organization",
Nullable organizationType,
"Gets one of the user's organizations by id",
[ Define.Input("id", StringType) ],
fun ctx (root: Root) ->
let globalId = ctx.Arg<string> "id"
match globalId with
| GlobalId("Organization", id) ->
let repository = buildOrganizationRepository root.Db root.UserId
repository.Fetch(Guid(id))
| _ -> raise (GQLMessageException "Invalid organization ID received.")
)
And the root is a simple record value:
type Root = {
Db: DbCtx
UserId: string
}
If the query is executed against this setup, then the root argument of the resolver becomes null, even when that is not a valid value
for the field. This issue completely goes away whenever there is either another field in the main query, as in the following:
fragment SidebarFragment on Query {
organizations(first: 10) {
edges {
node {
name
id
}
}
}
}
query MainLayoutMainQuery {
node(id: "") {
id
}
...SidebarFragment
}
Or the fragment is not used, and instead is sent inline as normal:
query MainLayoutMainQuery {
organizations(first: 10) {
edges {
node {
name
id
}
}
}
}
Expected behavior
The organizations field should be the same for all of the previous queries, and no null error should occur.
Actual behavior
The root argument is null.
Known workarounds
Add a dummy field to the main query, as that somehow makes the root field not be null.
Related information
- Arch linux 6.10.5
- FSharp.Data.GraphQL 2.2.1
- .NET Core 8
- Ngôn ngữ chính
- F#
- Star
- 406
- Fork
- 74
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 14
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 fsprojects/FSharp.Data.GraphQL
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
fsprojects/FSharp.Data.GraphQL#573 · 1 reaction · 2 người được giao ·
-
FR: Suave package Đang mở
fsprojects/FSharp.Data.GraphQL#566 · 1 bình luận · 1 reaction · 2 người được giao ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
Tất cả issue của fsprojects/FSharp.Data.GraphQL
Issue tương tự
-
Area: Excel support
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
orbeon/orbeon-forms#7893 ·
-
essnmx good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
yeti-platform/yeti#1380 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelcontextprotocol/python-sdk#3566 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
griptape-ai/griptape#2353 ·