我有以下性质的查询
Category1(name: $cat1){
Category2(secondName: $cat2){
secondName
}}
Run Code Online (Sandbox Code Playgroud)
我的架构是这样的:
const Query = new GraphQLObjectType({
name: 'Query',
fields: {
Category1: {
type: new GraphQLList(Category1Type),
args: { name },
resolve: resolveCategory1
}}
})
Run Code Online (Sandbox Code Playgroud)
然后 Category1Type 定义为:
const Category1Type = new GraphQLObjectType({
name: 'Category1',
description: '<>',
fields: () => ({
name: { type: GraphQLString },
category2: {
type: new GraphQLList(CategoryType2),
args: { secondName },
resolve: resolveCategory2
}
})
});
Run Code Online (Sandbox Code Playgroud)
为简单起见,假设 category2 是这样的:
const Category2Type = new GraphQLObjectType({
name: 'Category2',
description: '<>',
fields: () => …
Run Code Online (Sandbox Code Playgroud)