Executing a query that only contains a fragment spread causes the root value to be null.
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
Beginne damit, die nur aus einem Fragment bestehende Abfrage mit FSharp.Data.GraphQL 2.2.1 zu reproduzieren, und untersuche während der Ausführung das root-Argument des organizationField-Resolvers. Vergleiche sie mit dem Fall eines Inline-Fragments und dem Fall einer Abfrage mit einem zusätzlichen Feld; abgeschlossen ist die Untersuchung, wenn alle drei Formen dasselbe nicht-null root bereitstellen und das organizations-Feld ohne einen null-Fehler aufgelöst wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- F#
- Sterne
- 407
- Forks
- 74
- Ø Merge
- 15 Std. 59 Min.
- Gemergte PRs (30 T.)
- 20
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus fsprojects/FSharp.Data.GraphQL
-
Introspection emits JSON-serialized value as `defaultValue` instead of a GraphQL literal (breaks enum defaults)Evtl. vergeben @xperiandri hat das vor 10 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 65/100
fsprojects/FSharp.Data.GraphQL#623 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 52/100
fsprojects/FSharp.Data.GraphQL#613 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
fsprojects/FSharp.Data.GraphQL#596 ·
Maintainer antworten meist innerhalb von 1 Tag
-
`documentId` has different values for the same query contentEvtl. vergeben @xperiandri hat das vor 148 Tagen übernommen. Offen
fsprojects/FSharp.Data.GraphQL#573 · 1 Reaktion · 2 zugewiesene Personen ·
Maintainer antworten meist innerhalb von 1 Tag
-
FR: Suave packageEvtl. vergeben @xperiandri hat das vor 148 Tagen übernommen. Offen
fsprojects/FSharp.Data.GraphQL#566 · 1 Kommentar · 1 Reaktion · 2 zugewiesene Personen ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in fsprojects/FSharp.Data.GraphQL
Ähnliche Issues
-
nextjs-tracking
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
cloudflare/vinext#3920 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
glpi-project/glpi#25922 ·
Maintainer antworten meist innerhalb von 1 Tag
-
unbounded value for n in `/v1/logs` can panic/OOMEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offensmall item
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
canonical/pebble#1127 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
beginner friendly community contributions-welcome good first issue hacktoberfest health help wanted up-for-grabs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
StackExchange/StackExchange.Redis#3274 ·
Maintainer antworten meist innerhalb von 1 Tag