I ran this query:
Map(
Paginate(
Match(
Index("userGoalsBySortOrder"),
CurrentIdentity(),
null
)
),
Lambda(
["sortOrder", "ref"],
Get(Var("ref"))
)
)
on the dashboard by providing a “custom secret”
I got 2 results:
{
data: [
{
ref: Ref(Collection("goals"), "323005644921634883"),
ts: 1644301037650000,
data: {
name: "Savings goal",
targetAmount: 4848484884,
installmentTerms: "Monthly",
installmentAmount: 3290,
sortOrder: 21,
user: Ref(Collection("users"), "322014450218434627")
}
},
{
ref: Ref(Collection("goals"), "322888010772250690"),
ts: 1644191649090000,
data: {
name: "Savings goal",
targetAmount: 1000000,
installmentTerms: "Monthly",
installmentAmount: 8000,
sortOrder: 18.99981000189998,
user: Ref(Collection("users"), "322014450218434627")
}
}
]
}
which are correct.
Compared to the graphql query:
{
getUserGoals {
data {
name
deletedAt
}
}
}
which gives me the following results:
{
"data": {
"getUserGoals": {
"data": []
}
}
}
Using the same secret.
Side note: I was trying to fetch the data using TS, but I got a TS error: Argument of type 'null' is not assignable to parameter of type 'ExprArg'.ts(2345)
const results = await client.query(
query.Map(
query.Paginate(
query.Match(
query.Index('userGoalsBySortOrder'),
query.CurrentIdentity(),
null
)
),
query.Lambda(['sortOrder', 'ref'], query.Get(query.Var('ref')))
)
);