diff --git a/backend/infrahub/graphql/mutations/branch.py b/backend/infrahub/graphql/mutations/branch.py index d556c1a6ca..1456cb361c 100644 --- a/backend/infrahub/graphql/mutations/branch.py +++ b/backend/infrahub/graphql/mutations/branch.py @@ -105,6 +105,7 @@ async def mutate( fields = await extract_fields(info.field_nodes[0].selection_set) if context.service: + await context.service.component.refresh_schema_hash(branches=[obj.name]) message = messages.EventBranchCreate( branch=obj.name, branch_id=str(obj.id), diff --git a/backend/tests/unit/graphql/mutations/test_branch.py b/backend/tests/unit/graphql/mutations/test_branch.py index 2b97a4c57b..51de2edb5e 100644 --- a/backend/tests/unit/graphql/mutations/test_branch.py +++ b/backend/tests/unit/graphql/mutations/test_branch.py @@ -11,6 +11,7 @@ from infrahub.graphql.initialization import prepare_graphql_params from infrahub.message_bus import messages from infrahub.services import InfrahubServices +from tests.adapters.cache import MemoryCache from tests.adapters.message_bus import BusRecorder from tests.helpers.graphql import graphql_mutation @@ -178,8 +179,9 @@ async def test_branch_delete( query=delete_query, db=db, branch=default_branch, account_session=session_admin ) recorder = BusRecorder() - service = InfrahubServices(message_bus=recorder) - + cache = MemoryCache() + service = InfrahubServices(message_bus=recorder, cache=cache, database=db) + await service.component.initialize(service=service) create = await graphql_mutation( query=create_query, db=db, branch=default_branch, service=service, account_session=session_admin ) diff --git a/changelog/5130.fixed.md b/changelog/5130.fixed.md new file mode 100644 index 0000000000..b06084dff9 --- /dev/null +++ b/changelog/5130.fixed.md @@ -0,0 +1 @@ +Refresh branch hash on local worker during branch create