Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Change nullable installation query to non nullable. Rename queries and mutations to keep the same convention

Maciej Korycinskid1620747490d
diff --git a/saleor/graphql/app/mutations.py b/saleor/graphql/app/mutations.py
index b88aeca9f5..20f86ebfa4 100644
--- a/saleor/graphql/app/mutations.py
+++ b/saleor/graphql/app/mutations.py
@@ -208,7 +208,7 @@ class AppDelete(ModelDeleteMutation):
raise ValidationError({"id": ValidationError(msg, code=code)})
-class DropFailedInstallation(ModelDeleteMutation):
+class AppDropFailedInstallation(ModelDeleteMutation):
class Arguments:
id = graphene.ID(
description="ID of failed installation to drop.", required=True
@@ -238,7 +238,7 @@ class DropFailedInstallation(ModelDeleteMutation):
raise ValidationError({"id": ValidationError(msg, code=code)})
-class RetryInstallApp(ModelMutation):
+class AppRetryInstall(ModelMutation):
class Arguments:
id = graphene.ID(description="ID of failed installation.", required=True)
activate_after_installation = graphene.Boolean(
@@ -286,7 +286,7 @@ class RetryInstallApp(ModelMutation):
return cls.success_response(app_job)
-class InstallAppInput(graphene.InputObjectType):
+class AppInstallInput(graphene.InputObjectType):
name = graphene.String(description="Name of the app to install.")
manifest_url = graphene.String(description="Url to app's manifest in JSON format.")
activate_after_installation = graphene.Boolean(
@@ -300,9 +300,9 @@ class InstallAppInput(graphene.InputObjectType):
)
-class InstallApp(ModelMutation):
+class AppInstall(ModelMutation):
class Arguments:
- input = InstallAppInput(
+ input = AppInstallInput(
required=True, description="Fields required to install a new app.",
)
diff --git a/saleor/graphql/app/schema.py b/saleor/graphql/app/schema.py
index 90710912e9..26462e1b7a 100644
--- a/saleor/graphql/app/schema.py
+++ b/saleor/graphql/app/schema.py
@@ -8,16 +8,16 @@ from .filters import AppFilter
from .mutations import (
AppCreate,
AppDelete,
+ AppDropFailedInstallation,
+ AppInstall,
+ AppRetryInstall,
AppTokenCreate,
AppTokenDelete,
AppUpdate,
- DropFailedInstallation,
- InstallApp,
- RetryInstallApp,
)
from .resolvers import resolve_apps, resolve_ongoing_apps_installations
from .sorters import AppSortingInput
-from .types import App, OngoingAppInstallation
+from .types import App, AppOngoingInstallation
class AppFilterInput(FilterInputObjectType):
@@ -26,8 +26,10 @@ class AppFilterInput(FilterInputObjectType):
class AppQueries(graphene.ObjectType):
- ongoing_apps_installations = graphene.List(
- OngoingAppInstallation, description="List of all ongoing apps installations"
+ apps_ongoing_installations = graphene.List(
+ graphene.NonNull(AppOngoingInstallation),
+ description="List of all ongoing apps installations",
+ required=True,
)
apps = FilterInputConnectionField(
App,
@@ -42,7 +44,7 @@ class AppQueries(graphene.ObjectType):
)
@permission_required(AppPermission.MANAGE_APPS)
- def resolve_ongoing_apps_installations(self, info, **kwargs):
+ def resolve_apps_ongoing_installations(self, info, **kwargs):
return resolve_ongoing_apps_installations(info, **kwargs)
@permission_required(AppPermission.MANAGE_APPS)
@@ -62,6 +64,6 @@ class AppMutations(graphene.ObjectType):
app_token_create = AppTokenCreate.Field()
app_token_delete = AppTokenDelete.Field()
- install_app = InstallApp.Field()
- retry_install_app = RetryInstallApp.Field()
- drop_failed_installation = DropFailedInstallation.Field()
+ app_install = AppInstall.Field()
+ app_retry_install = AppRetryInstall.Field()
+ app_drop_failed_installation = AppDropFailedInstallation.Field()
diff --git a/saleor/graphql/app/types.py b/saleor/graphql/app/types.py
index 3a3f078394..5537c27fff 100644
--- a/saleor/graphql/app/types.py
+++ b/saleor/graphql/app/types.py
@@ -106,7 +106,7 @@ class App(CountableDjangoObjectType):
return root.webhooks.all()
-class OngoingAppInstallation(CountableDjangoObjectType):
+class AppOngoingInstallation(CountableDjangoObjectType):
class Meta:
model = models.AppJob
description = "Represents ongoing installation of app."
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 5bbe452622..fbc6590df9 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -237,6 +237,12 @@ type AppDelete {
app: App
}
+type AppDropFailedInstallation {
+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
+ appErrors: [AppError!]!
+ appJob: AppOngoingInstallation
+}
+
type AppError {
field: String
message: String
@@ -266,6 +272,19 @@ input AppInput {
permissions: [PermissionEnum]
}
+type AppInstall {
+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
+ appErrors: [AppError!]!
+ appJob: AppOngoingInstallation
+}
+
+input AppInstallInput {
+ name: String
+ manifestUrl: String
+ activateAfterInstallation: Boolean = true
+ permissions: [PermissionEnum]
+}
+
enum AppJobStatus {
PENDING
SUCCESS
@@ -273,6 +292,22 @@ enum AppJobStatus {
DELETED
}
+type AppOngoingInstallation {
+ id: ID!
+ status: AppJobStatus!
+ message: String
+ createdAt: DateTime!
+ updatedAt: DateTime!
+ name: String!
+ manifestUrl: String!
+}
+
+type AppRetryInstall {
+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
+ appErrors: [AppError!]!
+ appJob: AppOngoingInstallation
+}
+
enum AppSortField {
NAME
CREATION_DATE
@@ -1761,12 +1796,6 @@ type DraftOrderUpdate {
order: Order
}
-type DropFailedInstallation {
- errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
- appErrors: [AppError!]!
- appJob: OngoingAppInstallation
-}
-
type Error {
field: String
message: String
@@ -1961,19 +1990,6 @@ type Image {
alt: String
}
-type InstallApp {
- errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
- appErrors: [AppError!]!
- appJob: OngoingAppInstallation
-}
-
-input InstallAppInput {
- name: String
- manifestUrl: String
- activateAfterInstallation: Boolean = true
- permissions: [PermissionEnum]
-}
-
input IntRangeInput {
gte: Int
lte: Int
@@ -2506,9 +2522,9 @@ type Mutation {
appDelete(id: ID!): AppDelete
appTokenCreate(input: AppTokenInput!): AppTokenCreate
appTokenDelete(id: ID!): AppTokenDelete
- installApp(input: InstallAppInput!): InstallApp
- retryInstallApp(activateAfterInstallation: Boolean = true, id: ID!): RetryInstallApp
- dropFailedInstallation(id: ID!): DropFailedInstallation
+ appInstall(input: AppInstallInput!): AppInstall
+ appRetryInstall(activateAfterInstallation: Boolean = true, id: ID!): AppRetryInstall
+ appDropFailedInstallation(id: ID!): AppDropFailedInstallation
requestPasswordReset(email: String!, redirectUrl: String!): RequestPasswordReset
confirmAccount(email: String!, token: String!): ConfirmAccount
setPassword(token: String!, email: String!, password: String!): SetPassword
@@ -2580,16 +2596,6 @@ interface ObjectWithMetadata {
meta: [MetaStore]! @deprecated(reason: "Use the `metadata` field. This field will be removed after 2020-07-31.")
}
-type OngoingAppInstallation {
- id: ID!
- status: AppJobStatus!
- message: String
- createdAt: DateTime!
- updatedAt: DateTime!
- name: String!
- manifestUrl: String!
-}
-
type Order implements Node & ObjectWithMetadata {
id: ID!
created: DateTime!
@@ -3978,7 +3984,7 @@ type Query {
checkouts(before: String, after: String, first: Int, last: Int): CheckoutCountableConnection
checkoutLine(id: ID): CheckoutLine
checkoutLines(before: String, after: String, first: Int, last: Int): CheckoutLineCountableConnection
- ongoingAppsInstallations: [OngoingAppInstallation]
+ appsOngoingInstallations: [AppOngoingInstallation!]!
apps(filter: AppFilterInput, sortBy: AppSortingInput, before: String, after: String, first: Int, last: Int): AppCountableConnection
app(id: ID!): App
addressValidationRules(countryCode: CountryCode!, countryArea: String, city: String, cityArea: String): AddressValidationData
@@ -4026,12 +4032,6 @@ type RequestPasswordReset {
accountErrors: [AccountError!]!
}
-type RetryInstallApp {
- errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
- appErrors: [AppError!]!
- appJob: OngoingAppInstallation
-}
-
type Sale implements Node {
id: ID!
name: String!
diff --git a/tests/api/app/mutations/test_drop_failed_installation.py b/tests/api/app/mutations/test_app_drop_failed_installation.py
similarity index 95%
rename from tests/api/app/mutations/test_drop_failed_installation.py
rename to tests/api/app/mutations/test_app_drop_failed_installation.py
index 4d39073213..97e91906e3 100644
--- a/tests/api/app/mutations/test_drop_failed_installation.py
+++ b/tests/api/app/mutations/test_app_drop_failed_installation.py
@@ -6,8 +6,8 @@ from saleor.graphql.core.enums import AppErrorCode
from tests.api.utils import get_graphql_content
DROP_FAILED_INSTALLATION_MUTATION = """
- mutation DropFailedInstallation($id: ID!){
- dropFailedInstallation(id:$id){
+ mutation AppDropFailedInstallation($id: ID!){
+ appDropFailedInstallation(id:$id){
appErrors{
field
message
@@ -124,7 +124,7 @@ def test_cannot_drop_installation_if_status_is_different_than_failed(
content = get_graphql_content(response)
AppJob.objects.get()
- app_job_errors = content["data"]["dropFailedInstallation"]["appErrors"]
+ app_job_errors = content["data"]["appDropFailedInstallation"]["appErrors"]
assert len(app_job_errors) == 1
assert app_job_errors[0]["field"] == "id"
diff --git a/tests/api/app/mutations/test_install_app.py b/tests/api/app/mutations/test_app_install.py
similarity index 94%
rename from tests/api/app/mutations/test_install_app.py
rename to tests/api/app/mutations/test_app_install.py
index 2ff131cc3f..9dc5722029 100644
--- a/tests/api/app/mutations/test_install_app.py
+++ b/tests/api/app/mutations/test_app_install.py
@@ -7,9 +7,9 @@ from saleor.graphql.core.enums import AppErrorCode, PermissionEnum
from ...utils import get_graphql_content
INSTALL_APP_MUTATION = """
- mutation InstallApp(
+ mutation AppInstall(
$name: String, $manifest_url: String, $permissions: [PermissionEnum]){
- installApp(
+ appInstall(
input:{name: $name, manifestUrl: $manifest_url, permissions:$permissions}){
appJob{
id
@@ -49,7 +49,7 @@ def test_install_app_mutation(
response = staff_api_client.post_graphql(query, variables=variables,)
content = get_graphql_content(response)
app_job = AppJob.objects.get()
- app_job_data = content["data"]["installApp"]["appJob"]
+ app_job_data = content["data"]["appInstall"]["appJob"]
assert int(app_job_data["id"]) == app_job.id
assert app_job_data["status"] == JobStatus.PENDING.upper()
assert app_job_data["manifestUrl"] == app_job.manifest_url
@@ -75,7 +75,7 @@ def test_install_app_mutation_by_app(
response = app_api_client.post_graphql(query, variables=variables,)
content = get_graphql_content(response)
app_job = AppJob.objects.get()
- app_job_data = content["data"]["installApp"]["appJob"]
+ app_job_data = content["data"]["appInstall"]["appJob"]
assert int(app_job_data["id"]) == app_job.id
assert app_job_data["status"] == JobStatus.PENDING.upper()
assert app_job_data["manifestUrl"] == app_job.manifest_url
@@ -94,7 +94,7 @@ def test_app_install_mutation_out_of_scope_permissions(
}
response = staff_api_client.post_graphql(query, variables=variables,)
content = get_graphql_content(response)
- data = content["data"]["installApp"]
+ data = content["data"]["appInstall"]
errors = data["appErrors"]
assert not data["appJob"]
@@ -118,7 +118,7 @@ def test_install_app_mutation_by_app_out_of_scope_permissions(
response = app_api_client.post_graphql(query, variables=variables,)
content = get_graphql_content(response)
- data = content["data"]["installApp"]
+ data = content["data"]["appInstall"]
errors = data["appErrors"]
assert not data["appJob"]
diff --git a/tests/api/app/mutations/test_retry_install_app.py b/tests/api/app/mutations/test_app_retry_install.py
similarity index 92%
rename from tests/api/app/mutations/test_retry_install_app.py
rename to tests/api/app/mutations/test_app_retry_install.py
index a915f78737..3a6fa07a9b 100644
--- a/tests/api/app/mutations/test_retry_install_app.py
+++ b/tests/api/app/mutations/test_app_retry_install.py
@@ -8,9 +8,9 @@ from saleor.graphql.core.enums import AppErrorCode
from tests.api.utils import get_graphql_content
RETRY_INSTALL_APP_MUTATION = """
- mutation RetryInstallApp(
+ mutation AppRetryInstall(
$id: ID!, $activate_after_installation: Boolean){
- retryInstallApp(id:$id, activateAfterInstallation:$activate_after_installation){
+ appRetryInstall(id:$id, activateAfterInstallation:$activate_after_installation){
appJob{
id
status
@@ -52,7 +52,7 @@ def test_retry_install_app_mutation(
response = staff_api_client.post_graphql(query, variables=variables,)
content = get_graphql_content(response)
app_job = AppJob.objects.get()
- app_job_data = content["data"]["retryInstallApp"]["appJob"]
+ app_job_data = content["data"]["appRetryInstall"]["appJob"]
assert int(app_job_data["id"]) == app_job.id
assert app_job_data["status"] == JobStatus.PENDING.upper()
assert app_job_data["manifestUrl"] == app_job.manifest_url
@@ -84,7 +84,7 @@ def test_retry_install_app_mutation_by_app(
response = app_api_client.post_graphql(query, variables=variables,)
content = get_graphql_content(response)
app_job = AppJob.objects.get()
- app_job_data = content["data"]["retryInstallApp"]["appJob"]
+ app_job_data = content["data"]["appRetryInstall"]["appJob"]
assert int(app_job_data["id"]) == app_job.id
assert app_job_data["status"] == JobStatus.PENDING.upper()
assert app_job_data["manifestUrl"] == app_job.manifest_url
@@ -112,7 +112,7 @@ def test_retry_install_app_mutation_missing_required_permissions(
}
response = staff_api_client.post_graphql(query, variables=variables,)
content = get_graphql_content(response)
- data = content["data"]["retryInstallApp"]
+ data = content["data"]["appRetryInstall"]
errors = data["appErrors"]
assert not data["appJob"]
@@ -137,7 +137,7 @@ def test_retry_install_app_mutation_by_app_missing_required_permissions(
response = app_api_client.post_graphql(query, variables=variables,)
content = get_graphql_content(response)
- data = content["data"]["retryInstallApp"]
+ data = content["data"]["appRetryInstall"]
errors = data["appErrors"]
assert not data["appJob"]
@@ -173,8 +173,8 @@ def test_cannot_retry_installation_if_status_is_different_than_failed(
content = get_graphql_content(response)
AppJob.objects.get()
- app_job_data = content["data"]["retryInstallApp"]["appJob"]
- app_job_errors = content["data"]["retryInstallApp"]["appErrors"]
+ app_job_data = content["data"]["appRetryInstall"]["appJob"]
+ app_job_errors = content["data"]["appRetryInstall"]["appErrors"]
assert not app_job_data
assert len(app_job_errors) == 1
assert app_job_errors[0]["field"] == "id"
diff --git a/tests/api/app/queries/test_ongoing_apps_installations.py b/tests/api/app/queries/test_apps_ongoing_installations.py
similarity index 88%
rename from tests/api/app/queries/test_ongoing_apps_installations.py
rename to tests/api/app/queries/test_apps_ongoing_installations.py
index fbf8325f38..3556f928f0 100644
--- a/tests/api/app/queries/test_ongoing_apps_installations.py
+++ b/tests/api/app/queries/test_apps_ongoing_installations.py
@@ -2,7 +2,7 @@ from tests.api.utils import assert_no_permission, get_graphql_content
ONGOING_APPS_INSTALLATION_QUERY = """
{
- ongoingAppsInstallations{
+ appsOngoingInstallations{
id
}
}
@@ -15,7 +15,7 @@ def test_ongoing_apps_installation(app_job, staff_api_client, permission_manage_
ONGOING_APPS_INSTALLATION_QUERY, permissions=[permission_manage_apps]
)
content = get_graphql_content(response)
- installations = content["data"]["ongoingAppsInstallations"]
+ installations = content["data"]["appsOngoingInstallations"]
assert len(installations) == 1
assert int(installations[0]["id"]) == app_job.id
@@ -27,7 +27,7 @@ def test_ongoing_apps_installation_by_app(
ONGOING_APPS_INSTALLATION_QUERY, permissions=[permission_manage_apps]
)
content = get_graphql_content(response)
- installations = content["data"]["ongoingAppsInstallations"]
+ installations = content["data"]["appsOngoingInstallations"]
assert len(installations) == 1
assert int(installations[0]["id"]) == app_job.id