gpt4 book ai didi

graphql - 错误 : Invalid AST Node: {"input":"** } on graphql mutation (Amplify client)

转载 作者:行者123 更新时间:2023-12-04 00:02:03 28 4
gpt4 key购买 nike

我尝试在 api doc("https://aws-amplify.github.io/docs/cli-toolchain/graphql?sdk=js ") 上使用示例架构,如下面的多对多连接

type Post @model {
id: ID!
title: String!
editors: [PostEditor] @connection(keyName: "byPost", fields: ["id"])
}

# Create a join model and disable queries as you don't need them
# and can query through Post.editors and User.posts
type PostEditor
@model(queries: null)
@key(name: "byPost", fields: ["postID", "editorID"])
@key(name: "byEditor", fields: ["editorID", "postID"]) {
id: ID!
postID: ID!
editorID: ID!
post: Post! @connection(fields: ["postID"])
editor: User! @connection(fields: ["editorID"])
}

type User @model {
id: ID!
username: String!
posts: [PostEditor] @connection(keyName: "byEditor", fields: ["id"])
}

我创建了所有项目,然后尝试删除它们,但我失败了,尤其是在 PostEditor 上。

有一个删除 PostEditor 的突变,所以我像下面这样称呼它

API.graphql(graphqlOperation((deletePostEditor, {input: {id},})))

它失败并显示以下错误消息。

错误:AST 节点无效:{"input":"b2f7064c-af32-49cd-8c87-*******"}

我想我提供了正确的 ID。我在查询时检查了它。

最佳答案

您应该将参数作为 graphqlOperation 的第二个参数传递.所以,检查你的括号
API.graphql(graphqlOperation((deletePostEditor, {input: {id},}))) ,你有一对额外的括号

下面是正确的一个API.graphql(graphqlOperation(deletePostEditor, { input: { id } }))

  • 第一个参数=deletePostEditor
  • 第二个参数={输入:{id}}

  • 小错误,不是吗?

    关于graphql - 错误 : Invalid AST Node: {"input":"** } on graphql mutation (Amplify client),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59516375/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com