reactjsfaunadbfql.multiquery

Pass pagination arguments in Fauna Function


I'm trying to build fauna function which will accept before or after arguments in Paginate function, but when I run it I have error Array, Set, or Page expected, String provided So this arguments are only provided as string.

This is my fauna function:

Query(
  Lambda(
    ["paginationAfter", "paginationBefore"],
    If(
      IsEmpty(Var("paginationAfter")),
      If(
        IsEmpty(Var("paginationBefore")),
        Map(
          Paginate(Match(Index("get_logs_by_date")), { size: 10 }),
          Lambda(["created", "ref"], Get(Var("ref")))
        ),
        Map(
          Paginate(Match(Index("get_logs_by_date")), {
            before: Var("paginationBefore"),
            size: 10
          }),
          Lambda(["created", "ref"], Get(Var("ref")))
        )
      ),
      Map(
        Paginate(Match(Index("get_logs_by_date")), {
          after: Var("paginationAfter"),
          size: 10
        }),
        Lambda(["created", "ref"], Get(Var("ref")))
      )
    )
  )
)

Any help is appreaciated. Note that I'm not using GRAPHQL Thanks


Solution

  • You are using IsEmpty, which requires an array or set. Instead, try using IsNull instead.