GraphQl+ Springboot+数据加载器:正确的模式是什么?
我有GraphQl + Springboot + MongoDB应用程序,带有GraphQl.java.kickstart.springboot,并且我遇到了性能问题。 该应用程序的步行骨架是去年完成的,我收到了它。我想添加数据加载机 / batchdataloader(更好)以提高性能,并避免查询数据库的加时性,以了解类似的请求。查看数据加载器示例,我看到的实现与我的实现截然不同。 我有一个QueryResolver类,可以调用称为存储库的服务。结果是从这里暴露的,而不是一些解析器处理的。
@Component
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
public class Query implements GraphQLQueryResolver {
@Autowired
ProjectService projectService;
public Iterable<ProjectDao> listProjects(String name, Sort orderByInput) {
return projectService.getProjects(name, orderByInput);
}
}
现在,我不明白这是否是一种错误的方法来添加数据加载器。 在这里我找到了一个问题类似的实现,但随后他似乎已经改变了此答案。 更改整个代码会很耗时,我真的希望我只是缺少一些东西。 您有任何建议或文档需要建议吗?非常感谢您!
I have GraphQL + SpringBoot + MongoDB application, with graphql.java.kickstart.springboot ,and I'm having performance issues.
The walking skeleton of this application was done the last year and I received it as it is. I'd like to add DataLoaders / BatchDataLoaders (better) to improve the performance and to avoid to query the DB overtime for similar requests. Looking at DataLoaders examples I see quite different implementations from the one I have.
I have a QueryResolver class that calls the Service which calls the Repository. The result is exposed from here, not handled by some Resolvers.
@Component
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
public class Query implements GraphQLQueryResolver {
@Autowired
ProjectService projectService;
public Iterable<ProjectDao> listProjects(String name, Sort orderByInput) {
return projectService.getProjects(name, orderByInput);
}
}
Now I don't understand if this is a wrong approach in order to add the DataLoaders.
Here I found a question with a similar implementation, but then he seems to have changed looking at this answer.
Changing the whole code would be time-consuming and I really hope I'm just missing something.
Do you have any tips or docs to suggest? Thank you so much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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