Skip to content

Commit

Permalink
fix(Datasets): rename uploadUrl mutation to refer to datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarfil committed Jul 10, 2024
1 parent 8ced0b9 commit 8535cb7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
8 changes: 4 additions & 4 deletions hexa/datasets/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ input CreateDatasetVersionFileInput {
"""
Input for creating un upload link for the file
"""
input GenerateUploadUrlInput {
input GenerateDatasetUploadUrlInput {
versionId: ID!
contentType: String!
uri: String!
Expand All @@ -302,7 +302,7 @@ enum CreateDatasetVersionFileError {
"""
Result of creating an upload url
"""
type GenerateUploadUrlResult {
type GenerateDatasetUploadUrlResult {
uploadUrl: String
success: Boolean!
errors: [CreateDatasetVersionFileError!]!
Expand All @@ -315,7 +315,7 @@ type CreateDatasetVersionFileResult {
"The created file object"
file: DatasetVersionFile
"The URL to upload the file to"
uploadUrl: String @deprecated(reason: "moved to dedicated generateUploadUrl mutation")
uploadUrl: String @deprecated(reason: "moved to dedicated generateDatasetUploadUrl mutation")
success: Boolean!
errors: [CreateDatasetVersionFileError!]!
}
Expand Down Expand Up @@ -449,7 +449,7 @@ extend type Mutation {
"Delete a dataset version."
deleteDatasetVersion(input: DeleteDatasetVersionInput!): DeleteDatasetVersionResult! @loginRequired
"Create dataset version file upload url."
generateUploadUrl(input: GenerateUploadUrlInput!): GenerateUploadUrlResult! @loginRequired
generateDatasetUploadUrl(input: GenerateDatasetUploadUrlInput!): GenerateDatasetUploadUrlResult! @loginRequired
"Create a new file in a dataset version."
createDatasetVersionFile(input: CreateDatasetVersionFileInput!): CreateDatasetVersionFileResult! @loginRequired
"Prepare to download a file in a dataset version."
Expand Down
2 changes: 1 addition & 1 deletion hexa/datasets/schema/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def resolve_delete_dataset_share(_, info, **kwargs):
return {"success": False, "errors": ["PERMISSION_DENIED"]}


@mutations.field("generateUploadUrl")
@mutations.field("generateDatasetUploadUrl")
def resolve_generate_upload_url(_, info, **kwargs):
request = info.context["request"]
mutation_input = kwargs["input"]
Expand Down
12 changes: 8 additions & 4 deletions hexa/datasets/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
from django.http import HttpRequest

from hexa.core.graphql import result_page
from hexa.datasets.api import generate_upload_url
from hexa.datasets.models import (
Dataset,
DatasetLink,
DatasetVersion,
DatasetVersionFile,
)
from hexa.files.basefs import BucketObjectAlreadyExists
from hexa.workspaces.models import Workspace
from hexa.workspaces.schema.types import workspace_object, workspace_permissions

from ...files.basefs import BucketObjectAlreadyExists
from ..api import generate_upload_url
from ..models import Dataset, DatasetLink, DatasetVersion, DatasetVersionFile

dataset_object = ObjectType("Dataset")
dataset_permissions = ObjectType("DatasetPermissions")
dataset_version_object = ObjectType("DatasetVersion")
Expand Down
8 changes: 4 additions & 4 deletions hexa/datasets/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def test_create_duplicate(self):
dataset.create_version(principal=superuser, name="Version 1")

@mock_gcp_storage
def test_genarate_upload_url(self):
def test_generate_upload_url(self):
superuser = self.create_user("[email protected]", is_superuser=True)
workspace = self.create_workspace(
superuser,
Expand All @@ -392,8 +392,8 @@ def test_genarate_upload_url(self):
self.client.force_login(superuser)
r = self.run_query(
"""
mutation generateUploadUrl ($input: GenerateUploadUrlInput!) {
generateUploadUrl(input: $input) {
mutation generateDatasetUploadUrl ($input: GenerateDatasetUploadUrlInput!) {
generateDatasetUploadUrl(input: $input) {
uploadUrl
success
errors
Expand All @@ -409,7 +409,7 @@ def test_genarate_upload_url(self):
},
)
self.assertEqual(
r["data"]["generateUploadUrl"],
r["data"]["generateDatasetUploadUrl"],
{
"uploadUrl": f"http://signed-url/{str(dataset.id)}/{str(dataset_version.id)}/uri_file.csv",
"success": True,
Expand Down

0 comments on commit 8535cb7

Please sign in to comment.