我有一个拼接的 graphql 模式。一些类型字段被解析为info.mergeInfo.delegateToSchema
这是一个示例(来自apollo docs):
const mergedSchema = mergeSchemas({
schemas: [
transformedChirpSchema,
authorSchema,
linkTypeDefs,
],
resolvers: {
User: {
chirps: {
fragment: `... on User { id }`,
resolve(user, args, context, info) {
return info.mergeInfo.delegateToSchema({
schema: chirpSchema,
operation: 'query',
fieldName: 'chirpsByAuthorId',
args: {
authorId: user.id,
},
context,
info,
});
},
},
},
});
是否可以root
在chirps
解析器中访问?所以root
那里有所有的父字段?当然,另一种方法是用于此目的,但我想,从代码的角度来看,使用 root 会更好,因为在某些情况下context
我已经在使用value。root