元帅GraphQl执行结果对Java对象
我搜索了很多东西,但是不幸的是,任何建议的解决方案都适合我。
我将描述要点:
- 我的休息项目建立在OpenAPI和 OpenApi Maven Generator插件上。
- 通过
JAXRS-Spec
生成器I生成应用程序DTO。 - 通过
graphQl-nodejs-express-server
Generator,我生产GraphQl架构文件。 - REST Web服务作为可选的GraphQl查询接受,以过滤/减少答案的冗长。
GraphQl executionResult.getData()
方法返回linkedHashmap
的实例。
问题是:如何将上述linkedhashmap
降低到相应的dto
?
预先感谢您!
------ 编辑 ----
我希望改进和简化我的问题。
我有以下DTO:
public class ResponseDTO {
private Integer id;
private String description;
}
我通过GraphQl过滤:
GraphQLSchema graphQLSchema = getGraphQLSchema();
String graphqlQuery = "{ ResponseDTO { id } }";
ExecutionInput builder = ExecutionInput
.newExecutionInput()
.query(graphqlQuery)
.build();
ExecutionResult executionResult = GraphQL
.newGraphQL(graphQLSchema)
.build()
.execute(builder);
LinkedHashMap graphQLData = executionResult.getData();
//TODO How can I convert 'graphQLData' to a `ResponseDTO` instance?
ResponseDTO responseDTO = ???;
I searched a lot into SO, but unfortunately any of the proposed solutions fits to me.
I am going to describe the key points:
- My REST project is built upon OpenAPI and the OpenAPI maven generator plugin.
- By the
jaxrs-spec
generator I produce the application DTOs. - By the
graphql-nodejs-express-server
generator I produce the GraphQL schema files. - The REST web service accepts, as optional, a GraphQL query in order to filter/reduce the verbosity of the answer.
The GraphQL ExecutionResult.getData()
method returns an instance of a LinkedHashMap
.
The question is: How can I marshall the above LinkedHashMap
to the corresponding DTO
?
Thank you so much in advance!
----
Edit
----
I wish to improve and simplify my question.
I have a DTO such the following one:
public class ResponseDTO {
private Integer id;
private String description;
}
I filter it by GraphQL:
GraphQLSchema graphQLSchema = getGraphQLSchema();
String graphqlQuery = "{ ResponseDTO { id } }";
ExecutionInput builder = ExecutionInput
.newExecutionInput()
.query(graphqlQuery)
.build();
ExecutionResult executionResult = GraphQL
.newGraphQL(graphQLSchema)
.build()
.execute(builder);
LinkedHashMap graphQLData = executionResult.getData();
//TODO How can I convert 'graphQLData' to a `ResponseDTO` instance?
ResponseDTO responseDTO = ???;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于找到了解决方案:
其中
fixTypeid
是:I finally found the solution:
Where
fixTypeId
is: