Confusion on how to call and test

I want to develop a function based on the one given on

under heading " A UDF that returns a database page"

Here is the function given on that page:

  name: "vip_users",
  body: Query(Lambda(["size", "after", "before"],
        match: Match(Index("vip_users"), true),
        page: If(
          Equals(Var("before"), null),
            Equals(Var("after"), null),
              Paginate(Var("match"), { size: Var("size") }),
              Paginate(Var("match"), { size: Var("size"), after: Var("after") })
          Paginate(Var("match"), { size: Var("size"), before: Var("before") }),
      Map(Var("page"), Lambda("ref", Get(Var("ref"))))

Assuming that I have made the required collection and index (my names are different), how do I test the above function in the Shell using FQL?

I tried this:
Call(Function(“vip_users”, [3, null, null]))

But it doesn’t work, giving error:

Error: [
    "position": [
    "code": "invalid argument",
    "description": "Database Ref expected, Array provided."

Please help.


Hi @skanade

The arguments for Call are comma separated, not put into an array. Putting the args into an array makes it consider what you gave it a single argument which is an array, thus the error that you handed it an array.

The docs for Call, I guess, technically state this, but it could be clearer for sure.

Try this:

Call(Function('vip_users'), 3, null, null))

Also, FYI, I see you have asked a lot of other questions about graphql. This might help, in regards to the UDF for paginated data example.