diff options
author | John Estabrook <jestabro@vyos.io> | 2021-11-13 13:04:41 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2021-11-15 15:36:24 -0600 |
commit | 8e8d3d8e6dfec86c210a1b5874e839ad8adaef4b (patch) | |
tree | 5c3ac0e54908f45defbbd1cf687865a1cd30e4e0 /src/services/api/graphql/bindings.py | |
parent | ef392ba9715290a5b8e8b619fc19e708fe7e442b (diff) | |
download | vyos-1x-8e8d3d8e6dfec86c210a1b5874e839ad8adaef4b.tar.gz vyos-1x-8e8d3d8e6dfec86c210a1b5874e839ad8adaef4b.zip |
graphql: T3993: move schema generation to bindings.py; clean up for linting
(cherry picked from commit 9e2694b24b06d928240522322c9a6d60c7a7d290)
Diffstat (limited to 'src/services/api/graphql/bindings.py')
-rw-r--r-- | src/services/api/graphql/bindings.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/services/api/graphql/bindings.py b/src/services/api/graphql/bindings.py new file mode 100644 index 000000000..1403841b4 --- /dev/null +++ b/src/services/api/graphql/bindings.py @@ -0,0 +1,14 @@ +import vyos.defaults +from . graphql.mutations import mutation +from . graphql.directives import DataDirective + +from ariadne import make_executable_schema, load_schema_from_path, snake_case_fallback_resolvers + +def generate_schema(): + api_schema_dir = vyos.defaults.directories['api_schema'] + + type_defs = load_schema_from_path(api_schema_dir) + + schema = make_executable_schema(type_defs, mutation, snake_case_fallback_resolvers, directives={"generate": DataDirective}) + + return schema |