From 093ac258c11894b07afd9e85a61778d23e356718 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Sun, 23 Oct 2022 11:05:33 -0500 Subject: graphql: T4574: call all schema definition generation on init --- src/services/api/graphql/utils/schema_from_composite.py | 8 ++++---- src/services/api/graphql/utils/schema_from_config_session.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/services/api/graphql/utils') diff --git a/src/services/api/graphql/utils/schema_from_composite.py b/src/services/api/graphql/utils/schema_from_composite.py index f9983cd98..d5e0ecdf6 100755 --- a/src/services/api/graphql/utils/schema_from_composite.py +++ b/src/services/api/graphql/utils/schema_from_composite.py @@ -23,13 +23,15 @@ import json from inspect import signature, getmembers, isfunction, isclass, getmro from jinja2 import Template +from vyos.defaults import directories if __package__ is None or __package__ == '': from util import snake_to_pascal_case, map_type_name + from composite_function import queries, mutations else: from . util import snake_to_pascal_case, map_type_name + from . composite_function import queries, mutations -# this will be run locally before the build -SCHEMA_PATH = '../graphql/schema' +SCHEMA_PATH = directories['api_schema'] schema_data: dict = {'schema_name': '', 'schema_fields': []} @@ -100,8 +102,6 @@ def create_schema(func_name: str, func: callable, template: str) -> str: return res def generate_composite_definitions(): - from composite_function import queries, mutations - results = [] for name,func in queries.items(): res = create_schema(name, func, query_template) diff --git a/src/services/api/graphql/utils/schema_from_config_session.py b/src/services/api/graphql/utils/schema_from_config_session.py index ea78aaf88..b6609357e 100755 --- a/src/services/api/graphql/utils/schema_from_config_session.py +++ b/src/services/api/graphql/utils/schema_from_config_session.py @@ -23,13 +23,15 @@ import json from inspect import signature, getmembers, isfunction, isclass, getmro from jinja2 import Template +from vyos.defaults import directories if __package__ is None or __package__ == '': from util import snake_to_pascal_case, map_type_name + from config_session_function import queries, mutations else: from . util import snake_to_pascal_case, map_type_name + from . config_session_function import queries, mutations -# this will be run locally before the build -SCHEMA_PATH = '../graphql/schema' +SCHEMA_PATH = directories['api_schema'] schema_data: dict = {'schema_name': '', 'schema_fields': []} @@ -100,8 +102,6 @@ def create_schema(func_name: str, func: callable, template: str) -> str: return res def generate_config_session_definitions(): - from config_session_function import queries, mutations - results = [] for name,func in queries.items(): res = create_schema(name, func, query_template) -- cgit v1.2.3