解析器中错误的类型返回不会触发错误
我正在用GraphQl构建一个Sever。我定义了应该返回用户类型的单个查询。但是,在我的解析器中,我实际上是在返回一种字符串类型:“ Hello!”。
查询在操场上执行没有任何问题。
我的问题:解析器的返回语句期望用户类型,而是返回字符串。为什么不失败?
typedef
type User {
id: String
email: String
name: String
}
type Query {
printUser: User
}
分辨率
const resolvers = {
Query: {
printUser: async (parent, args, context, info) => {
return 'Hello!';
}
}
I am building a sever with Graphql. I define a single query which should return a User type. However, in my resolver I am actually returning a string type: "Hello!".
The query executes in the playground without any problem.
My question: the return statement of the resolver expects a User type, instead returns a string. Why is it not failing?
TypeDef
type User {
id: String
email: String
name: String
}
type Query {
printUser: User
}
Resolver
const resolvers = {
Query: {
printUser: async (parent, args, context, info) => {
return 'Hello!';
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论