diff --git a/changelog/374.fixed.md b/changelog/374.fixed.md new file mode 100644 index 00000000..0751c038 --- /dev/null +++ b/changelog/374.fixed.md @@ -0,0 +1 @@ +Fix branch creation with the sync client while setting `wait_until_completion=False` \ No newline at end of file diff --git a/infrahub_sdk/branch.py b/infrahub_sdk/branch.py index 9d7de1fb..2403e1ef 100644 --- a/infrahub_sdk/branch.py +++ b/infrahub_sdk/branch.py @@ -292,13 +292,14 @@ def create( }, } - query = Mutation(mutation="BranchCreate", input_data=input_data, query=MUTATION_QUERY_DATA) + mutation_query = MUTATION_QUERY_TASK if background_execution else MUTATION_QUERY_DATA + query = Mutation(mutation="BranchCreate", input_data=input_data, query=mutation_query) response = self.client.execute_graphql(query=query.render(), tracker="mutation-branch-create") # Make sure server version is recent enough to support background execution, as previously # using background_execution=True had no effect. if background_execution and "task" in response["BranchCreate"]: - return BranchData(**response["BranchCreate"]["task"]["id"]) + return response["BranchCreate"]["task"]["id"] return BranchData(**response["BranchCreate"]["object"]) def delete(self, branch_name: str) -> bool: