Getting connection fields within DataFetcher#get
See original GitHub issueHello mates,
What is the best way to get the list of fields from nodes
and edges.node
in my DataFetcher for ThingConnection?
I need the union of these fields to make an optimal fetch to my datastore
I was able to get them when the query didn’t include fragments, using env.getSelectionSet and walking through the fields
// I notice that this hack gets me fields at top level in my graphql.schema.DataFetcher#get ThingConnection implementation
DataFetchingFieldSelectionSetImpl ss = ((DataFetchingFieldSelectionSetImpl) ((DataFetchingEnvironmentImpl) env).selectionSet);
ss.fieldCollector.collectFields(ss.parameters,ss.fields)
What would be the best way to go deeper into the tree without having to expand the fragments and evaluating skip/include directives. If this facility is not in place would you consider adding a convenience method for this case?
Type definition
# A connection to a list of Things.
type ThingConnection {
# Information to aid in pagination.
pageInfo: PageInfo
# A list of Things.
nodes: [Thing]
# A list of Thing edges.
edges: [ThingEdge]
# Count of filtered result set without considering pagination arguments.
totalCount: Int!
}
query
{
things(first: 10) {
nodes {
... thingInfo @skip(if:false)
...fix
}
edges {
cursor
node {
description
status {
...status @skip(if:false)
}
}
}
totalCount
}
}
fragment thingInfo on Thing {
key
summary
status {
...status
}
}
fragment fix on Thing {
stuff {
name
}
}
fragment status on Status {
name
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
GraphQL register new Type wiring with argument to data fetcher
Inside data fetcher get field name from DataFetcherEnvironment. Use reflection to get field from source object. Example #1: RuntimeWiring.
Read more >Data fetching - DGS Framework - Netflix Open Source
The DgsDataFetchingEnvironment gives access to the context , the query itself, data loaders, and the source object. The source object is the object...
Read more >Data Consolidation for Data Sources of Non- uniform Sample ...
As becomes apparent in Figure 2, we simply get rid of certain samples in the discrete- time signal. ... var backendUrl = '/data-fetcher/get-....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this is done in https://github.com/graphql-java/graphql-java/pull/1176
I was thinking something like this (psudeo java)
Maybe this would help build a tree structure of subselected fields and their types.