2
を解決し、私は次のクエリと一緒にexpress-graphqlを使用しています:GraphQLはGraphQLObjectType
invitations {
sent
received
}
次のように(簡体字)、スキーマ定義は次のとおりです。
resolve
メソッドが
sent
ために呼び出されることはありませんが
const InvitationType = new GraphQLObjectType({
name: 'InvitationType',
description: 'Friends invitations',
fields: {
sent: {
type: new GraphQLList(GraphQLString),
description: 'Invitations sent to friends.',
resolve() {
return ['sentA'];
}
},
received: {
type: new GraphQLList(GraphQLString),
description: 'Invitations received from friends.',
resolve() {
return ['receivedA', 'receivedB'];
}
}
}
});
// Root schema
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
fields: {
invitations: {
type: InvitationType // no resolve() method here.
}
}
})
});
フィールドはreceived
です。戻って上記のクエリ:
{data: {invitations: {sent: null, received: null}}}
親(invitations
)フィールド上のresolve()
メソッドを定義することなく、ネストされたフィールド(sent
とreceived
)を解決する方法はありますか?