Skip to content

Commit 5757a80

Browse files
committed
Flatten resource tree because queries do not know in advance how deeply nested the tree is but still should be able to request the whole tree in one query (this shortcoming of GraphQL was and is discussed in graphql/graphql-spec#91 and graphql/graphql-spec#237)
1 parent acd6586 commit 5757a80

File tree

2 files changed

+152
-79
lines changed

2 files changed

+152
-79
lines changed

apis/database.graphql

Lines changed: 132 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -875,29 +875,23 @@ interface Data {
875875
The other resources' data is the result of applying some conversion method or
876876
a chain of such methods to the first resource's data. Detailed information
877877
about which conversion method applied to which data resulted in which other
878-
data is recorded in the tree with the root `resourceRoot`.
878+
data is recorded in the tree `resourceTree` with the root `resourceTree.root`
879+
and the non-root vertices `resourceTree.nonRootVertices`.
879880
880881
Note that all resources describe the same data only in different formats.
881882
"""
882883
resources: [GetHttpsResource!]!
883884

884885
"""
885-
Root vertex made up of
886-
* an HTTP resource with meta information of the actual data
887-
requestable through the protocol HTTP over
888-
TLS, in short, HTTPS, with `GET` requests, where the data is
889-
the result of applying
890-
the method `appliedMethod`, and
891-
* child vertices, where each child vertex is made up of an HTTP resource whose
892-
data is the result of applying some conversion method to the root's data,
893-
child vertices of itself, and the applied conversion method.
894-
895-
By traversing the tree from the root at each vertex it is clear how its data
896-
was obtained from its parent's data.
886+
Multiple HTTP resources organized as tree with meta information of the actual
887+
data requestable through the protocol HTTP over TLS, in short, HTTPS, with
888+
`GET` requests. The root-resource's data is the result of applying the method
889+
`appliedMethod`. Each non-root-resource's data is the result of applying
890+
a specified conversion method to its parent resource's data.
897891
898892
Note that all resources describe the same data only in different formats.
899893
"""
900-
resourceRoot: GetHttpsResourceRoot!
894+
resourceTree: GetHttpsResourceTree!
901895

902896
"""
903897
Approval by the database of the result without the field `approval` itself.
@@ -925,7 +919,7 @@ type OpticalData implements Node & Data {
925919
appliedMethod: AppliedMethod!
926920
validity: OpenEndedDateTimeRange!
927921
resources: [GetHttpsResource!]!
928-
resourceRoot: GetHttpsResourceRoot!
922+
resourceTree: GetHttpsResourceTree!
929923
approvals: [DataApproval!]!
930924
approval: ResponseApproval!
931925

@@ -951,7 +945,7 @@ type CalorimetricData implements Node & Data {
951945
appliedMethod: AppliedMethod!
952946
validity: OpenEndedDateTimeRange!
953947
resources: [GetHttpsResource!]!
954-
resourceRoot: GetHttpsResourceRoot!
948+
resourceTree: GetHttpsResourceTree!
955949
approvals: [DataApproval!]!
956950
approval: ResponseApproval!
957951

@@ -981,7 +975,7 @@ type HygrothermalData implements Node & Data {
981975
appliedMethod: AppliedMethod!
982976
validity: OpenEndedDateTimeRange!
983977
resources: [GetHttpsResource!]!
984-
resourceRoot: GetHttpsResourceRoot!
978+
resourceTree: GetHttpsResourceTree!
985979
approvals: [DataApproval!]!
986980
approval: ResponseApproval!
987981
}
@@ -1001,7 +995,7 @@ type PhotovoltaicData implements Node & Data {
1001995
appliedMethod: AppliedMethod!
1002996
validity: OpenEndedDateTimeRange!
1003997
resources: [GetHttpsResource!]!
1004-
resourceRoot: GetHttpsResourceRoot!
998+
resourceTree: GetHttpsResourceTree!
1005999
approvals: [DataApproval!]!
10061000
approval: ResponseApproval!
10071001
}
@@ -1041,27 +1035,35 @@ type AppliedMethod {
10411035
}
10421036

10431037
"""
1044-
Applied method whose sources are implicit from the context in which it is
1045-
used.
1038+
Applied conversion method to exactly one named source identified by tree-vertex
1039+
identifier.
10461040
"""
1047-
type AppliedMethodWithImplicitSources {
1041+
type ToTreeVertexAppliedConversionMethod {
10481042
"""
1049-
Method identifier of method that was applied by the creator on the source
1050-
data. The method's meta data can be obtained by sending the GraphQL query
1043+
Method identifier of conversion method that was applied by the creator on the
1044+
source data. The method's meta data can be obtained by sending the GraphQL
1045+
query
10511046
`method(methodId: ..., timestamp: ...) { ... }`
10521047
to the metabase.
10531048
"""
10541049
methodId: Uuid!
10551050

10561051
"""
1057-
Named arguments to configure the method.
1052+
Named arguments to configure the conversion method.
10581053
- For each parameter required by the method, there is exactly one argument in
10591054
the list.
10601055
- Each argument in the list corresponds to an optional or required parameter
10611056
of the method.
10621057
- Each two distinct arguments in the list have different names.
10631058
"""
1064-
arguments: [MethodArgument!]!
1059+
arguments: [NamedMethodArgument!]!
1060+
1061+
"""
1062+
Named data source identified by tree-vertex identifier to which the
1063+
conversion method was applied. The conversion method requires exactly one
1064+
named source and a value for this source is given.
1065+
"""
1066+
source: NamedTreeVertexMethodSource!
10651067
}
10661068

10671069
"""
@@ -1094,6 +1096,21 @@ type NamedMethodSource {
10941096
value: CrossDatabaseDataReference!
10951097
}
10961098

1099+
"""
1100+
Named local data source of a method.
1101+
"""
1102+
type NamedTreeVertexMethodSource {
1103+
"""
1104+
Name
1105+
"""
1106+
name: String!
1107+
1108+
"""
1109+
Method source as tree-vertex identifier.
1110+
"""
1111+
value: ID!
1112+
}
1113+
10971114
"""
10981115
Cross-database data reference.
10991116
"""
@@ -1557,6 +1574,96 @@ type GetHttpsResource {
15571574
archivedFilesMetaInformation: [FileMetaInformation!]!
15581575
}
15591576

1577+
"""
1578+
Multiple HTTP resources organized as tree with meta information of the actual
1579+
data requestable through the protocol HTTP over TLS, in short, HTTPS, with
1580+
`GET` requests. Each vertex specifies
1581+
* a vertex identifier (unique among the tree vertices),
1582+
* child vertex identifiers, and
1583+
* an HTTP resource.
1584+
Each non-root vertex also specifies an applied conversion method with its
1585+
parent vertex's identifier as source, where indeed the non-root-resource's data
1586+
is the result of applying the conversion method to its parent resource's data.
1587+
1588+
The root vertex is in the field `root` and non-root resource vertices are in
1589+
the field `nonRootVertices`. The order of a vertex's child identifiers is
1590+
identical to the order in which they occur in the list of non-root vertices.
1591+
1592+
Note that all resources describe the same data only in different formats.
1593+
"""
1594+
interface GetHttpsResourceTree {
1595+
"""
1596+
Root resource vertex.
1597+
"""
1598+
root: GetHttpsResourceTreeRoot!
1599+
1600+
"""
1601+
Non-root resource vertices in breadth-first order starting from, but not
1602+
including, the root vertex.
1603+
1604+
By traversing the tree from the root at each vertex it is clear how the
1605+
vertex's data was obtained from the parent's data and by remembering or
1606+
composing the chain of applied conversion methods how the vertex's data was
1607+
obtained from the root's data.
1608+
"""
1609+
nonRootVertices: [GetHttpsResourceTreeNonRootVertex!]!
1610+
}
1611+
1612+
"""
1613+
A root or non-root resource is the result of some measurement or simulation, or
1614+
of applying some conversion method to its parent resource. Its child resources
1615+
are the results of applying conversion methods to it, the child resources of
1616+
its child resources are the results of applying conversion methods to the child
1617+
resources, and so forth. The applied conversion methods are specified in the
1618+
child resources.
1619+
"""
1620+
interface GetHttpsResourceTreeVertex {
1621+
"""
1622+
Vertex identifier unique among the tree vertices. It is used to set-up edges,
1623+
that is, parent/child relationships, in the flattened tree structure.
1624+
"""
1625+
vertexId: ID!
1626+
1627+
"""
1628+
Identifiers of child resource vertices whose resource data is obtained by
1629+
applying conversion methods to this vertex's resource data. Note that each
1630+
child vertex's conversion method has the present vertex's identifier as
1631+
source value.
1632+
"""
1633+
childIds: [ID!]!
1634+
1635+
"""
1636+
Resource
1637+
"""
1638+
value: GetHttpsResource!
1639+
}
1640+
1641+
"""
1642+
A root resource is the direct result of some measurement or simulation.
1643+
"""
1644+
type GetHttpsResourceTreeRoot implements GetHttpsResourceTreeVertex {
1645+
vertexId: ID!
1646+
childIds: [ID!]!
1647+
value: GetHttpsResource!
1648+
}
1649+
1650+
"""
1651+
A non-root resource is the result of applying some conversion method to its
1652+
parent resource.
1653+
"""
1654+
type GetHttpsResourceTreeNonRootVertex implements GetHttpsResourceTreeVertex {
1655+
vertexId: ID!
1656+
childIds: [ID!]!
1657+
value: GetHttpsResource!
1658+
1659+
"""
1660+
Conversion method applied to the parent resource to obtain the present
1661+
vertex's resource. The parent resource is identified by the vertex identifier
1662+
`appliedConversionMethod.source.value`.
1663+
"""
1664+
appliedConversionMethod: ToTreeVertexAppliedConversionMethod!
1665+
}
1666+
15601667
"""
15611668
File meta information.
15621669
"""
@@ -1603,47 +1710,3 @@ type FileMetaInformation {
16031710
"""
16041711
formatId: Uuid!
16051712
}
1606-
1607-
"""
1608-
A root or non-root resource is the result of some measurement or simulation, or
1609-
of applying some conversion method to its parent resource. Its child resources
1610-
are the results of applying conversion methods to it, the child resources of
1611-
its child resources are the results of applying conversion methods to the child
1612-
resources, and so forth. The applied conversion methods are specified in the
1613-
child resources.
1614-
"""
1615-
interface GetHttpsResourceVertex {
1616-
"""
1617-
Resource
1618-
"""
1619-
resource: GetHttpsResource!
1620-
1621-
"""
1622-
Child resources obtained by applying conversion methods to the present
1623-
resource.
1624-
"""
1625-
children: [GetHttpsResourceNonRootVertex!]!
1626-
}
1627-
1628-
"""
1629-
A root resource is the direct result of some measurement or simulation.
1630-
"""
1631-
type GetHttpsResourceRoot implements GetHttpsResourceVertex {
1632-
resource: GetHttpsResource!
1633-
children: [GetHttpsResourceNonRootVertex!]!
1634-
}
1635-
1636-
"""
1637-
A non-root resource is the result of applying some conversion method to its
1638-
parent resource.
1639-
"""
1640-
type GetHttpsResourceNonRootVertex implements GetHttpsResourceVertex {
1641-
resource: GetHttpsResource!
1642-
children: [GetHttpsResourceNonRootVertex!]!
1643-
1644-
"""
1645-
Conversion method applied to the parent resource to obtain the present
1646-
resource.
1647-
"""
1648-
appliedConversionMethod: AppliedMethodWithImplicitSources!
1649-
}

queries/database/data.graphql

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,25 @@ query {
5454
formatId
5555
}
5656
}
57-
resourceRoot {
58-
resource {
59-
description
60-
hashValue
61-
locator
62-
formatId
63-
archivedFilesMetaInformation {
64-
path
57+
resourceTree {
58+
root {
59+
vertexId
60+
childIds
61+
value {
62+
description
63+
hashValue
64+
locator
6565
formatId
66+
archivedFilesMetaInformation {
67+
path
68+
formatId
69+
}
6670
}
6771
}
68-
children {
69-
resource {
72+
nonRootVertices {
73+
vertexId
74+
childIds
75+
value {
7076
description
7177
hashValue
7278
locator
@@ -82,6 +88,10 @@ query {
8288
name
8389
value
8490
}
91+
source {
92+
name
93+
value
94+
}
8595
}
8696
}
8797
}

0 commit comments

Comments
 (0)