@databrecht @ptpaterson
Thank you, I now get rankingname/desc for the user’s member rankings.
I changed the schema and the field ‘ranking’ to ‘ladder’ to avoid any type/field ambiguity.:
type User {
active: Boolean!
username: String!
description: String
email: String
mobile: String
ownerOf: [Ranking!]! @relation(name:"ownerranking")
memberOf: [Player!]! @relation(name: "playerinranking")
}
type Player {
active: Boolean!
rank: Int!
ladder: Ranking!
playerInfo: User! @relation(name: "playerinranking")
challenger: Player @relation (name: "playerchallenger")
}
type Ranking {
active: Boolean!
rankingname: String!
rankingdesc: String
owner: User! @relation(name:"ownerranking")
}
I created a new index:
{
name: "ladder_in_player_by_ranking",
unique: false,
serialized: true,
source: "Ranking",
terms: [
{
field: ["ref"]
}
],
values: [
{
field: ["data", "rankingname"]
},
{
field: ["data", "rankingdesc"]
}
]
}
which I then added to the query:
Map(
Paginate(
Match(
Index("playerinranking_by_user"),
Ref(Collection("User"), "290125575057572353")
)
),
Lambda(
"ref",
Let(
{
instance: Get(Var("ref"))
},
Merge(Var("instance"), {
ladder: Paginate(
Match(
Index("ladder_in_player_by_ranking"),
Select(["data", "ladder"], Var("instance"))
)
)
})
)
)
)
{
data: [
{
ref: Ref(Collection("Player"), "290121646658814469"),
ts: 1613618034246000,
data: {
active: true,
rank: 1,
ladder: Ref(Collection("Ranking"), "290125481092579841"),
playerInfo: Ref(Collection("User"), "290125575057572353"),
challenger: Ref(Collection("Player"), "290125849145901569")
},
ladder: {
data: [["Test1Rnk", "t1"]]
}
},
{
ref: Ref(Collection("Player"), "290125849145901569"),
ts: 1613618050484000,
data: {
active: true,
rank: 2,
ladder: Ref(Collection("Ranking"), "290125505974239745"),
playerInfo: Ref(Collection("User"), "290125575057572353"),
challenger: Ref(Collection("Player"), "290121646658814469")
},
ladder: {
data: [["Test2Rnk", "t2"]]
}
}
]
}
To use this query I have created a function ‘member_rankings’:
Query(
Lambda(
["userRef"],
Map(
Paginate(
Match(
Index("playerinranking_by_user"),
Get(Ref(Collection("User"), Var("userRef")))
)
),
Lambda(
"ref",
Let(
{ instance: Get(Var("ref")) },
Merge(Var("instance"), {
ladder: Paginate(
Match(
Index("ladder_in_player_by_ranking"),
Select(["data", "ladder"], Var("instance"))
)
)
})
)
)
)
)
)
I think the data returned is an array of arrays (?) e.g.:
[["Test1Rnk", "t1"], ["Test2Rnk", "t2"]]
How should I define a new @resolver (memberRankings) in the schema to handle the data I obtain from the query function?
Thanks for your patience, and getting me to this point …