Schema:
type Goal @collection(name: "goals") {
name: String!
targetAmount: Float!
installmentTerms: InstallmentTerms!
installmentAmount: Float!
deletedAt: String
user: User @relation
sortOrder: Float! # needs to be float
}
custom mutation:
getUserGoals: [Goal!] @resolver(name: "getUserGoals", paginated: true)
FQL resolver:
Update(Function("getUserGoals"), {
role: "admin",
body: Query(
Lambda(
["size", "afterCursor", "beforeCursor"],
Map(
Paginate(
Match(
Index("userGoalsBySortOrder"),
CurrentIdentity(),
null
)
),
Lambda(
["sortOrder", "ref"],
Get(Var("ref"))
)
)
)
)
});
userGoalsBySortOrder
index
CreateIndex({
name: 'userGoalsBySortOrder',
source: Collection('goals'),
terms: [
{ field: ['data', 'user'] },
{ field: ['data', 'deletedAt'] }
],
values: [
{ field: ['data', 'sortOrder'], reverse: true },
{ field: ['ref'] }
]
})
When I run this query:
{
getUserGoals {
data {
name
}
}
}
it works:
{
"data": {
"getUserGoals": {
"data": [
{
"name": "Savings goal"
},
{
"name": "Savings goal"
}
]
}
}
}
Now when I try to get the sortOrder
:
{
getUserGoals {
data {
name
sortOrder
}
}
}
It throws an error
{
"data": {
"getUserGoals": {
"data": [
null,
null
]
}
},
"errors": [
{
"message": "Can't convert '10' to double",
"path": [
"getUserGoals",
"data",
0,
"sortOrder"
],
"locations": [
{
"line": 5,
"column": 7
}
]
},
{
"message": "Can't convert '9' to double",
"path": [
"getUserGoals",
"data",
1,
"sortOrder"
],
"locations": [
{
"line": 5,
"column": 7
}
]
}
]
}
It only happens when I include sortOrder
in the fields.