Skip to content

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

Update mutation handling

dominik-zeglen4a4aa4e12b51
diff --git a/saleor/static/dashboard-next/productTypes/containers/ProductTypeDelete.tsx b/saleor/static/dashboard-next/productTypes/containers/ProductTypeDelete.tsx
index 5d03f88218..ca080e1d71 100644
--- a/saleor/static/dashboard-next/productTypes/containers/ProductTypeDelete.tsx
+++ b/saleor/static/dashboard-next/productTypes/containers/ProductTypeDelete.tsx
@@ -8,10 +8,7 @@ import {
ProductTypeDeleteMutation,
ProductTypeDeleteMutationVariables
} from "../../gql-types";
-import {
- productTypeDeleteMutation,
- TypedProductTypeDeleteMutation
-} from "../mutations";
+import { TypedProductTypeDeleteMutation } from "../mutations";
interface ProductTypeDeleteProviderProps extends PartialMutationProviderProps {
id: string;
@@ -25,7 +22,6 @@ const ProductTypeDeleteProvider: React.StatelessComponent<
ProductTypeDeleteProviderProps
> = ({ id, children, onError, onSuccess }) => (
<TypedProductTypeDeleteMutation
- mutation={productTypeDeleteMutation}
variables={{ id }}
onCompleted={onSuccess}
onError={onError}
diff --git a/saleor/static/dashboard-next/productTypes/containers/ProductTypeUpdate.tsx b/saleor/static/dashboard-next/productTypes/containers/ProductTypeUpdate.tsx
index 074c35b535..708fead10a 100644
--- a/saleor/static/dashboard-next/productTypes/containers/ProductTypeUpdate.tsx
+++ b/saleor/static/dashboard-next/productTypes/containers/ProductTypeUpdate.tsx
@@ -8,10 +8,7 @@ import {
ProductTypeUpdateMutation,
ProductTypeUpdateMutationVariables
} from "../../gql-types";
-import {
- productTypeUpdateMutation,
- TypedProductTypeUpdateMutation
-} from "../mutations";
+import { TypedProductTypeUpdateMutation } from "../mutations";
interface ProductTypeUpdateProviderProps extends PartialMutationProviderProps {
children: PartialMutationProviderRenderProps<
@@ -23,11 +20,7 @@ interface ProductTypeUpdateProviderProps extends PartialMutationProviderProps {
const ProductTypeUpdateProvider: React.StatelessComponent<
ProductTypeUpdateProviderProps
> = ({ children, onError, onSuccess }) => (
- <TypedProductTypeUpdateMutation
- mutation={productTypeUpdateMutation}
- onCompleted={onSuccess}
- onError={onError}
- >
+ <TypedProductTypeUpdateMutation onCompleted={onSuccess} onError={onError}>
{(mutate, { data, loading, error }) => {
return children({
data,
diff --git a/saleor/static/dashboard-next/productTypes/mutations.ts b/saleor/static/dashboard-next/productTypes/mutations.ts
index 6ff5b12126..a4aeceb78e 100644
--- a/saleor/static/dashboard-next/productTypes/mutations.ts
+++ b/saleor/static/dashboard-next/productTypes/mutations.ts
@@ -9,10 +9,8 @@ import {
ProductTypeUpdateMutation,
ProductTypeUpdateMutationVariables
} from "../gql-types";
+import { TypedMutation } from "../mutations";
-export const TypedProductTypeDeleteMutation = Mutation as React.ComponentType<
- MutationProps<ProductTypeDeleteMutation, ProductTypeDeleteMutationVariables>
->;
export const productTypeDeleteMutation = gql`
mutation ProductTypeDelete($id: ID!) {
productTypeDelete(id: $id) {
@@ -26,10 +24,11 @@ export const productTypeDeleteMutation = gql`
}
}
`;
+export const TypedProductTypeDeleteMutation = TypedMutation<
+ ProductTypeDeleteMutation,
+ ProductTypeDeleteMutationVariables
+>(productTypeDeleteMutation);
-export const TypedProductTypeUpdateMutation = Mutation as React.ComponentType<
- MutationProps<ProductTypeUpdateMutation, ProductTypeUpdateMutationVariables>
->;
export const productTypeUpdateMutation = gql`
mutation ProductTypeUpdate($id: ID!, $input: ProductTypeInput!) {
productTypeUpdate(id: $id, input: $input) {
@@ -64,10 +63,11 @@ export const productTypeUpdateMutation = gql`
}
}
`;
+export const TypedProductTypeUpdateMutation = TypedMutation<
+ ProductTypeUpdateMutation,
+ ProductTypeUpdateMutationVariables
+>(productTypeUpdateMutation);
-export const TypedProductTypeCreateMutation = Mutation as React.ComponentType<
- MutationProps<ProductTypeCreateMutation, ProductTypeCreateMutationVariables>
->;
export const productTypeCreateMutation = gql`
mutation ProductTypeCreate($input: ProductTypeInput!) {
productTypeCreate(input: $input) {
@@ -102,3 +102,7 @@ export const productTypeCreateMutation = gql`
}
}
`;
+export const TypedProductTypeCreateMutation = TypedMutation<
+ ProductTypeCreateMutation,
+ ProductTypeCreateMutationVariables
+>(productTypeCreateMutation);
diff --git a/saleor/static/dashboard-next/productTypes/views/ProductTypeCreate.tsx b/saleor/static/dashboard-next/productTypes/views/ProductTypeCreate.tsx
index a00fed4048..2f3ac09b52 100644
--- a/saleor/static/dashboard-next/productTypes/views/ProductTypeCreate.tsx
+++ b/saleor/static/dashboard-next/productTypes/views/ProductTypeCreate.tsx
@@ -9,10 +9,7 @@ import ProductTypeDetailsPage, {
ProductTypeForm
} from "../components/ProductTypeDetailsPage";
import { AttributeSearchProvider } from "../containers/AttributeSearch";
-import {
- productTypeCreateMutation,
- TypedProductTypeCreateMutation
-} from "../mutations";
+import { TypedProductTypeCreateMutation } from "../mutations";
import {
productTypeCreateQuery,
TypedProductTypeCreateDataQuery
@@ -52,7 +49,6 @@ export const ProductTypeUpdate: React.StatelessComponent = () => (
};
return (
<TypedProductTypeCreateMutation
- mutation={productTypeCreateMutation}
onCompleted={handleCreateSuccess}
>
{(