具有嵌套类型的动物区系UDF GraphQL解析器

时间:2020-10-15 17:06:17

标签: graphql user-defined-functions fql.multiquery faunadb

我有这个 GraphQL模式graphql schema graphql query

type Board {
  title: String @unique
  description: String
  columns: [Column] @relation
  user: User
  locked: Boolean
}

type Column {
  title: String @unique
  description: String
  columnType: ColumnType
  board: Board
  wip: Int
  wipLimit: Int
  weight: Int
}
type Query {
   allBoards: [Board!]!
   allColumns: [Column!]!
   getBoardByTitle(title: String!):Board @resolver(name: "GetBoardByTitle")
}

功能的实现是: function implementation

    Query(
Lambda(
["title"],
Let(
  { boardRef: Match(Index("board_by_title"), Var("title")) },
  {
    data: {
      _id: Select(["ref", "id"], Get(Var("boardRef"))),
      description: Select(["data", "description"], Get(Var("boardRef"))),
      title: Select(["data", "title"], Get(Var("boardRef"))),
      columns: Map(
        Paginate(
          Match(
            Index("all_columns_by_board_order_by_weight"),
            Select(["ref"], Get(Var("boardRef")))
          )
        ),
        Lambda(
          ["weight", "columnRef"],
          Let(
            { columnRef1: Get(Var("columnRef")) },
            {
              _id: Select(["ref", "id"], Var("columnRef1")),
              description: Select(
                ["data", "description"],
                Var("columnRef1")
              ),
              title: Select(["data", "title"], Var("columnRef1"))
            }
          )
        )
      )
    }
  }
)
)
)

以及索引board index column index

    {
  name: "board_by_title",
  unique: true,
  serialized: true,
  source: "Board",
  terms: [
    {
      field: ["data", "title"]
    }
  ]
}    
{
  name: "all_columns_by_board_order_by_weight",
  serialized: true,
  source: "Column",
  terms: [
    {
      field: ["data", "board"]
    }
  ],
  values: [
    {
      field: ["data", "weight"]
    },
    {
      field: ["ref"]
    }
  ]
}

并且 GraphQL查询的执行出现此错误: error of graphql query execution(“在路径[ref]上找不到值。”)

  1. 是否有任何文档说明udf graphql解析器的响应结构应如何,以便确切地知道实现此功能的正确方法是什么?
  2. 是否有此类udf graphql解析器(具有嵌套类型)的示例?
  3. 如果1)和2)的答案是否定的,您能帮我调试/查找此功能的修复程序吗?
  4. 如何调试udf graphql解析器?

谢谢

0 个答案:

没有答案