Schema sample
Consider the following custom model
- A Customer has access to some DeliveryPoint nodes for a given period of time through the relation HAS_ACCESS(ContractStart, ContractEnd)
- A DeliveryPoint contains Meter nodes. A meter could be replace, this why the relation HAS_METER contains FromDate and ToDate properties.
- A Meter could be a combination of multiple Meter nodes through the relation HAS_METER
- A Meter reprensents a DataHubSource by the relation IS_SOURCE
- A DataHubVariable is the reflect of an alarm condition on a DeliveryPoint through the relation ALARM
- DataHubSite nodes are grouped by Region through IN_REGION relation
The corresponding schema is:
type Customer {
Id: ID!
Name: String!
#A customer has access to some delivery points during a given period \n
DeliveryPoints: [DeliveryPoint] @direct_relation(Type: "HAS_ACCESS" ContractStart:DateTime ContractEnd: DateTime)
}
type DeliveryPoint {
Key: String!
Ean: String!
IsActive: Boolean
ActiveFrom: DateTime
ActiveTo: DateTime
#DataHubSource nodes linked to this node through meters or submeters \n
Sources: [DataHubSource] @traverse_relation(Type: "IS_SOURCE", Depth: 5)
#Meters linked to this node \n
Meters : [Meter] @direct_relation(Type: "HAS_METER" FromDate:DateTime ToDate: DateTime)
#The alarm variable \n
AlarmVariable : [DataHubVariable] @direct_relation(Type: "ALARM" Direction: IN)
#The value of ContractStart and ContractEnd from HAS_ACCESS relation \n
CustomerAccessStart: DateTime @relation_field(RelationType: "HAS_ACCESS", FieldName: "ContractStart")
CustomerAccessEnd: DateTime @relation_field(RelationType: "HAS_ACCESS", FieldName: "ContractEnd")
}
type Meter {
Name: String!
Region: String
#DataHubSource nodes directly linked to this node \n
Sources: [DataHubSource] @direct_relation(Type: "IS_SOURCE")
#Meters linked to this one (sub meters) \n
SubMeters : [Meter] @direct_relation(Type: "HAS_METER")
#The value of FromDate and ToDate from HAS_METER relation \n
DeliveryPointMeterSince: DateTime @relation_field(RelationType: "HAS_METER", FieldName: "FromDate")
DeliveryPointMeterUntil: DateTime @relation_field(RelationType: "HAS_METER", FieldName: "ToDate")
}
type Query {
Customers : [Customer]
Meters : [Meter]
DeliveryPoints:[DeliveryPoint]
}
This schema allows these kind of queries.