diff --git a/hexa/datasets/graphql/schema.graphql b/hexa/datasets/graphql/schema.graphql index 870e61ded..6fc53a8d0 100644 --- a/hexa/datasets/graphql/schema.graphql +++ b/hexa/datasets/graphql/schema.graphql @@ -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! @@ -302,7 +302,7 @@ enum CreateDatasetVersionFileError { """ Result of creating an upload url """ -type GenerateUploadUrlResult { +type GenerateDatasetUploadUrlResult { uploadUrl: String success: Boolean! errors: [CreateDatasetVersionFileError!]! @@ -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!]! } @@ -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." diff --git a/hexa/datasets/schema/mutations.py b/hexa/datasets/schema/mutations.py index feffc52ac..3c2e66a3e 100644 --- a/hexa/datasets/schema/mutations.py +++ b/hexa/datasets/schema/mutations.py @@ -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"] diff --git a/hexa/datasets/schema/types.py b/hexa/datasets/schema/types.py index af0697058..c52a1bbaa 100644 --- a/hexa/datasets/schema/types.py +++ b/hexa/datasets/schema/types.py @@ -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") diff --git a/hexa/datasets/tests/test_schema.py b/hexa/datasets/tests/test_schema.py index 508fcb9cd..443c6e060 100644 --- a/hexa/datasets/tests/test_schema.py +++ b/hexa/datasets/tests/test_schema.py @@ -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("superuser@blsq.com", is_superuser=True) workspace = self.create_workspace( superuser, @@ -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 @@ -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,