Skip to content

Commit

Permalink
Upgrade of graphql as community supported tool
Browse files Browse the repository at this point in the history
- adopt graphql to use exporters
- remove additional fields `source` and `channel`
- add graphql specific parameter to add additional metadata
- adopt readme
- remove graphql exporters from contrib

call with:
```
${TOOLSDIR}/vspec2graphql.py -I ./spec --gqlfield "source" "Source System" --gqlfield "channel" "Collecting channel" ./spec/VehicleSignalSpecification.vspec vss_rel_$$(cat VERSION).graphql.ts
```

Signed-off-by: Daniel Wilms <Daniel.DW.Wilms@bmw.de>
  • Loading branch information
danielwilms committed Jun 8, 2022
1 parent 1a32b53 commit 41f71ef
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 237 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Examples on tool usage can be found in the [VSS Makefile](https://github.com/COV
[vspec2ocf.py](contrib/ocf/vspec2ocf.py) | Parses and expands a VSS and generates a OCF specification | Contrib (Obsolete, no longer functional) | - |
[vspec2proto.py](contrib/vspec2protobuf.py) | Parses and expands a VSS and generates a Protobuf specification | Contrib (Beta) | - |
[vspec2ttl.py](contrib/vspec2ttl/vspec2ttl.py) | Parses and expands a VSS and generates a TTL specification | Contrib | - |
[vspec2graphql.py](contrib/vspec2graphql.py) | Parses and expands a VSS and generates a GraphQL specification | Contrib | - |
[vspec2graphql.py](contrib/vspec2graphql.py) | Parses and expands a VSS and generates a GraphQL specification | Community Supported | [Documentation](docs/VSS2GRAPHQL.md) |

## Tool Architecture

Expand Down
129 changes: 0 additions & 129 deletions contrib/vspec2graphql.py

This file was deleted.

1 change: 0 additions & 1 deletion contrib/vspec2graphql/.gitignore

This file was deleted.

Empty file removed contrib/vspec2graphql/__init__.py
Empty file.
Empty file.
80 changes: 0 additions & 80 deletions contrib/vspec2graphql_alternative.py

This file was deleted.

39 changes: 26 additions & 13 deletions contrib/vspec2graphql/README.md → docs/VSS2GRAPHQL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## What does vspec2graphql do?
## vspec2graphql

This allows to automatically generate a graphql schema that can represent VSS data.
This exporter allows to automatically generate a graphql schema that can represent VSS data.
The resulting schema does only allow querying information. Mutations are not supported.

The resulting schema will look something like this:
Expand Down Expand Up @@ -37,23 +37,36 @@ type Vehicle_VehicleIdentification_Brand {
"""Value: Vehicle brand or manufacturer"""
value: String
"""Source system: Vehicle brand or manufacturer"""
source: String
"""Collecting channel: Vehicle brand or manufacturer"""
channel: String
"""Timestamp: Vehicle brand or manufacturer"""
timestamp: String
}
```

Above, `source` and `channel` are free text fields which can be used to include information on the origin of the data. Content is implementation specific. `timestamp` shall be the timestamp of the observation formatted according to ISO 8601 with UTC time zone.

Every leaf has a timestamp. This is supposed to contain the date of the last modification of the value.
Queries can then filter data that has been recorded after a given timestamp.

After adjusting the vspec path in the makefile you should be able to execute
`make graphql` in `vss-tools/vspec2graphql`.
The generated schema can then be found in: `vss-tools/vspec2graphql/generated/result.graphql`
### Additional leaf parameters

As for `timestamp` in some scenarios it makes sense to add certain metadata like the `source` of a
served signal or additional privacy information. Therefore the tool has an additional calling parameter
`--gqlfield <name> <description>`, which takes the name and description of the additional field, like:

```
--gqlfield "source" "Source System"
```

Resulting in the following leaf in the schema:

```
"""Vehicle brand or manufacturer"""
type Vehicle_VehicleIdentification_Brand {
"""Value: Vehicle brand or manufacturer."""
value: String
"""Timestamp: Vehicle brand or manufacturer."""
timestamp: String
""" Source System: Vehicle brand or manufacturer."""
source: String
}
```
17 changes: 17 additions & 0 deletions vspec2graphql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3
#
#
# (c) 2022 BMW Group
#
# All files and artifacts in this repository are licensed under the
# provisions of the license provided by the LICENSE file in this repository.
#
#
# Convert vspec2grahql wrapper for vspec2x
#

import sys
import vspec2x

if __name__ == "__main__":
vspec2x.main(["--format", "graphql"]+sys.argv[1:])
3 changes: 2 additions & 1 deletion vspec2x.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import sys
import vspec

from vssexporters import vss2json, vss2csv, vss2yaml, vss2binary, vss2franca, vss2ddsidl
from vssexporters import vss2json, vss2csv, vss2yaml, vss2binary, vss2franca, vss2ddsidl, vss2graphql



Expand All @@ -34,6 +34,7 @@ def export(config: argparse.Namespace, root: VSSNode):
binary = vss2binary
franca = vss2franca
idl = vss2ddsidl
graphql = vss2graphql

def __str__(self):
return self.name
Expand Down
Loading

0 comments on commit 41f71ef

Please sign in to comment.