标签: grandstack

在 GraphQL 参数化查询中使用 ID

我有以下架构:

type Post {
  id: ID!
  text: String
}
Run Code Online (Sandbox Code Playgroud)

我正在使用自动生成的突变neo4j-graphql.js,因此我可以访问以下突变:

UpdatePost(
id: ID!
text: String
): Post
Run Code Online (Sandbox Code Playgroud)

问题:

当我使用以下查询时:

mutation update($id: String, $text: String) {
  UpdatePost(id: $id, text: $text) {
    id
    text
  }
}
Run Code Online (Sandbox Code Playgroud)

具有以下参数:

{
  "id": "a19289b3-a191-46e2-9912-5a3d1b067cb2",
  "text": "text"
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

{
  "error": {
    "errors": [
      {
        "message": "Variable \"$id\" of type \"String\" used in position expecting type \"ID!\".",
        "locations": [
          {
            "line": 1,
            "column": 17
          },
          {
            "line": 2,
            "column": 18
          }
        ],
        "extensions": {
          "code": …
Run Code Online (Sandbox Code Playgroud)

apollo graphql grandstack

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

apollo ×1

grandstack ×1

graphql ×1