我在 Spring Boot 中调用 graphQL 突变 API 时陷入困境。让我解释一下我的场景,我有两个微服务,一个是 AuditConsumeService,它使用来自 activeMQ 的消息,另一个是 GraphQL 层,它只是从消费服务获取数据并将其放入数据库中。当我尝试使用 graphql Playground 或 Postman 推送数据时,一切都很好。如何从 AuditConsumeService 推送数据。在 AuditConsumeService 中,我尝试将突变 API 作为字符串发送。负责将其发送到 graphQL 层的方法是
public Mono<String> sendLogsToGraphQL(String logs){
return webClient
.post()
.uri("http://localhost:8080/logs/createEventLog")
.bodyValue(logs)
.retrieve()
.bodyToMono(String.class);
}
Run Code Online (Sandbox Code Playgroud)
注意:我也尝试将数据作为对象传递,但没有用。String logs将从 activeMQ 提供给它。我发送的数据是;
{
"hasError": false,
"message": "Hello There",
"sender": "Ali Ahmad",
"payload": {
"type": "String",
"title": "Topoic",
"description": "This is the demo description of the activemqq"
},
"serviceInfo":{
"version": "v1",
"date": "2021-05-18T08:44:17.8237608+05:00",
"serverStatus": "UP",
"serviceName": "IdentityService"
} …Run Code Online (Sandbox Code Playgroud)