From 8e8d3d8e6dfec86c210a1b5874e839ad8adaef4b Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Sat, 13 Nov 2021 13:04:41 -0600 Subject: graphql: T3993: move schema generation to bindings.py; clean up for linting (cherry picked from commit 9e2694b24b06d928240522322c9a6d60c7a7d290) --- src/services/api/graphql/bindings.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/services/api/graphql/bindings.py (limited to 'src/services/api') 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 -- cgit v1.2.3