[英]"Variable 'input' has coerced Null value for NonNull type XXX" - aws-amplify & graphql & react
[英]GraphQL AWS React Can't resolve value type mismatch expected type LIST
我在 React 中有一个查询
const allQueries = await API.graphql(graphqlOperation(queries.listProcess));
然后在我的 queries.js 中我将它定义为这样。
```export const listProcess = `query ListProcess(
$filter: ModelProcessFilterInput
$limit: Int
$nextToken: String
) {
listProcess(filter: $filter, limit: $limit, nextToken: $nextToken) {
items {
id
routine {
id
key
}
event {
eventId
detailType
source
account
time
region
resources
detail
}
tasks {
key
title
status
processId
context
eventId
message
export
error
output
}
workers {
id
type
}
status
context
}
nextToken
}
}
`;```
当我 go 查询它时,我在 JS 中收到此错误
地点:null
消息:“无法解析值(/listProcesss/items[1]/tasks):类型不匹配错误,预期类型 LIST”
路径:数组(4)
0:“列表进程”
1:“项目” 2:1 3:“任务”长度:4
当您的 DynamoDB 数据与 GraphQL 架构不匹配时,会发生此错误。
当数据中有 MAP/Object 时,当 GraphQL 模式设置为期望 LIST/Array 时。
对我来说,我将响应设置为数组,而不是自定义查询的 object。
type Query {
stripeGetCheckoutSession(sessionId: ID!): [StripeSession] @function(name: "StripeGetCheckoutSession-${env}")
}
将数组括号从[StripeSession]
删除到StripeSession
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.