diff --git a/selfprivacy_api/dependencies.py b/selfprivacy_api/dependencies.py index d48074c..b2e2b19 100644 --- a/selfprivacy_api/dependencies.py +++ b/selfprivacy_api/dependencies.py @@ -27,4 +27,4 @@ async def get_token_header( def get_api_version() -> str: """Get API version""" - return "3.3.0+configs" + return "3.3.0" diff --git a/selfprivacy_api/graphql/mutations/services_mutations.py b/selfprivacy_api/graphql/mutations/services_mutations.py index 704fc96..34f9539 100644 --- a/selfprivacy_api/graphql/mutations/services_mutations.py +++ b/selfprivacy_api/graphql/mutations/services_mutations.py @@ -41,6 +41,41 @@ class SetServiceConfigurationInput: service_id: str configuration: strawberry.scalars.JSON + """Yes, it is a JSON scalar, which is supposed to be a Map. + I can't define it as a proper type because GraphQL doesn't support unions in input types. + There is a @oneOf directive, but it doesn't fit this usecase. + + Other option would have been doing something like this: + ```python + @strawberry.type + class StringConfigurationInputField: + fieldId: str + value: str + + @strawberry.type + class BoolConfigurationInputField: + fieldId: str + value: bool + + // ... + + @strawberry.input + class SetServiceConfigurationInput: + service_id: str + stringFields: List[StringConfigurationInputField] + boolFields: List[BoolConfigurationInputField] + enumFields: List[EnumConfigurationInputField] + intFields: List[IntConfigurationInputField] + ``` + + But it would be very painful to maintain and will break compatibility with + every change. + + Be careful when parsing it. Probably it will be wise to add a parser/validator + later when we get a new Pydantic integration in Strawberry. + + -- Inex, 26.07.2024 + """ @strawberry.input diff --git a/selfprivacy_api/services/service.py b/selfprivacy_api/services/service.py index 114d76c..17b6f4f 100644 --- a/selfprivacy_api/services/service.py +++ b/selfprivacy_api/services/service.py @@ -381,7 +381,7 @@ class Service(ABC): try: ensure_folder_ownership(binds) except Exception as error: - # We have logged it via write_to_log and we additionally log it here in the error field + # We have logged it via print and we additionally log it here in the error field # We are continuing anyway but Job has no warning field Jobs.update( job,