query One {
library(id: "library_1") {
name
book {
title
__typename
}
__typename
}
}
When I investigate info object info.field_nodes[0].selection_set.selections I got selection set of FieldNodes that looks like that:
<class 'graphql.language.ast.SelectionSetNode'>
<class 'graphql.pyutils.frozen_list.FrozenList'> [FieldNode at 45:49, FieldNode at 54:95, FieldNode at 100:110]
# FieldNode at 45:49
name
# FieldNode at 54:95
book {
title
__typename
}
# FieldNode at 100:110
__typename
Problem
In my second query set I added results field to wrap my data.
query All {
allLibrary {
results {
name
book {
title
__typename
}
__typename
}
__typename
}
}
Unfortunately, this causes a problem because query set is resolved from level of allLibrary not library as in the first example. The consequences of this structure is that info.field_nodes[0].selection_set.selections resolves fields incorrectly. Skiping, all the fields that I have interest in (name , book, __typename).
<class 'graphql.language.ast.SelectionSetNode'>
<class 'graphql.pyutils.frozen_list.FrozenList'> [FieldNode at 14:147, FieldNode at 133:143]
# FieldNode at 31:128
results {
name
book {
title
__typename
}
__typename
}
# FieldNode at 133:143
__typename
Question
How I can fix my info.field_nodes[0].selection_set so it fetches the FieldNode correctly ?
Context
have a GraphQL query that looks like this.
When I investigate
info
objectinfo.field_nodes[0].selection_set.selections
I got selection set ofFieldNodes
that looks like that:Problem
In my second query set I added
results
field to wrap my data.Unfortunately, this causes a problem because query set is resolved from level of
allLibrary
notlibrary
as in the first example. The consequences of this structure is thatinfo.field_nodes[0].selection_set.selections
resolves fields incorrectly. Skiping, all the fields that I have interest in (name
,book
,__typename
).Question
How I can fix my
info.field_nodes[0].selection_set
so it fetches theFieldNode
correctly ?