Executing a query that only contains a fragment spread causes the root value to be null.
まだ誰も着手していません。
評価
調査の方向性
まず、FSharp.Data.GraphQL 2.2.1 を使ってフラグメントのみのクエリを再現し、実行中の organizationField resolver の root 引数を調べます。inline-fragment の場合と追加フィールド付きクエリの場合と比較します。完了の条件は、3 つの形式すべてで同じ non-null の root が提供され、organizations フィールドが null エラーなしで解決されることです。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- F#
- スター
- 406
- フォーク
- 74
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 14
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
fsprojects/FSharp.Data.GraphQL のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
fsprojects/FSharp.Data.GraphQL#573 · リアクション 1 件 · 担当者 2 名 ·
-
FR: Suave package オープン
fsprojects/FSharp.Data.GraphQL#566 · コメント 1 件 · リアクション 1 件 · 担当者 2 名 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
fsprojects/FSharp.Data.GraphQL の issue をすべて見る
似ている issue
-
bug priority:normal ready-for-dev
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
OpenHands/extensions#626 · コメント 1 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
avniproject/avni-client#2135 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
use-agent-os/agent-os#3276 ·