发布于2021-05-29 22:49 阅读(1421) 评论(0) 点赞(12) 收藏(0)
主要是现在网上关于 GraphQL 的资料比较少,当我在学习的时候出了问题网上也是基本找不到解决方案,所以在此记录下来,后续遇到其他问题也会一一进行记录进来。
其实我们 Idea 安装的 GraphQL 本身就带有代码检查功能,只是它仅限于检查我们写的 .graphql 脚本文件,所以
比如,我随便写一个错误的语法,我在 root.graphql 中定义的是 Query ,这里继承一个不存在的 Query1 类型,这个时候不光代码会有红色波浪线和标红显示
插件也会给我们提示
不过就算插件会给我们错误提示,也需要我们自己仔细根据错误提示分析解决,因为网上资料太少,不像别的框架,拿出去一百度一堆解决方法。
org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.kickstart.tools.SchemaParser]: Factory method ‘schemaParser’ threw exception; nested exception is graphql.kickstart.tools.resolver.FieldResolverError: No method or field found as defined in schema :5 with any of the following signatures (with or without one of [interface graphql.schema.DataFetchingEnvironment] as the last argument), in priority order:
graphql.kickstart.tools.resolver.FieldResolverError: No method or field found as defined in schema :5 with any of the following signatures (with or without one of [interface graphql.schema.DataFetchingEnvironment] as the last argument), in priority order:
graphql 文件中,type Query 或者 type Mutation 定义的方法名,必须与我们后端实现 GraphQLQueryResolver 或 GraphQLMutationResolver 之后写的接口名称一致,如出现此问题请检查是否一致
org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.kickstart.tools.SchemaParser]: Factory method ‘schemaParser’ threw exception; nested exception is graphql.kickstart.tools.resolver.FieldResolverError: No method or field found as defined in schema :35 with any of the following signatures (with or without one of [interface graphql.schema.DataFetchingEnvironment] as the last argument), in priority order:
graphql.kickstart.tools.resolver.FieldResolverError: No method or field found as defined in schema :35 with any of the following signatures (with or without one of [interface graphql.schema.DataFetchingEnvironment] as the last argument), in priority order:
graphql 文件中,定义的对象的属性列名,必须在 Java 实体类中一一进行对应,如出现此问题请检查是否一致或缺少对应属性
{
“errors”: [
{
“message”: “Validation error of type SubSelectionRequired: Sub selection required for type Teacher of field teacher @ ‘listClazz/teacher’”,
“locations”: []
}
],
“data”: null
}
当我们查询的对象中有对象属性或者集合对象属性,我们想要查询对象属性的信息,必须要把这个对象属性中我们想要查询的属性也列出来
比如我这里是一个 teacher 对象,我必须列出 teacher 对象中,我想查询的列,否则我就直接不查询 teacher
比如,写出 teacher 对象 我想要的属性
或者直接不查 teacher
{
“error”: “Unexpected end of JSON input”
}
当我们使用 input 输入对象时,我们传入的 input 对象参数为 json 类型,出现此问题,多半是我们的 json 格式错误
{
“errors”: [
{
“message”: “Validation error of type LoneAnonymousOperationViolation: Operation addByInput is following anonymous operation.”,
“locations”: []
}
],
“data”: null
}
在图形化工具中,Query 类型和 Mutation 类型不能同时调用
原文链接:https://blog.csdn.net/wxw1997a/article/details/117307351
作者:举起你的手来
链接:http://www.javaheidong.com/blog/article/207643/3e422d58e2f247f70009/
来源:java黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 java黑洞网 All Rights Reserved 版权所有,并保留所有权利。京ICP备18063182号-2
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!