From 8a4ec9832e5244f83dd234383977496f82021206 Mon Sep 17 00:00:00 2001 From: Fatih Acar Date: Wed, 18 Sep 2024 13:21:31 +0200 Subject: [PATCH] fix(backend): allow usage of "updated_at" attributes Signed-off-by: Fatih Acar --- backend/infrahub/core/node/__init__.py | 6 ++++++ changelog/3730.fixed.md | 1 + 2 files changed, 7 insertions(+) create mode 100644 changelog/3730.fixed.md diff --git a/backend/infrahub/core/node/__init__.py b/backend/infrahub/core/node/__init__.py index 62cf2d64aa..366795d505 100644 --- a/backend/infrahub/core/node/__init__.py +++ b/backend/infrahub/core/node/__init__.py @@ -239,6 +239,9 @@ async def _process_fields(self, fields: dict, db: InfrahubDatabase) -> None: # ------------------------------------------- # Validate Input # ------------------------------------------- + if "updated_at" in fields and "updated_at" not in self._schema.valid_input_names: + # FIXME: Allow users to use "updated_at" named attributes until we have proper metadata handling + fields.pop("updated_at") for field_name in fields.keys(): if field_name not in self._schema.valid_input_names: errors.append(ValidationError({field_name: f"{field_name} is not a valid input for {self.get_kind()}"})) @@ -398,6 +401,9 @@ async def load( self._existing = True if updated_at: + kwargs["updated_at"] = ( + updated_at # FIXME: Allow users to use "updated_at" named attributes until we have proper metadata handling + ) self._updated_at = Timestamp(updated_at) await self._process_fields(db=db, fields=kwargs) diff --git a/changelog/3730.fixed.md b/changelog/3730.fixed.md new file mode 100644 index 0000000000..39b82cdb25 --- /dev/null +++ b/changelog/3730.fixed.md @@ -0,0 +1 @@ +GraphQL results when querying nodes with `updated_at` named attributes will now return correct values instead of null/None