Sure. If you use the exact schema:
GraphQL Query for sorting domains based on links:
query getSortedDomains {
queryConnections(order: {
links: desc
}) {
ConnectionID
source_domain {
DomainID
}
target_domain {
DomainID
}
links
}
}
DQL equivalent:
query getSortedDomains {
queryConnections(func: type(Connections), orderasc: Connections.links) {
uid
Connections.source_domain {
uid
}
Connections.target_domain {
uid
}
Connections.links
}
}
Let me know if this structure solves your problem or not.
If you want to use GraphQL Layer in your app we can easily use hasInverse directive to connect domains and their connections and then query differently.
Your schema will look like this:
type Domain {
DomainID: ID!
name: String!
sourceConections: [Connections]
targetConnections: [Connections]
}
type Connections {
ConnectionID: ID!
source_domain: Domain! @hasInverse(field: "sourceConections")
target_domain: Domain! @hasInverse(field: "targetConnections")
links: Int!
}