के लिए नेस्टेड क्वेरी मैं अपने ग्राफिक्स स्कीमा भाषा के साथ अपने दोस्त सूची के लिए रिज़ॉल्यूवर कैसे बना सकता हूं? दोस्त सूची में लोगों की एक सरणी है _id।नए ग्राफQL buildSchema
मेरे नए लोगों GraphQL स्कीमा भाषा के साथ टाइप करें:
const schema = buildSchema(`
type People {
_id: String
firstName: String
lastName: String
demo: String
friendList: [People]
}
type Query {
getPeople(_id: String): People
}
`);
मेरे पुराने लोगों GraphQLObjectType साथ टाइप करें:
:const PeopleType = new GraphQLObjectType({
name: 'People',
fields:() => ({
_id: {
type: GraphQLString,
},
firstName: {
type: GraphQLString,
},
lastName: {
type: GraphQLString,
},
friendList: {
type: new GraphQLList(PeopleType),
// pass @friends parentValue
resolve: ({ friends }) {
return People.find({ _id: { $in: friends } }).then(res => res);
},
}),
});
मैं इस क्वेरी हासिल करना चाहते हैं
{
people(_id: "ABC123") {
firstName
lastName
friendList {
firstName
lastName
}
}
क्या आपको कभी इसका जवाब मिला? अभी इस के माध्यम से संघर्ष कर रहा हूँ। –