Skip to content

Commit

Permalink
Updated version create to return a full Version
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-Morgan committed Feb 13, 2025
1 parent cab9674 commit 7671998
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/specklepy/api/resources/current/version_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_versions(
model_id, project_id, limit=limit, cursor=cursor, filter=filter
)

def create(self, input: CreateVersionInput) -> str:
def create(self, input: CreateVersionInput) -> Version:
metrics.track(metrics.SDK, self.account, {"name": "Version Create"})
return super().create(input)

Expand Down
23 changes: 18 additions & 5 deletions src/specklepy/core/api/resources/current/version_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,39 @@ def get_versions(
variables,
).data.data.data

def create(self, input: CreateVersionInput) -> str:
def create(self, input: CreateVersionInput) -> Version:
QUERY = gql(
"""
mutation Create($input: CreateVersionInput!) {
data:versionMutations {
data:create(input: $input) {
data:id
id
referencedObject
message
sourceApplication
createdAt
previewUrl
authorUser {
id
name
bio
company
verified
role
avatar
}
}
}
}
"""
)

variables = {
"input": input.model_dump(warnings="error"),
}

return self.make_request_and_parse_response(
DataResponse[DataResponse[DataResponse[str]]], QUERY, variables
).data.data.data
DataResponse[DataResponse[Version]], QUERY, variables
).data.data

def update(self, input: UpdateVersionInput) -> Version:
QUERY = gql(
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ def create_version(client: SpeckleClient, project_id: str, model_id: str) -> Ver
input = CreateVersionInput(
objectId=objectId, modelId=model_id, projectId=project_id
)
version_id = client.version.create(input)
return client.version.get(version_id, project_id)
return client.version.create(input)


@pytest.fixture(scope="session")
Expand Down

0 comments on commit 7671998

Please sign in to comment.