Currently using Basic authorization and a Query defined in schema as:
userFindById (uid: String!): User @resolver (name: "user_find_by_id")
I have a function:
name: "user_find_by_id",
body: Query(
Lambda(
["uid"],
Let(
{
match: Match(Index("user_find_by_id"), Var("uid")),
user: If(Exists(Var("match")), Get(Var("match")), "false"),
},
{
user: Select(['data', 'username'], Var("user"))
}
)
)
)
which uses an index:
name: "user_find_by_id",
source: Collection("User"),
unique: false,
terms: [
{
field: ["ref"]
}
]
However, trying with an existing User document:
{
userFindById(uid: "290125575057572353") {
username
}
}
on document:
{
"ref": Ref(Collection("User"), "290125575057572353"),
"ts": 1612944159470000,
"data": {
"active": true,
"username": "Test1",
"description": "R hander",
"email": "t1@t1.com",
"mobile": "+65 1111"
}
}
in PG I get:
{
"errors": [
{
"message": "Value not found at path [data,username].",
"extensions": {
"code": "value not found"
}
}
]
}
How do I need to change the function to be able to reference fields in the User collection?
Thanks …