I’m trying to set up filtering functionality for the documentAccount fields. However, when I attempted to compile my model, I got the “ controllerDID is not indexable” error.
Here is my schema:
type Profile
@createModel(accountRelation: SINGLE, description: "A Profile")
@createIndex(fields: [{path: ["controllerDID"]}])
{
controllerDID: DID! @documentAccount
name: String! @string(minLength: 1, maxLength: 100)
bio: String @string(minLength: 1, maxLength: 300)
avatar: CID
}
The @documentAccount directive represents a view to the controller in the stream metadata, it’s not part of the stream contents that can be indexed using the @createIndex directive.
What is your use-case of wanting to index the controller please? If it’s to perform queries filtered by controller, it’s possible to make controller-centric queries such as:
query {
# use the controller DID as id
node(id: "did:pkh:...") {
...on CeramicAccount {
# any field present in the CeramicAccount object
profile {
displayName
}
}
}
}
Thanks for describing the use-case.
Considering you know the individual DIDs and stream IDs, you can already load them all in a single GraphQL query, for example:
fragment AccountFragment on Node {
...on CeramicAccount {
profile {
displayName
}
}
}
fragment PostFragment on Node {
...on Post {
title
text
}
}
query {
account1: node(id: "did:pkh:123...") {
...AccountFragment
}
account2: node(id: "did:pkh:456...") {
...AccountFragment
}
post1: node(id: "k6...123") {
...PostFragment
}
post2: node(id: "k6...456") {
...PostFragment
}
}
@seref if that’s useful, one thing we could easily do is adding a nodes(ids: [ID!]!): [Node]! entry point to the query, so you could do queries such as:
query {
accounts: nodes(ids: ["did:pkh:123...", "did:pkh:456..."]) {
...on CeramicAccount {
profile {
displayName
}
}
}
posts: nodes(ids: ["k6...123", "k6...456"]) {
...on Post {
title
text
}
}
}
Hey @seref, I just published v0.5.1 of the packages that should support the nodes entry-point, can you let me know if it works for you when you have time to try it out please? Thanks!