I want to implement the following custom fields based on dql
query:
type User {
id: String! @id
name: String! @search(by: [hash,term])
followings: [User]
followers: [User] @hasInverse(field: followings)
# Check if I follow the user
is_following: Boolean @custom(dql: """
query($logged_user_id: string!){
queryIsFollowing(func: type(User)) {
cnt as count(followers @filter(uid($logged_user_id)))
is_following: math(cnt == 1)
}
}
""")
# The number of followings
followings_count: Int @custom(dql: """
query{
queryFollowingsCounts(func: type(User)) {
followings_count: count(User.followings)
}
}
""")
# The number of followers
followers_count: Int @custom(dql: """
query{
queryFollowersCounts(func: type(User)) {
followers_count: count(User.followers)
}
}
""")
created_at: DateTime!
...
}
But this feature is not yet supported, I hope team can provide support.