From f9fdc1baa6225e43767804e3fcb8449f7cc561f0 Mon Sep 17 00:00:00 2001 From: ash Date: Tue, 6 Feb 2024 17:28:40 +0000 Subject: [PATCH 1/2] Type Environment.type as an enum, not a string --- softpack_core/artifacts.py | 12 ++++++++++-- softpack_core/schemas/environment.py | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/softpack_core/artifacts.py b/softpack_core/artifacts.py index 789b6e0..987f3bb 100644 --- a/softpack_core/artifacts.py +++ b/softpack_core/artifacts.py @@ -56,6 +56,14 @@ class State(Enum): failed = 'failed' +@strawberry.enum +class Type(Enum): + """Environment types.""" + + softpack = "softpack" + module = "module" + + class Artifacts: """Artifacts repo access class.""" @@ -65,9 +73,9 @@ class Artifacts: module_file = "module" readme_file = "README.md" built_by_softpack_file = ".built_by_softpack" - built_by_softpack = "softpack" + built_by_softpack = Type.softpack.value generated_from_module_file = ".generated_from_module" - generated_from_module = "module" + generated_from_module = Type.module.value users_folder_name = "users" groups_folder_name = "groups" credentials_callback = None diff --git a/softpack_core/schemas/environment.py b/softpack_core/schemas/environment.py index 5e8b20d..0801b59 100644 --- a/softpack_core/schemas/environment.py +++ b/softpack_core/schemas/environment.py @@ -19,7 +19,7 @@ from strawberry.file_uploads import Upload from softpack_core.app import app -from softpack_core.artifacts import Artifacts, Package, State +from softpack_core.artifacts import Artifacts, Package, State, Type from softpack_core.module import GenerateEnvReadme, ToSoftpackYML from softpack_core.schemas.base import BaseSchema @@ -196,7 +196,7 @@ class Environment: path: str description: str readme: str - type: str + type: Type packages: list[Package] state: Optional[State] artifacts = Artifacts() From 8ce9ddb1a033c1e791e625bdda5ecce377a7e6db Mon Sep 17 00:00:00 2001 From: ash Date: Wed, 7 Feb 2024 09:16:44 +0000 Subject: [PATCH 2/2] Document how to generate GraphQL schema --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index e124f07..2ab81d6 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,12 @@ Run [MkDocs] server to view documentation: poetry run mkdocs serve ``` +To generate a GraphQL schema file: + +``` +poetry run strawberry export-schema softpack_core.graphql:GraphQL.schema > schema.graphql +``` + [pip]: https://pip.pypa.io [Python installation guide]: http://docs.python-guide.org/en/latest/starting/installation/