假设我的 GraphQL API 有以下类型定义:
const typeDef = `
type Book {
title: String
author: Author
likes: Int
}
type Author {
id: String
name: String
age: Int
books: [Book]
}
type Query{
books(authorid: String!): Book
}
`
那么,我需要多少个解析器呢?我应该只使用一个解析器处理此查询请求books
并返回所有书籍和作者信息,还是应该制作多个解析器,例如Query -> books
,Book -> author
和Author -> books
?我不确定模块化架构和解析器如何协同工作。