【发布时间】:2017-01-29 15:40:37
【问题描述】:
我正在浏览 GraphQl 的文档,并意识到新的 Schema 语言只支持默认解析器。有没有办法在使用新的架构语言时添加自定义解析器?
let userObj = {
id: 1,
name: "A",
homeAddress: {
line1: "Line1",
line2: "Line2",
city: "City"
}
};
let schema = buildSchema(`
type Query {
user(id: ID): User
}
type User {
id: ID
name: String
address: String
}
`);
//I would like User.address to be resolved from the fields in the json response eg. address = Line1, Line2, City
这是我定义的架构。我想在这里添加一些行为,允许我解析地址对象并返回一个串联的字符串值。
【问题讨论】:
标签: graphql graphql-js