我已经定义了这个模式。
input TopicInput {
name: String!
value: String!
}
input RetentionChangeInput {
templateId: String!
endDateAndTime: String!
reason: String!
topics: [TopicInput!]!
}
type Mutation {
retentionChange(spec: RetentionChangeInput!): RetentionChangeResult!
}
type RetentionChangeResult {
numberOfHits: Int!
}
这也是我的查询文件。
mutation ($templateId: String!, $endDateAndTime: String!, $reason: String!, $topics: [TopicInput!]!) {
retentionChange(spec: {
templateId: $templateId,
endDateAndTime: $endDateAndTime,
reason: $reason,
topics: $topics
}) {
numberOfHits
}
}
我正在使用 java 执行突变请求。
return graphQlClient.documentName("mutationQuery")
.variables(Map.of("templateId", request.templateId(), "endDateAndTime", request.endDateAndTime(), "reason", request.reason(), "topics", request.topics()))
.execute()
.map(resp -> resp.toEntity(Response.class))
.block();
我的要求是这样的
mutation {
retentionChange(
spec: {
templateId: "11bf1735"
endDateAndTime: "2029-02-01T12:00:00"
reason: "Request"
topics: [
{ name: "SER", value: "a7d6e86d" }
]
}
) {
numberOfHits
}
}
我收到此错误 org.springframework.graphql.client.FieldAccessException:无效字段“”,错误:[{message=验证错误(UnknownType):未知类型“TopicInput”,位置=[{line=1,column=87}],扩展={分类=验证错误}}]
架构命名不匹配导致出现问题。