Reputation: 812
I am not able to call nested resolvers using graphql-tools. I have filed bug on github but haven't got any reply yet.
https://github.com/apollographql/graphql-tools/issues/1026.
Nested fields of my schema are not getting called while querying.
Schema
type XYZ {
title: String
}
type NestedLevel1 {
reference: XYZ
}
type ABCD {
title: String
reference: XYZ
nestedLevel1: NestedLevel1
}
type Query {
ABCDList(limit: Int, skip: Int): [ABCD]
}
Resolvers
const Resolvers = {
Query: {
ABCDList: () => []
},
ABCD: {
reference: () => [] // this function is being called
nestedLevel1: {
reference: () => [] // this function is not being called
}
}
}
Resolver function of top level "reference" is being called but not "nestedLevel1.reference" resolver. Please correct me if I am doing something wrong.
Upvotes: 0
Views: 675
Reputation: 812
I have figured out solution for above issue. Instead of providing field id(key) of type return Type of field should be used in nested resolver.
Following is solution which worked for me.
const Resolvers = {
Query: {
ABCDList: () => []
},
ABCD: {
reference: () => []
},
NestedLevel1: {
reference: () => []
}
}
Upvotes: 0