diff --git a/src/attributes/components/AttributeDetails/AttributeDetails.tsx b/src/attributes/components/AttributeDetails/AttributeDetails.tsx index fa2ba39de..5bffdb265 100644 --- a/src/attributes/components/AttributeDetails/AttributeDetails.tsx +++ b/src/attributes/components/AttributeDetails/AttributeDetails.tsx @@ -1,11 +1,11 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import CardTitle from "@saleor/components/CardTitle"; import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; import FormSpacer from "@saleor/components/FormSpacer"; import SingleSelectField from "@saleor/components/SingleSelectField"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { commonMessages } from "@saleor/intl"; import { AttributeInputTypeEnum } from "@saleor/types/globalTypes"; import { getFormErrors, getProductErrorMessage } from "@saleor/utils/errors"; diff --git a/src/attributes/components/AttributePage/AttributePage.tsx b/src/attributes/components/AttributePage/AttributePage.tsx index 099183aa2..e3ce7bc3b 100644 --- a/src/attributes/components/AttributePage/AttributePage.tsx +++ b/src/attributes/components/AttributePage/AttributePage.tsx @@ -1,4 +1,3 @@ -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import AppHeader from "@saleor/components/AppHeader"; import CardSpacer from "@saleor/components/CardSpacer"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; @@ -7,6 +6,11 @@ import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; +import { + AttributeDetailsFragment, + AttributeDetailsFragment_values +} from "@saleor/fragments/types/AttributeDetailsFragment"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { sectionNames } from "@saleor/intl"; import { maybe } from "@saleor/misc"; import { ReorderAction } from "@saleor/types"; @@ -15,10 +19,6 @@ import React from "react"; import { useIntl } from "react-intl"; import slugify from "slugify"; -import { - AttributeDetailsFragment, - AttributeDetailsFragment_values -} from "../../types/AttributeDetailsFragment"; import AttributeDetails from "../AttributeDetails"; import AttributeProperties from "../AttributeProperties"; import AttributeValues from "../AttributeValues"; diff --git a/src/attributes/components/AttributeProperties/AttributeProperties.tsx b/src/attributes/components/AttributeProperties/AttributeProperties.tsx index b88bf7060..4d5e56589 100644 --- a/src/attributes/components/AttributeProperties/AttributeProperties.tsx +++ b/src/attributes/components/AttributeProperties/AttributeProperties.tsx @@ -2,12 +2,12 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import Typography from "@material-ui/core/Typography"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import CardSpacer from "@saleor/components/CardSpacer"; import CardTitle from "@saleor/components/CardTitle"; import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; import FormSpacer from "@saleor/components/FormSpacer"; import Hr from "@saleor/components/Hr"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { commonMessages } from "@saleor/intl"; import { getFormErrors, getProductErrorMessage } from "@saleor/utils/errors"; import React from "react"; diff --git a/src/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsx b/src/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsx index 60b9c1506..0eb163ce9 100644 --- a/src/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsx +++ b/src/attributes/components/AttributeValueEditDialog/AttributeValueEditDialog.tsx @@ -5,11 +5,11 @@ import DialogContent from "@material-ui/core/DialogContent"; import DialogTitle from "@material-ui/core/DialogTitle"; import TextField from "@material-ui/core/TextField"; import { getAttributeValueErrorMessage } from "@saleor/attributes/errors"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import ConfirmButton, { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import { buttonMessages } from "@saleor/intl"; import { maybe } from "@saleor/misc"; diff --git a/src/attributes/components/AttributeValues/AttributeValues.tsx b/src/attributes/components/AttributeValues/AttributeValues.tsx index 55c6ce43a..71b9c81f0 100644 --- a/src/attributes/components/AttributeValues/AttributeValues.tsx +++ b/src/attributes/components/AttributeValues/AttributeValues.tsx @@ -13,13 +13,12 @@ import { SortableTableBody, SortableTableRow } from "@saleor/components/SortableTable"; +import { AttributeDetailsFragment_values } from "@saleor/fragments/types/AttributeDetailsFragment"; import { maybe, renderCollection, stopPropagation } from "@saleor/misc"; import { ReorderAction } from "@saleor/types"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; -import { AttributeDetailsFragment_values } from "../../types/AttributeDetailsFragment"; - export interface AttributeValuesProps { disabled: boolean; values: AttributeDetailsFragment_values[]; diff --git a/src/attributes/errors.ts b/src/attributes/errors.ts index 89ba9feac..a245bf8c2 100644 --- a/src/attributes/errors.ts +++ b/src/attributes/errors.ts @@ -1,9 +1,8 @@ +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { ProductErrorCode } from "@saleor/types/globalTypes"; import { getProductErrorMessage } from "@saleor/utils/errors"; import { defineMessages, IntlShape } from "react-intl"; -import { ProductErrorFragment } from "./types/ProductErrorFragment"; - const messages = defineMessages({ attributeSlugUnique: { defaultMessage: "Attribute with this slug already exists" diff --git a/src/attributes/fixtures.ts b/src/attributes/fixtures.ts index 7f7af4ec7..bcb9405dc 100644 --- a/src/attributes/fixtures.ts +++ b/src/attributes/fixtures.ts @@ -1,10 +1,10 @@ +import { AttributeDetailsFragment } from "@saleor/fragments/types/AttributeDetailsFragment"; import { ProductDetails_product_productType_variantAttributes } from "@saleor/products/types/ProductDetails"; import { AttributeInputTypeEnum, AttributeValueType } from "@saleor/types/globalTypes"; -import { AttributeDetailsFragment } from "./types/AttributeDetailsFragment"; import { AttributeList_attributes_edges_node } from "./types/AttributeList"; export const attribute: AttributeDetailsFragment = { diff --git a/src/attributes/mutations.ts b/src/attributes/mutations.ts index f7c607e5a..54dd0a2cb 100644 --- a/src/attributes/mutations.ts +++ b/src/attributes/mutations.ts @@ -1,7 +1,8 @@ +import { attributeDetailsFragment } from "@saleor/fragments/attributes"; +import { productErrorFragment } from "@saleor/fragments/errors"; import { TypedMutation } from "@saleor/mutations"; import gql from "graphql-tag"; -import { attributeDetailsFragment } from "./queries"; import { AttributeBulkDelete, AttributeBulkDeleteVariables @@ -35,13 +36,6 @@ import { AttributeValueUpdateVariables } from "./types/AttributeValueUpdate"; -export const productErrorFragment = gql` - fragment ProductErrorFragment on ProductError { - code - field - } -`; - const attributeBulkDelete = gql` ${productErrorFragment} mutation AttributeBulkDelete($ids: [ID!]!) { diff --git a/src/attributes/queries.ts b/src/attributes/queries.ts index 99a12cb86..1664344b9 100644 --- a/src/attributes/queries.ts +++ b/src/attributes/queries.ts @@ -1,41 +1,18 @@ +import { + attributeDetailsFragment, + attributeFragment +} from "@saleor/fragments/attributes"; +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; -import { pageInfoFragment, TypedQuery } from "../queries"; +import { TypedQuery } from "../queries"; import { AttributeDetails, AttributeDetailsVariables } from "./types/AttributeDetails"; import { AttributeList, AttributeListVariables } from "./types/AttributeList"; -export const attributeFragment = gql` - fragment AttributeFragment on Attribute { - id - name - slug - visibleInStorefront - filterableInDashboard - filterableInStorefront - } -`; - -export const attributeDetailsFragment = gql` - ${attributeFragment} - fragment AttributeDetailsFragment on Attribute { - ...AttributeFragment - availableInGrid - inputType - storefrontSearchPosition - valueRequired - values { - id - name - slug - type - } - } -`; - const attributeDetails = gql` ${attributeDetailsFragment} query AttributeDetails($id: ID!) { diff --git a/src/attributes/views/AttributeCreate/AttributeCreate.tsx b/src/attributes/views/AttributeCreate/AttributeCreate.tsx index 02cc03f00..1c9e5d5ff 100644 --- a/src/attributes/views/AttributeCreate/AttributeCreate.tsx +++ b/src/attributes/views/AttributeCreate/AttributeCreate.tsx @@ -1,4 +1,4 @@ -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import useNavigator from "@saleor/hooks/useNavigator"; import useNotifier from "@saleor/hooks/useNotifier"; import { maybe } from "@saleor/misc"; diff --git a/src/auth/AuthProvider.tsx b/src/auth/AuthProvider.tsx index e5e470b0d..8905a0fcb 100644 --- a/src/auth/AuthProvider.tsx +++ b/src/auth/AuthProvider.tsx @@ -1,4 +1,5 @@ import { DEMO_MODE } from "@saleor/config"; +import { User } from "@saleor/fragments/types/User"; import useNotifier from "@saleor/hooks/useNotifier"; import { maybe } from "@saleor/misc"; import { @@ -18,7 +19,6 @@ import { } from "./mutations"; import { RefreshToken, RefreshTokenVariables } from "./types/RefreshToken"; import { TokenAuth, TokenAuthVariables } from "./types/TokenAuth"; -import { User } from "./types/User"; import { VerifyToken, VerifyTokenVariables } from "./types/VerifyToken"; import { displayDemoMessage, diff --git a/src/auth/index.tsx b/src/auth/index.tsx index 3f2607d5f..447631f8d 100644 --- a/src/auth/index.tsx +++ b/src/auth/index.tsx @@ -1,9 +1,9 @@ +import { User } from "@saleor/fragments/types/User"; import React from "react"; import { Route, Switch } from "react-router-dom"; import Layout from "./components/Layout"; import LoginLoading from "./components/LoginLoading"; -import { User } from "./types/User"; import { newPasswordPath, passwordResetPath, diff --git a/src/auth/misc.ts b/src/auth/misc.ts index d886c35cb..a9e1392f6 100644 --- a/src/auth/misc.ts +++ b/src/auth/misc.ts @@ -1,5 +1,6 @@ +import { User } from "@saleor/fragments/types/User"; + import { PermissionEnum } from "../types/globalTypes"; -import { User } from "./types/User"; export const hasPermission = (permission: PermissionEnum, user: User) => user.userPermissions.map(perm => perm.code).includes(permission); diff --git a/src/auth/mutations.ts b/src/auth/mutations.ts index c2d794085..41778f090 100644 --- a/src/auth/mutations.ts +++ b/src/auth/mutations.ts @@ -1,4 +1,5 @@ -import { accountErrorFragment } from "@saleor/customers/mutations"; +import { fragmentUser } from "@saleor/fragments/auth"; +import { accountErrorFragment } from "@saleor/fragments/errors"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; @@ -11,22 +12,6 @@ import { SetPassword, SetPasswordVariables } from "./types/SetPassword"; import { TokenAuth, TokenAuthVariables } from "./types/TokenAuth"; import { VerifyToken, VerifyTokenVariables } from "./types/VerifyToken"; -export const fragmentUser = gql` - fragment User on User { - id - email - firstName - lastName - userPermissions { - code - name - } - avatar { - url - } - } -`; - export const tokenAuthMutation = gql` ${fragmentUser} mutation TokenAuth($email: String!, $password: String!) { diff --git a/src/categories/components/CategoryCreatePage/CategoryCreatePage.tsx b/src/categories/components/CategoryCreatePage/CategoryCreatePage.tsx index 951a026c0..4e350ce2a 100644 --- a/src/categories/components/CategoryCreatePage/CategoryCreatePage.tsx +++ b/src/categories/components/CategoryCreatePage/CategoryCreatePage.tsx @@ -1,4 +1,3 @@ -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import AppHeader from "@saleor/components/AppHeader"; import { CardSpacer } from "@saleor/components/CardSpacer"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; @@ -7,6 +6,7 @@ import Form from "@saleor/components/Form"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import SeoForm from "@saleor/components/SeoForm"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { sectionNames } from "@saleor/intl"; import { ContentState, convertToRaw, RawDraftContentState } from "draft-js"; import React from "react"; diff --git a/src/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx b/src/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx index 7d089cb14..4779571ba 100644 --- a/src/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx +++ b/src/categories/components/CategoryDetailsForm/CategoryDetailsForm.tsx @@ -1,10 +1,10 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import CardTitle from "@saleor/components/CardTitle"; import FormSpacer from "@saleor/components/FormSpacer"; import RichTextEditor from "@saleor/components/RichTextEditor"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { commonMessages } from "@saleor/intl"; import { getFormErrors, getProductErrorMessage } from "@saleor/utils/errors"; import { RawDraftContentState } from "draft-js"; diff --git a/src/categories/components/CategoryList/CategoryList.tsx b/src/categories/components/CategoryList/CategoryList.tsx index 39d1d8d28..6b4a55f2d 100644 --- a/src/categories/components/CategoryList/CategoryList.tsx +++ b/src/categories/components/CategoryList/CategoryList.tsx @@ -3,7 +3,6 @@ import TableBody from "@material-ui/core/TableBody"; import TableCell from "@material-ui/core/TableCell"; import TableFooter from "@material-ui/core/TableFooter"; import TableRow from "@material-ui/core/TableRow"; -import { CategoryFragment } from "@saleor/categories/types/CategoryFragment"; import { CategoryListUrlSortField } from "@saleor/categories/urls"; import Checkbox from "@saleor/components/Checkbox"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; @@ -11,6 +10,7 @@ import Skeleton from "@saleor/components/Skeleton"; import TableCellHeader from "@saleor/components/TableCellHeader"; import TableHead from "@saleor/components/TableHead"; import TablePagination from "@saleor/components/TablePagination"; +import { CategoryFragment } from "@saleor/fragments/types/CategoryFragment"; import { maybe, renderCollection } from "@saleor/misc"; import { ListActions, ListProps, SortPage } from "@saleor/types"; import { getArrowDirection } from "@saleor/utils/sort"; diff --git a/src/categories/components/CategoryListPage/CategoryListPage.tsx b/src/categories/components/CategoryListPage/CategoryListPage.tsx index 0015bfb99..877e57ce9 100644 --- a/src/categories/components/CategoryListPage/CategoryListPage.tsx +++ b/src/categories/components/CategoryListPage/CategoryListPage.tsx @@ -1,10 +1,10 @@ import Button from "@material-ui/core/Button"; import Card from "@material-ui/core/Card"; -import { CategoryFragment } from "@saleor/categories/types/CategoryFragment"; import { CategoryListUrlSortField } from "@saleor/categories/urls"; import Container from "@saleor/components/Container"; import PageHeader from "@saleor/components/PageHeader"; import SearchBar from "@saleor/components/SearchBar"; +import { CategoryFragment } from "@saleor/fragments/types/CategoryFragment"; import { sectionNames } from "@saleor/intl"; import { ListActions, diff --git a/src/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx b/src/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx index 91ec1591a..1e9dacdb8 100644 --- a/src/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx +++ b/src/categories/components/CategoryUpdatePage/CategoryUpdatePage.tsx @@ -1,6 +1,5 @@ import Button from "@material-ui/core/Button"; import Card from "@material-ui/core/Card"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import AppHeader from "@saleor/components/AppHeader"; import { CardSpacer } from "@saleor/components/CardSpacer"; import CardTitle from "@saleor/components/CardTitle"; @@ -11,6 +10,7 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import SeoForm from "@saleor/components/SeoForm"; import { Tab, TabContainer } from "@saleor/components/Tab"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { sectionNames } from "@saleor/intl"; import { RawDraftContentState } from "draft-js"; import React from "react"; diff --git a/src/categories/fixtures.ts b/src/categories/fixtures.ts index 60537288d..9828ce611 100644 --- a/src/categories/fixtures.ts +++ b/src/categories/fixtures.ts @@ -1,6 +1,7 @@ +import { CategoryFragment } from "@saleor/fragments/types/CategoryFragment"; + import { content } from "../storybook/stories/components/RichTextEditor"; import { CategoryDetails_category } from "./types/CategoryDetails"; -import { CategoryFragment } from "./types/CategoryFragment"; export const categories: CategoryFragment[] = [ { diff --git a/src/categories/mutations.ts b/src/categories/mutations.ts index dc41a0f25..cb61a5072 100644 --- a/src/categories/mutations.ts +++ b/src/categories/mutations.ts @@ -1,8 +1,8 @@ -import { productErrorFragment } from "@saleor/attributes/mutations"; +import { categoryDetailsFragment } from "@saleor/fragments/categories"; +import { productErrorFragment } from "@saleor/fragments/errors"; import makeMutation from "@saleor/hooks/makeMutation"; import gql from "graphql-tag"; -import { categoryDetailsFragment } from "./queries"; import { CategoryBulkDelete, CategoryBulkDeleteVariables diff --git a/src/categories/queries.ts b/src/categories/queries.ts index 1f6592a94..af7dd09ba 100644 --- a/src/categories/queries.ts +++ b/src/categories/queries.ts @@ -1,43 +1,18 @@ +import { + categoryDetailsFragment, + categoryFragment +} from "@saleor/fragments/categories"; +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; +import { fragmentMoney } from "@saleor/fragments/products"; import makeQuery from "@saleor/hooks/makeQuery"; -import { fragmentMoney } from "@saleor/products/queries"; import gql from "graphql-tag"; -import { pageInfoFragment } from "../queries"; import { CategoryDetails, CategoryDetailsVariables } from "./types/CategoryDetails"; import { RootCategories } from "./types/RootCategories"; -export const categoryFragment = gql` - fragment CategoryFragment on Category { - id - name - children { - totalCount - } - products { - totalCount - } - } -`; -export const categoryDetailsFragment = gql` - fragment CategoryDetailsFragment on Category { - id - backgroundImage { - alt - url - } - name - descriptionJson - seoDescription - seoTitle - parent { - id - } - } -`; - export const rootCategories = gql` ${categoryFragment} ${pageInfoFragment} diff --git a/src/categories/types/CategoryProperties.ts b/src/categories/types/CategoryProperties.ts deleted file mode 100644 index 3ff2be8c5..000000000 --- a/src/categories/types/CategoryProperties.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* tslint:disable */ -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL query operation: CategoryProperties -// ==================================================== - -export interface CategoryProperties_category_parent { - __typename: "Category"; - id: string; -} - -export interface CategoryProperties_category_children_edges_node_children { - __typename: "CategoryCountableConnection"; - totalCount: number | null; -} - -export interface CategoryProperties_category_children_edges_node_products { - __typename: "ProductCountableConnection"; - totalCount: number | null; -} - -export interface CategoryProperties_category_children_edges_node { - __typename: "Category"; - id: string; - name: string; - children: CategoryProperties_category_children_edges_node_children | null; - products: CategoryProperties_category_children_edges_node_products | null; -} - -export interface CategoryProperties_category_children_edges { - __typename: "CategoryCountableEdge"; - node: CategoryProperties_category_children_edges_node; -} - -export interface CategoryProperties_category_children { - __typename: "CategoryCountableConnection"; - edges: CategoryProperties_category_children_edges[]; -} - -export interface CategoryProperties_category_products_pageInfo { - __typename: "PageInfo"; - endCursor: string | null; - hasNextPage: boolean; - hasPreviousPage: boolean; - startCursor: string | null; -} - -export interface CategoryProperties_category_products_edges_node_productType { - __typename: "ProductType"; - id: string; - name: string; -} - -export interface CategoryProperties_category_products_edges_node { - __typename: "Product"; - id: string; - name: string; - thumbnailUrl: string | null; - productType: CategoryProperties_category_products_edges_node_productType; -} - -export interface CategoryProperties_category_products_edges { - __typename: "ProductCountableEdge"; - cursor: string; - node: CategoryProperties_category_products_edges_node; -} - -export interface CategoryProperties_category_products { - __typename: "ProductCountableConnection"; - pageInfo: CategoryProperties_category_products_pageInfo; - edges: CategoryProperties_category_products_edges[]; -} - -export interface CategoryProperties_category { - __typename: "Category"; - id: string; - name: string; - description: string; - parent: CategoryProperties_category_parent | null; - children: CategoryProperties_category_children | null; - products: CategoryProperties_category_products | null; -} - -export interface CategoryProperties { - category: CategoryProperties_category | null; -} - -export interface CategoryPropertiesVariables { - id: string; - first?: number | null; - after?: string | null; - last?: number | null; - before?: string | null; -} diff --git a/src/categories/types/RootCategoryChildren.ts b/src/categories/types/RootCategoryChildren.ts deleted file mode 100644 index 71f75ba20..000000000 --- a/src/categories/types/RootCategoryChildren.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* tslint:disable */ -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL query operation: RootCategoryChildren -// ==================================================== - -export interface RootCategoryChildren_categories_edges_node_children { - __typename: "CategoryCountableConnection"; - totalCount: number | null; -} - -export interface RootCategoryChildren_categories_edges_node_products { - __typename: "ProductCountableConnection"; - totalCount: number | null; -} - -export interface RootCategoryChildren_categories_edges_node { - __typename: "Category"; - id: string; - name: string; - children: RootCategoryChildren_categories_edges_node_children | null; - products: RootCategoryChildren_categories_edges_node_products | null; -} - -export interface RootCategoryChildren_categories_edges { - __typename: "CategoryCountableEdge"; - cursor: string; - node: RootCategoryChildren_categories_edges_node; -} - -export interface RootCategoryChildren_categories { - __typename: "CategoryCountableConnection"; - edges: RootCategoryChildren_categories_edges[]; -} - -export interface RootCategoryChildren { - categories: RootCategoryChildren_categories | null; -} diff --git a/src/collections/components/CollectionCreatePage/CollectionCreatePage.tsx b/src/collections/components/CollectionCreatePage/CollectionCreatePage.tsx index 714484810..fdea99d5c 100644 --- a/src/collections/components/CollectionCreatePage/CollectionCreatePage.tsx +++ b/src/collections/components/CollectionCreatePage/CollectionCreatePage.tsx @@ -1,6 +1,5 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import AppHeader from "@saleor/components/AppHeader"; import { CardSpacer } from "@saleor/components/CardSpacer"; import CardTitle from "@saleor/components/CardTitle"; @@ -12,6 +11,7 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import SeoForm from "@saleor/components/SeoForm"; import VisibilityCard from "@saleor/components/VisibilityCard"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import useDateLocalize from "@saleor/hooks/useDateLocalize"; import { commonMessages, sectionNames } from "@saleor/intl"; import { ContentState, convertToRaw, RawDraftContentState } from "draft-js"; diff --git a/src/collections/components/CollectionDetails/CollectionDetails.tsx b/src/collections/components/CollectionDetails/CollectionDetails.tsx index 194010216..2de3ae015 100644 --- a/src/collections/components/CollectionDetails/CollectionDetails.tsx +++ b/src/collections/components/CollectionDetails/CollectionDetails.tsx @@ -1,10 +1,10 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import CardTitle from "@saleor/components/CardTitle"; import FormSpacer from "@saleor/components/FormSpacer"; import RichTextEditor from "@saleor/components/RichTextEditor"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { commonMessages } from "@saleor/intl"; import { maybe } from "@saleor/misc"; import { getFormErrors, getProductErrorMessage } from "@saleor/utils/errors"; diff --git a/src/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx b/src/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx index 0f919e913..4bdb628b3 100644 --- a/src/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx +++ b/src/collections/components/CollectionDetailsPage/CollectionDetailsPage.tsx @@ -1,4 +1,3 @@ -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import AppHeader from "@saleor/components/AppHeader"; import { CardSpacer } from "@saleor/components/CardSpacer"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; @@ -12,6 +11,7 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import SeoForm from "@saleor/components/SeoForm"; import VisibilityCard from "@saleor/components/VisibilityCard"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import useDateLocalize from "@saleor/hooks/useDateLocalize"; import { sectionNames } from "@saleor/intl"; import { RawDraftContentState } from "draft-js"; diff --git a/src/collections/mutations.ts b/src/collections/mutations.ts index bc582d939..1ed4fe5c7 100644 --- a/src/collections/mutations.ts +++ b/src/collections/mutations.ts @@ -1,11 +1,14 @@ -import { productErrorFragment } from "@saleor/attributes/mutations"; -import gql from "graphql-tag"; - -import { TypedMutation } from "../mutations"; import { collectionDetailsFragment, collectionProductFragment -} from "./queries"; +} from "@saleor/fragments/collections"; +import { + productErrorFragment, + shopErrorFragment +} from "@saleor/fragments/errors"; +import gql from "graphql-tag"; + +import { TypedMutation } from "../mutations"; import { CollectionAssignProduct, CollectionAssignProductVariables @@ -39,13 +42,6 @@ import { UnassignCollectionProductVariables } from "./types/UnassignCollectionProduct"; -export const ShopErrorFragment = gql` - fragment ShopErrorFragment on ShopError { - code - field - } -`; - const collectionUpdate = gql` ${collectionDetailsFragment} ${productErrorFragment} @@ -68,7 +64,7 @@ export const TypedCollectionUpdateMutation = TypedMutation< const collectionUpdateWithHomepage = gql` ${collectionDetailsFragment} ${productErrorFragment} - ${ShopErrorFragment} + ${shopErrorFragment} mutation CollectionUpdateWithHomepage( $id: ID! $input: CollectionInput! diff --git a/src/collections/queries.ts b/src/collections/queries.ts index cd7107ad3..c14d5b0e3 100644 --- a/src/collections/queries.ts +++ b/src/collections/queries.ts @@ -1,3 +1,8 @@ +import { + collectionDetailsFragment, + collectionFragment, + collectionProductFragment +} from "@saleor/fragments/collections"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; @@ -11,49 +16,6 @@ import { CollectionListVariables } from "./types/CollectionList"; -export const collectionFragment = gql` - fragment CollectionFragment on Collection { - id - isPublished - name - } -`; - -export const collectionDetailsFragment = gql` - ${collectionFragment} - fragment CollectionDetailsFragment on Collection { - ...CollectionFragment - backgroundImage { - alt - url - } - descriptionJson - publicationDate - seoDescription - seoTitle - isPublished - } -`; - -// This fragment is used to make sure that product's fields that are returned -// are always the same - fixes apollo cache -// https://github.com/apollographql/apollo-client/issues/2496 -// https://github.com/apollographql/apollo-client/issues/3468 -export const collectionProductFragment = gql` - fragment CollectionProductFragment on Product { - id - isPublished - name - productType { - id - name - } - thumbnail { - url - } - } -`; - export const collectionList = gql` ${collectionFragment} query CollectionList( diff --git a/src/collections/types/AssignHomepageCollection.ts b/src/collections/types/AssignHomepageCollection.ts deleted file mode 100644 index 48c912009..000000000 --- a/src/collections/types/AssignHomepageCollection.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* tslint:disable */ -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL mutation operation: AssignHomepageCollection -// ==================================================== - -export interface AssignHomepageCollection_homepageCollectionUpdate_errors { - __typename: "Error"; - field: string | null; - message: string | null; -} - -export interface AssignHomepageCollection_homepageCollectionUpdate_shop_homepageCollection { - __typename: "Collection"; - id: string; -} - -export interface AssignHomepageCollection_homepageCollectionUpdate_shop { - __typename: "Shop"; - homepageCollection: AssignHomepageCollection_homepageCollectionUpdate_shop_homepageCollection | null; -} - -export interface AssignHomepageCollection_homepageCollectionUpdate { - __typename: "HomepageCollectionUpdate"; - errors: AssignHomepageCollection_homepageCollectionUpdate_errors[] | null; - shop: AssignHomepageCollection_homepageCollectionUpdate_shop | null; -} - -export interface AssignHomepageCollection { - homepageCollectionUpdate: AssignHomepageCollection_homepageCollectionUpdate | null; -} - -export interface AssignHomepageCollectionVariables { - id?: string | null; -} diff --git a/src/collections/types/SearchProducts.ts b/src/collections/types/SearchProducts.ts deleted file mode 100644 index 495338a8e..000000000 --- a/src/collections/types/SearchProducts.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* tslint:disable */ -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL query operation: SearchProducts -// ==================================================== - -export interface SearchProducts_products_edges_node_productType { - __typename: "ProductType"; - id: string; - name: string; -} - -export interface SearchProducts_products_edges_node_thumbnail { - __typename: "Image"; - url: string; -} - -export interface SearchProducts_products_edges_node { - __typename: "Product"; - id: string; - isPublished: boolean; - name: string; - productType: SearchProducts_products_edges_node_productType; - thumbnail: SearchProducts_products_edges_node_thumbnail | null; -} - -export interface SearchProducts_products_edges { - __typename: "ProductCountableEdge"; - node: SearchProducts_products_edges_node; -} - -export interface SearchProducts_products { - __typename: "ProductCountableConnection"; - edges: SearchProducts_products_edges[]; -} - -export interface SearchProducts { - products: SearchProducts_products | null; -} - -export interface SearchProductsVariables { - query: string; -} diff --git a/src/components/AccountPermissionGroups/AccountPermissionGroups.stories.tsx b/src/components/AccountPermissionGroups/AccountPermissionGroups.stories.tsx index 82285210a..f4228b142 100644 --- a/src/components/AccountPermissionGroups/AccountPermissionGroups.stories.tsx +++ b/src/components/AccountPermissionGroups/AccountPermissionGroups.stories.tsx @@ -1,5 +1,5 @@ +import { StaffErrorFragment } from "@saleor/fragments/types/StaffErrorFragment"; import { SearchPermissionGroups_search_edges_node } from "@saleor/searches/types/SearchPermissionGroups"; -import { StaffErrorFragment } from "@saleor/staff/types/StaffErrorFragment"; import Decorator from "@saleor/storybook/Decorator"; import { AccountErrorCode } from "@saleor/types/globalTypes"; import { storiesOf } from "@storybook/react"; diff --git a/src/components/AccountPermissionGroups/AccountPermissionGroups.tsx b/src/components/AccountPermissionGroups/AccountPermissionGroups.tsx index 3c294de5e..c3aa9c813 100644 --- a/src/components/AccountPermissionGroups/AccountPermissionGroups.tsx +++ b/src/components/AccountPermissionGroups/AccountPermissionGroups.tsx @@ -1,7 +1,7 @@ import Typography from "@material-ui/core/Typography"; +import { StaffErrorFragment } from "@saleor/fragments/types/StaffErrorFragment"; import { FormChange } from "@saleor/hooks/useForm"; import { SearchPermissionGroups_search_edges_node } from "@saleor/searches/types/SearchPermissionGroups"; -import { StaffErrorFragment } from "@saleor/staff/types/StaffErrorFragment"; import { FetchMoreProps, SearchPageProps } from "@saleor/types"; import { getFormErrors } from "@saleor/utils/errors"; import getStaffErrorMessage from "@saleor/utils/errors/staff"; diff --git a/src/components/AccountPermissions/utils.ts b/src/components/AccountPermissions/utils.ts index 10f2f5a57..4a790da52 100644 --- a/src/components/AccountPermissions/utils.ts +++ b/src/components/AccountPermissions/utils.ts @@ -1,5 +1,5 @@ -import { User_userPermissions } from "@saleor/auth/types/User"; import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo"; +import { User_userPermissions } from "@saleor/fragments/types/User"; import { PermissionGroupDetails_user_userPermissions } from "@saleor/permissionGroups/types/PermissionGroupDetails"; export const getLastSourcesOfPermission = ( diff --git a/src/components/AddressEdit/AddressEdit.tsx b/src/components/AddressEdit/AddressEdit.tsx index 0b8201d45..136f5dfef 100644 --- a/src/components/AddressEdit/AddressEdit.tsx +++ b/src/components/AddressEdit/AddressEdit.tsx @@ -1,9 +1,9 @@ import { makeStyles } from "@material-ui/core/styles"; import TextField from "@material-ui/core/TextField"; import { AddressTypeInput } from "@saleor/customers/types"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getAccountErrorMessage from "@saleor/utils/errors/account"; import getOrderErrorMessage from "@saleor/utils/errors/order"; diff --git a/src/components/AppLayout/MenuList.tsx b/src/components/AppLayout/MenuList.tsx index 3fd970828..b445fee67 100644 --- a/src/components/AppLayout/MenuList.tsx +++ b/src/components/AppLayout/MenuList.tsx @@ -1,6 +1,7 @@ import configureIcon from "@assets/images/menu-configure-icon.svg"; import { makeStyles } from "@material-ui/core/styles"; import Typography from "@material-ui/core/Typography"; +import { User } from "@saleor/fragments/types/User"; import useTheme from "@saleor/hooks/useTheme"; import { sectionNames } from "@saleor/intl"; import classNames from "classnames"; @@ -9,7 +10,6 @@ import SVG from "react-inlinesvg"; import { FormattedMessage, useIntl } from "react-intl"; import { matchPath } from "react-router"; -import { User } from "../../auth/types/User"; import { configurationMenuUrl, createConfigurationMenu diff --git a/src/components/CompanyAddressInput/CompanyAddressForm.tsx b/src/components/CompanyAddressInput/CompanyAddressForm.tsx index d5252a310..e43752424 100644 --- a/src/components/CompanyAddressInput/CompanyAddressForm.tsx +++ b/src/components/CompanyAddressInput/CompanyAddressForm.tsx @@ -6,14 +6,14 @@ import SingleAutocompleteSelectField, { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; import { AddressTypeInput } from "@saleor/customers/types"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; +import { ShopErrorFragment } from "@saleor/fragments/types/ShopErrorFragment"; +import { WarehouseErrorFragment } from "@saleor/fragments/types/WarehouseErrorFragment"; import { ChangeEvent } from "@saleor/hooks/useForm"; -import { ShopErrorFragment } from "@saleor/siteSettings/types/ShopErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getAccountErrorMessage from "@saleor/utils/errors/account"; import getShopErrorMessage from "@saleor/utils/errors/shop"; import getWarehouseErrorMessage from "@saleor/utils/errors/warehouse"; -import { WarehouseErrorFragment } from "@saleor/warehouses/types/WarehouseErrorFragment"; import React from "react"; import { IntlShape, useIntl } from "react-intl"; diff --git a/src/components/CountryList/CountryList.tsx b/src/components/CountryList/CountryList.tsx index 57d39b9d0..b217dbe7f 100644 --- a/src/components/CountryList/CountryList.tsx +++ b/src/components/CountryList/CountryList.tsx @@ -11,12 +11,12 @@ import DeleteIcon from "@material-ui/icons/Delete"; import CardTitle from "@saleor/components/CardTitle"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; +import { CountryFragment } from "@saleor/fragments/types/CountryFragment"; import classNames from "classnames"; import React from "react"; import { FormattedMessage } from "react-intl"; import { getStringOrPlaceholder, maybe, renderCollection } from "../../misc"; -import { CountryFragment } from "../../taxes/types/CountryFragment"; export interface CountryListProps { countries: CountryFragment[]; diff --git a/src/components/RequirePermissions.tsx b/src/components/RequirePermissions.tsx index 13a11bc61..a5f413fdc 100644 --- a/src/components/RequirePermissions.tsx +++ b/src/components/RequirePermissions.tsx @@ -1,4 +1,4 @@ -import { User_userPermissions } from "@saleor/auth/types/User"; +import { User_userPermissions } from "@saleor/fragments/types/User"; import { PermissionEnum } from "@saleor/types/globalTypes"; import React from "react"; diff --git a/src/configuration/ConfigurationPage.tsx b/src/configuration/ConfigurationPage.tsx index cbf57c4a4..9e2f1566a 100644 --- a/src/configuration/ConfigurationPage.tsx +++ b/src/configuration/ConfigurationPage.tsx @@ -3,12 +3,12 @@ import CardContent from "@material-ui/core/CardContent"; import { IconProps } from "@material-ui/core/Icon"; import { makeStyles } from "@material-ui/core/styles"; import Typography from "@material-ui/core/Typography"; +import { User } from "@saleor/fragments/types/User"; import { sectionNames } from "@saleor/intl"; import React from "react"; import { useIntl } from "react-intl"; import { hasPermission } from "../auth/misc"; -import { User } from "../auth/types/User"; import Container from "../components/Container"; import PageHeader from "../components/PageHeader"; import { PermissionEnum } from "../types/globalTypes"; diff --git a/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx b/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx index b20ecc1c1..f60e53dfd 100644 --- a/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx +++ b/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx @@ -9,7 +9,7 @@ import ConfirmButton, { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import useAddressValidation from "@saleor/hooks/useAddressValidation"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; diff --git a/src/customers/components/CustomerCreateAddress/CustomerCreateAddress.tsx b/src/customers/components/CustomerCreateAddress/CustomerCreateAddress.tsx index 3d38cc6f7..710aa1d2c 100644 --- a/src/customers/components/CustomerCreateAddress/CustomerCreateAddress.tsx +++ b/src/customers/components/CustomerCreateAddress/CustomerCreateAddress.tsx @@ -6,7 +6,7 @@ import AddressEdit from "@saleor/components/AddressEdit"; import CardTitle from "@saleor/components/CardTitle"; import { FormSpacer } from "@saleor/components/FormSpacer"; import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx b/src/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx index 586721a70..06fd2da43 100644 --- a/src/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx +++ b/src/customers/components/CustomerCreateDetails/CustomerCreateDetails.tsx @@ -3,7 +3,7 @@ import CardContent from "@material-ui/core/CardContent"; import { makeStyles } from "@material-ui/core/styles"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import { commonMessages } from "@saleor/intl"; import { getFormErrors } from "@saleor/utils/errors"; import getAccountErrorMessage from "@saleor/utils/errors/account"; diff --git a/src/customers/components/CustomerCreateNote/CustomerCreateNote.tsx b/src/customers/components/CustomerCreateNote/CustomerCreateNote.tsx index 780786c00..b04b0496c 100644 --- a/src/customers/components/CustomerCreateNote/CustomerCreateNote.tsx +++ b/src/customers/components/CustomerCreateNote/CustomerCreateNote.tsx @@ -4,7 +4,7 @@ import TextField from "@material-ui/core/TextField"; import Typography from "@material-ui/core/Typography"; import CardTitle from "@saleor/components/CardTitle"; import { FormSpacer } from "@saleor/components/FormSpacer"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getAccountErrorMessage from "@saleor/utils/errors/account"; import React from "react"; diff --git a/src/customers/components/CustomerCreatePage/CustomerCreatePage.tsx b/src/customers/components/CustomerCreatePage/CustomerCreatePage.tsx index a31fcd973..554e96456 100644 --- a/src/customers/components/CustomerCreatePage/CustomerCreatePage.tsx +++ b/src/customers/components/CustomerCreatePage/CustomerCreatePage.tsx @@ -6,7 +6,7 @@ import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import useAddressValidation from "@saleor/hooks/useAddressValidation"; import { sectionNames } from "@saleor/intl"; import { AddressInput } from "@saleor/types/globalTypes"; diff --git a/src/customers/components/CustomerDetails/CustomerDetails.tsx b/src/customers/components/CustomerDetails/CustomerDetails.tsx index 32848b90e..b916c6c19 100644 --- a/src/customers/components/CustomerDetails/CustomerDetails.tsx +++ b/src/customers/components/CustomerDetails/CustomerDetails.tsx @@ -6,7 +6,7 @@ import Typography from "@material-ui/core/Typography"; import CardTitle from "@saleor/components/CardTitle"; import { ControlledCheckbox } from "@saleor/components/ControlledCheckbox"; import Skeleton from "@saleor/components/Skeleton"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import { maybe } from "@saleor/misc"; import { getFormErrors } from "@saleor/utils/errors"; import getAccountErrorMessage from "@saleor/utils/errors/account"; diff --git a/src/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx b/src/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx index c76f78c6a..44081fc76 100644 --- a/src/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx +++ b/src/customers/components/CustomerDetailsPage/CustomerDetailsPage.tsx @@ -6,7 +6,7 @@ import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import { sectionNames } from "@saleor/intl"; import React from "react"; import { useIntl } from "react-intl"; diff --git a/src/customers/components/CustomerInfo/CustomerInfo.tsx b/src/customers/components/CustomerInfo/CustomerInfo.tsx index 44044e58e..c722f49d1 100644 --- a/src/customers/components/CustomerInfo/CustomerInfo.tsx +++ b/src/customers/components/CustomerInfo/CustomerInfo.tsx @@ -6,7 +6,7 @@ import Typography from "@material-ui/core/Typography"; import CardTitle from "@saleor/components/CardTitle"; import Grid from "@saleor/components/Grid"; import Hr from "@saleor/components/Hr"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import { commonMessages } from "@saleor/intl"; import { getFormErrors } from "@saleor/utils/errors"; import getAccountErrorMessage from "@saleor/utils/errors/account"; diff --git a/src/customers/mutations.ts b/src/customers/mutations.ts index 30729d183..4625a3c4d 100644 --- a/src/customers/mutations.ts +++ b/src/customers/mutations.ts @@ -1,8 +1,12 @@ +import { fragmentAddress } from "@saleor/fragments/address"; +import { + customerAddressesFragment, + customerDetailsFragment +} from "@saleor/fragments/customers"; +import { accountErrorFragment } from "@saleor/fragments/errors"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { fragmentAddress } from "../orders/queries"; -import { customerAddressesFragment, customerDetailsFragment } from "./queries"; import { BulkRemoveCustomers, BulkRemoveCustomersVariables @@ -36,13 +40,6 @@ import { UpdateCustomerAddressVariables } from "./types/UpdateCustomerAddress"; -export const accountErrorFragment = gql` - fragment AccountErrorFragment on AccountError { - code - field - } -`; - const updateCustomer = gql` ${accountErrorFragment} ${customerDetailsFragment} diff --git a/src/customers/queries.ts b/src/customers/queries.ts index 461543b21..3bc3058fa 100644 --- a/src/customers/queries.ts +++ b/src/customers/queries.ts @@ -1,7 +1,11 @@ +import { + customerAddressesFragment, + customerDetailsFragment, + customerFragment +} from "@saleor/fragments/customers"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; -import { fragmentAddress } from "../orders/queries"; import { TypedQuery } from "../queries"; import { CustomerAddresses, @@ -14,50 +18,6 @@ import { } from "./types/CustomerDetails"; import { ListCustomers, ListCustomersVariables } from "./types/ListCustomers"; -export const customerFragment = gql` - fragment CustomerFragment on User { - id - email - firstName - lastName - } -`; - -export const customerDetailsFragment = gql` - ${customerFragment} - ${fragmentAddress} - fragment CustomerDetailsFragment on User { - ...CustomerFragment - dateJoined - lastLogin - defaultShippingAddress { - ...AddressFragment - } - defaultBillingAddress { - ...AddressFragment - } - note - isActive - } -`; - -export const customerAddressesFragment = gql` - ${customerFragment} - ${fragmentAddress} - fragment CustomerAddressesFragment on User { - ...CustomerFragment - addresses { - ...AddressFragment - } - defaultBillingAddress { - id - } - defaultShippingAddress { - id - } - } -`; - const customerList = gql` ${customerFragment} query ListCustomers( diff --git a/src/discounts/components/DiscountDates/DiscountDates.tsx b/src/discounts/components/DiscountDates/DiscountDates.tsx index 8a62a36ac..be0368439 100644 --- a/src/discounts/components/DiscountDates/DiscountDates.tsx +++ b/src/discounts/components/DiscountDates/DiscountDates.tsx @@ -4,7 +4,7 @@ import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; import { ControlledCheckbox } from "@saleor/components/ControlledCheckbox"; import Grid from "@saleor/components/Grid"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { commonMessages } from "@saleor/intl"; import { getFormErrors } from "@saleor/utils/errors"; import getDiscountErrorMessage from "@saleor/utils/errors/discounts"; diff --git a/src/discounts/components/SaleCreatePage/SaleCreatePage.tsx b/src/discounts/components/SaleCreatePage/SaleCreatePage.tsx index bdbecea77..42a005283 100644 --- a/src/discounts/components/SaleCreatePage/SaleCreatePage.tsx +++ b/src/discounts/components/SaleCreatePage/SaleCreatePage.tsx @@ -6,7 +6,7 @@ import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { sectionNames } from "@saleor/intl"; import React from "react"; import { useIntl } from "react-intl"; diff --git a/src/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx b/src/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx index 32d70c990..46df77189 100644 --- a/src/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx +++ b/src/discounts/components/SaleDetailsPage/SaleDetailsPage.tsx @@ -7,7 +7,7 @@ import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { Tab, TabContainer } from "@saleor/components/Tab"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { sectionNames } from "@saleor/intl"; import React from "react"; import { useIntl } from "react-intl"; diff --git a/src/discounts/components/SaleInfo/SaleInfo.tsx b/src/discounts/components/SaleInfo/SaleInfo.tsx index d56914c27..94a1baa1e 100644 --- a/src/discounts/components/SaleInfo/SaleInfo.tsx +++ b/src/discounts/components/SaleInfo/SaleInfo.tsx @@ -2,7 +2,7 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { commonMessages } from "@saleor/intl"; import { getFormErrors } from "@saleor/utils/errors"; import getDiscountErrorMessage from "@saleor/utils/errors/discounts"; diff --git a/src/discounts/components/SaleValue/SaleValue.tsx b/src/discounts/components/SaleValue/SaleValue.tsx index 9a30298c1..34312ac2c 100644 --- a/src/discounts/components/SaleValue/SaleValue.tsx +++ b/src/discounts/components/SaleValue/SaleValue.tsx @@ -2,7 +2,7 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { FormChange } from "@saleor/hooks/useForm"; import { SaleType } from "@saleor/types/globalTypes"; import { getFormErrors } from "@saleor/utils/errors"; diff --git a/src/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx b/src/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx index 2cbd55592..65899494e 100644 --- a/src/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx +++ b/src/discounts/components/VoucherCreatePage/VoucherCreatePage.tsx @@ -6,7 +6,7 @@ import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { sectionNames } from "@saleor/intl"; import React from "react"; import { useIntl } from "react-intl"; diff --git a/src/discounts/components/VoucherDates/VoucherDates.tsx b/src/discounts/components/VoucherDates/VoucherDates.tsx index 2ae93259a..be804c2e6 100644 --- a/src/discounts/components/VoucherDates/VoucherDates.tsx +++ b/src/discounts/components/VoucherDates/VoucherDates.tsx @@ -4,7 +4,7 @@ import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; import { ControlledCheckbox } from "@saleor/components/ControlledCheckbox"; import Grid from "@saleor/components/Grid"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { commonMessages } from "@saleor/intl"; import { getFormErrors } from "@saleor/utils/errors"; import getDiscountErrorMessage from "@saleor/utils/errors/discounts"; diff --git a/src/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx b/src/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx index e6f60c36f..db418d3e6 100644 --- a/src/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx +++ b/src/discounts/components/VoucherDetailsPage/VoucherDetailsPage.tsx @@ -10,7 +10,7 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { Tab, TabContainer } from "@saleor/components/Tab"; import { RequirementsPicker } from "@saleor/discounts/types"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { sectionNames } from "@saleor/intl"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/discounts/components/VoucherInfo/VoucherInfo.tsx b/src/discounts/components/VoucherInfo/VoucherInfo.tsx index 03eb4c89d..3b227980f 100644 --- a/src/discounts/components/VoucherInfo/VoucherInfo.tsx +++ b/src/discounts/components/VoucherInfo/VoucherInfo.tsx @@ -3,7 +3,7 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { commonMessages } from "@saleor/intl"; import { getFormErrors } from "@saleor/utils/errors"; import getDiscountErrorMessage from "@saleor/utils/errors/discounts"; diff --git a/src/discounts/components/VoucherLimits/VoucherLimits.tsx b/src/discounts/components/VoucherLimits/VoucherLimits.tsx index d3583f7b5..30a377641 100644 --- a/src/discounts/components/VoucherLimits/VoucherLimits.tsx +++ b/src/discounts/components/VoucherLimits/VoucherLimits.tsx @@ -3,7 +3,7 @@ import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; import { ControlledCheckbox } from "@saleor/components/ControlledCheckbox"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getDiscountErrorMessage from "@saleor/utils/errors/discounts"; import React from "react"; diff --git a/src/discounts/components/VoucherRequirements/VoucherRequirements.tsx b/src/discounts/components/VoucherRequirements/VoucherRequirements.tsx index 8a152bf17..da7d8e563 100644 --- a/src/discounts/components/VoucherRequirements/VoucherRequirements.tsx +++ b/src/discounts/components/VoucherRequirements/VoucherRequirements.tsx @@ -5,7 +5,7 @@ import CardTitle from "@saleor/components/CardTitle"; import { FormSpacer } from "@saleor/components/FormSpacer"; import RadioGroupField from "@saleor/components/RadioGroupField"; import { RequirementsPicker } from "@saleor/discounts/types"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getDiscountErrorMessage from "@saleor/utils/errors/discounts"; import React from "react"; diff --git a/src/discounts/components/VoucherTypes/VoucherTypes.tsx b/src/discounts/components/VoucherTypes/VoucherTypes.tsx index bb181c15f..f64e9b4a8 100644 --- a/src/discounts/components/VoucherTypes/VoucherTypes.tsx +++ b/src/discounts/components/VoucherTypes/VoucherTypes.tsx @@ -3,7 +3,7 @@ import CardContent from "@material-ui/core/CardContent"; import CardTitle from "@saleor/components/CardTitle"; import Grid from "@saleor/components/Grid"; import RadioGroupField from "@saleor/components/RadioGroupField"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getDiscountErrorMessage from "@saleor/utils/errors/discounts"; import React from "react"; diff --git a/src/discounts/components/VoucherValue/VoucherValue.tsx b/src/discounts/components/VoucherValue/VoucherValue.tsx index 680b2b228..6c3e1ecf8 100644 --- a/src/discounts/components/VoucherValue/VoucherValue.tsx +++ b/src/discounts/components/VoucherValue/VoucherValue.tsx @@ -8,7 +8,7 @@ import { FormSpacer } from "@saleor/components/FormSpacer"; import Hr from "@saleor/components/Hr"; import RadioGroupField from "@saleor/components/RadioGroupField"; import TextFieldWithChoice from "@saleor/components/TextFieldWithChoice"; -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getDiscountErrorMessage from "@saleor/utils/errors/discounts"; import React from "react"; diff --git a/src/discounts/mutations.ts b/src/discounts/mutations.ts index aa5007519..d9cadff5d 100644 --- a/src/discounts/mutations.ts +++ b/src/discounts/mutations.ts @@ -1,12 +1,13 @@ -import gql from "graphql-tag"; - -import { TypedMutation } from "../mutations"; import { saleDetailsFragment, saleFragment, voucherDetailsFragment, voucherFragment -} from "./queries"; +} from "@saleor/fragments/discounts"; +import { discountErrorFragment } from "@saleor/fragments/errors"; +import gql from "graphql-tag"; + +import { TypedMutation } from "../mutations"; import { SaleBulkDelete, SaleBulkDeleteVariables @@ -38,13 +39,6 @@ import { VoucherCreate, VoucherCreateVariables } from "./types/VoucherCreate"; import { VoucherDelete, VoucherDeleteVariables } from "./types/VoucherDelete"; import { VoucherUpdate, VoucherUpdateVariables } from "./types/VoucherUpdate"; -const discountErrorFragment = gql` - fragment DiscountErrorFragment on DiscountError { - code - field - } -`; - const saleUpdate = gql` ${discountErrorFragment} ${saleFragment} diff --git a/src/discounts/queries.ts b/src/discounts/queries.ts index 0a45954c6..683154ac4 100644 --- a/src/discounts/queries.ts +++ b/src/discounts/queries.ts @@ -1,7 +1,14 @@ +import { + saleDetailsFragment, + saleFragment, + voucherDetailsFragment, + voucherFragment +} from "@saleor/fragments/discounts"; +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; -import { pageInfoFragment, TypedQuery } from "../queries"; +import { TypedQuery } from "../queries"; import { SaleDetails, SaleDetailsVariables } from "./types/SaleDetails"; import { SaleList, SaleListVariables } from "./types/SaleList"; import { @@ -10,160 +17,6 @@ import { } from "./types/VoucherDetails"; import { VoucherList, VoucherListVariables } from "./types/VoucherList"; -export const saleFragment = gql` - fragment SaleFragment on Sale { - id - name - type - startDate - endDate - value - } -`; - -export const saleDetailsFragment = gql` - ${pageInfoFragment} - ${saleFragment} - fragment SaleDetailsFragment on Sale { - ...SaleFragment - products(after: $after, before: $before, first: $first, last: $last) { - edges { - node { - id - name - isPublished - productType { - id - name - } - thumbnail { - url - } - } - } - pageInfo { - ...PageInfoFragment - } - totalCount - } - categories(after: $after, before: $before, first: $first, last: $last) { - edges { - node { - id - name - products { - totalCount - } - } - } - pageInfo { - ...PageInfoFragment - } - totalCount - } - collections(after: $after, before: $before, first: $first, last: $last) { - edges { - node { - id - name - products { - totalCount - } - } - } - pageInfo { - ...PageInfoFragment - } - totalCount - } - } -`; - -export const voucherFragment = gql` - fragment VoucherFragment on Voucher { - id - code - startDate - endDate - usageLimit - discountValueType - discountValue - countries { - code - country - } - minSpent { - currency - amount - } - minCheckoutItemsQuantity - } -`; - -export const voucherDetailsFragment = gql` - ${pageInfoFragment} - ${voucherFragment} - fragment VoucherDetailsFragment on Voucher { - ...VoucherFragment - type - code - usageLimit - used - applyOncePerOrder - applyOncePerCustomer - products(after: $after, before: $before, first: $first, last: $last) { - edges { - node { - id - name - productType { - id - name - } - isPublished - thumbnail { - url - } - } - } - totalCount - pageInfo { - ...PageInfoFragment - } - } - collections(after: $after, before: $before, first: $first, last: $last) { - edges { - node { - id - name - products { - totalCount - } - } - } - totalCount - pageInfo { - ...PageInfoFragment - } - } - categories(after: $after, before: $before, first: $first, last: $last) { - edges { - node { - id - name - products { - totalCount - } - } - } - totalCount - pageInfo { - ...PageInfoFragment - } - } - } -`; - export const saleList = gql` ${pageInfoFragment} ${saleFragment} diff --git a/src/fixtures.ts b/src/fixtures.ts index 5d3b050b3..9b42321fe 100644 --- a/src/fixtures.ts +++ b/src/fixtures.ts @@ -1,5 +1,5 @@ -import { User_userPermissions } from "./auth/types/User"; import { ShopInfo_shop_permissions } from "./components/Shop/types/ShopInfo"; +import { User_userPermissions } from "./fragments/types/User"; import { FetchMoreProps, FilterPageProps, diff --git a/src/fragments/address.ts b/src/fragments/address.ts new file mode 100644 index 000000000..33126134c --- /dev/null +++ b/src/fragments/address.ts @@ -0,0 +1,22 @@ +import gql from "graphql-tag"; + +export const fragmentAddress = gql` + fragment AddressFragment on Address { + city + cityArea + companyName + country { + __typename + code + country + } + countryArea + firstName + id + lastName + phone + postalCode + streetAddress1 + streetAddress2 + } +`; diff --git a/src/fragments/attributes.ts b/src/fragments/attributes.ts new file mode 100644 index 000000000..1cbc7172a --- /dev/null +++ b/src/fragments/attributes.ts @@ -0,0 +1,29 @@ +import gql from "graphql-tag"; + +export const attributeFragment = gql` + fragment AttributeFragment on Attribute { + id + name + slug + visibleInStorefront + filterableInDashboard + filterableInStorefront + } +`; + +export const attributeDetailsFragment = gql` + ${attributeFragment} + fragment AttributeDetailsFragment on Attribute { + ...AttributeFragment + availableInGrid + inputType + storefrontSearchPosition + valueRequired + values { + id + name + slug + type + } + } +`; diff --git a/src/fragments/auth.ts b/src/fragments/auth.ts new file mode 100644 index 000000000..2a897a523 --- /dev/null +++ b/src/fragments/auth.ts @@ -0,0 +1,17 @@ +import gql from "graphql-tag"; + +export const fragmentUser = gql` + fragment User on User { + id + email + firstName + lastName + userPermissions { + code + name + } + avatar { + url + } + } +`; diff --git a/src/fragments/categories.ts b/src/fragments/categories.ts new file mode 100644 index 000000000..9953b0168 --- /dev/null +++ b/src/fragments/categories.ts @@ -0,0 +1,30 @@ +import gql from "graphql-tag"; + +export const categoryFragment = gql` + fragment CategoryFragment on Category { + id + name + children { + totalCount + } + products { + totalCount + } + } +`; +export const categoryDetailsFragment = gql` + fragment CategoryDetailsFragment on Category { + id + backgroundImage { + alt + url + } + name + descriptionJson + seoDescription + seoTitle + parent { + id + } + } +`; diff --git a/src/fragments/collections.ts b/src/fragments/collections.ts new file mode 100644 index 000000000..910f39084 --- /dev/null +++ b/src/fragments/collections.ts @@ -0,0 +1,44 @@ +import gql from "graphql-tag"; + +export const collectionFragment = gql` + fragment CollectionFragment on Collection { + id + isPublished + name + } +`; + +export const collectionDetailsFragment = gql` + ${collectionFragment} + fragment CollectionDetailsFragment on Collection { + ...CollectionFragment + backgroundImage { + alt + url + } + descriptionJson + publicationDate + seoDescription + seoTitle + isPublished + } +`; + +// This fragment is used to make sure that product's fields that are returned +// are always the same - fixes apollo cache +// https://github.com/apollographql/apollo-client/issues/2496 +// https://github.com/apollographql/apollo-client/issues/3468 +export const collectionProductFragment = gql` + fragment CollectionProductFragment on Product { + id + isPublished + name + productType { + id + name + } + thumbnail { + url + } + } +`; diff --git a/src/fragments/customers.ts b/src/fragments/customers.ts new file mode 100644 index 000000000..2e4753345 --- /dev/null +++ b/src/fragments/customers.ts @@ -0,0 +1,47 @@ +import gql from "graphql-tag"; + +import { fragmentAddress } from "./address"; + +export const customerFragment = gql` + fragment CustomerFragment on User { + id + email + firstName + lastName + } +`; + +export const customerDetailsFragment = gql` + ${customerFragment} + ${fragmentAddress} + fragment CustomerDetailsFragment on User { + ...CustomerFragment + dateJoined + lastLogin + defaultShippingAddress { + ...AddressFragment + } + defaultBillingAddress { + ...AddressFragment + } + note + isActive + } +`; + +export const customerAddressesFragment = gql` + ${customerFragment} + ${fragmentAddress} + fragment CustomerAddressesFragment on User { + ...CustomerFragment + addresses { + ...AddressFragment + } + defaultBillingAddress { + id + } + defaultShippingAddress { + id + } + } +`; diff --git a/src/fragments/discounts.ts b/src/fragments/discounts.ts new file mode 100644 index 000000000..2e99da371 --- /dev/null +++ b/src/fragments/discounts.ts @@ -0,0 +1,157 @@ +import gql from "graphql-tag"; + +import { pageInfoFragment } from "./pageInfo"; + +export const saleFragment = gql` + fragment SaleFragment on Sale { + id + name + type + startDate + endDate + value + } +`; + +export const saleDetailsFragment = gql` + ${pageInfoFragment} + ${saleFragment} + fragment SaleDetailsFragment on Sale { + ...SaleFragment + products(after: $after, before: $before, first: $first, last: $last) { + edges { + node { + id + name + isPublished + productType { + id + name + } + thumbnail { + url + } + } + } + pageInfo { + ...PageInfoFragment + } + totalCount + } + categories(after: $after, before: $before, first: $first, last: $last) { + edges { + node { + id + name + products { + totalCount + } + } + } + pageInfo { + ...PageInfoFragment + } + totalCount + } + collections(after: $after, before: $before, first: $first, last: $last) { + edges { + node { + id + name + products { + totalCount + } + } + } + pageInfo { + ...PageInfoFragment + } + totalCount + } + } +`; + +export const voucherFragment = gql` + fragment VoucherFragment on Voucher { + id + code + startDate + endDate + usageLimit + discountValueType + discountValue + countries { + code + country + } + minSpent { + currency + amount + } + minCheckoutItemsQuantity + } +`; + +export const voucherDetailsFragment = gql` + ${pageInfoFragment} + ${voucherFragment} + fragment VoucherDetailsFragment on Voucher { + ...VoucherFragment + type + code + usageLimit + used + applyOncePerOrder + applyOncePerCustomer + products(after: $after, before: $before, first: $first, last: $last) { + edges { + node { + id + name + productType { + id + name + } + isPublished + thumbnail { + url + } + } + } + totalCount + pageInfo { + ...PageInfoFragment + } + } + collections(after: $after, before: $before, first: $first, last: $last) { + edges { + node { + id + name + products { + totalCount + } + } + } + totalCount + pageInfo { + ...PageInfoFragment + } + } + categories(after: $after, before: $before, first: $first, last: $last) { + edges { + node { + id + name + products { + totalCount + } + } + } + totalCount + pageInfo { + ...PageInfoFragment + } + } + } +`; diff --git a/src/fragments/errors.ts b/src/fragments/errors.ts new file mode 100644 index 000000000..a45f97292 --- /dev/null +++ b/src/fragments/errors.ts @@ -0,0 +1,106 @@ +import gql from "graphql-tag"; + +export const productErrorFragment = gql` + fragment ProductErrorFragment on ProductError { + code + field + } +`; + +export const accountErrorFragment = gql` + fragment AccountErrorFragment on AccountError { + code + field + } +`; + +export const discountErrorFragment = gql` + fragment DiscountErrorFragment on DiscountError { + code + field + } +`; + +export const menuErrorFragment = gql` + fragment MenuErrorFragment on MenuError { + code + field + } +`; + +export const orderErrorFragment = gql` + fragment OrderErrorFragment on OrderError { + code + field + } +`; + +export const pageErrorFragment = gql` + fragment PageErrorFragment on PageError { + code + field + } +`; + +export const permissionGroupErrorFragment = gql` + fragment PermissionGroupErrorFragment on PermissionGroupError { + code + field + } +`; + +export const bulkProductErrorFragment = gql` + fragment BulkProductErrorFragment on BulkProductError { + field + code + index + } +`; +export const bulkStockErrorFragment = gql` + fragment BulkStockErrorFragment on BulkStockError { + code + field + index + } +`; +export const stockErrorFragment = gql` + fragment StockErrorFragment on StockError { + code + field + } +`; + +export const shippingErrorFragment = gql` + fragment ShippingErrorFragment on ShippingError { + code + field + } +`; + +export const shopErrorFragment = gql` + fragment ShopErrorFragment on ShopError { + code + field + } +`; + +export const staffErrorFragment = gql` + fragment StaffErrorFragment on StaffError { + code + field + } +`; + +export const warehouseErrorFragment = gql` + fragment WarehouseErrorFragment on WarehouseError { + code + field + } +`; + +export const webhookErrorFragment = gql` + fragment WebhookErrorFragment on WebhookError { + code + field + } +`; diff --git a/src/fragments/navigation.ts b/src/fragments/navigation.ts new file mode 100644 index 000000000..899a523cc --- /dev/null +++ b/src/fragments/navigation.ts @@ -0,0 +1,69 @@ +import gql from "graphql-tag"; + +export const menuFragment = gql` + fragment MenuFragment on Menu { + id + name + items { + id + } + } +`; + +export const menuItemFragment = gql` + fragment MenuItemFragment on MenuItem { + category { + id + name + } + collection { + id + name + } + id + level + name + page { + id + title + } + url + } +`; + +// GraphQL does not support recurive fragments +export const menuItemNestedFragment = gql` + ${menuItemFragment} + fragment MenuItemNestedFragment on MenuItem { + ...MenuItemFragment + children { + ...MenuItemFragment + children { + ...MenuItemFragment + children { + ...MenuItemFragment + children { + ...MenuItemFragment + children { + ...MenuItemFragment + children { + ...MenuItemFragment + } + } + } + } + } + } + } +`; + +export const menuDetailsFragment = gql` + ${menuItemNestedFragment} + fragment MenuDetailsFragment on Menu { + id + items { + ...MenuItemNestedFragment + } + name + } +`; diff --git a/src/fragments/orders.ts b/src/fragments/orders.ts new file mode 100644 index 000000000..a16092550 --- /dev/null +++ b/src/fragments/orders.ts @@ -0,0 +1,147 @@ +import gql from "graphql-tag"; + +import { fragmentAddress } from "./address"; + +export const fragmentOrderEvent = gql` + fragment OrderEventFragment on OrderEvent { + id + amount + date + email + emailType + message + quantity + type + user { + id + email + } + } +`; + +export const fragmentOrderLine = gql` + fragment OrderLineFragment on OrderLine { + id + isShippingRequired + productName + productSku + quantity + quantityFulfilled + unitPrice { + gross { + amount + currency + } + net { + amount + currency + } + } + thumbnail { + url + } + } +`; +export const fulfillmentFragment = gql` + ${fragmentOrderLine} + fragment FulfillmentFragment on Fulfillment { + id + lines { + id + quantity + orderLine { + ...OrderLineFragment + } + } + fulfillmentOrder + status + trackingNumber + warehouse { + id + name + } + } +`; + +export const fragmentOrderDetails = gql` + ${fragmentAddress} + ${fragmentOrderEvent} + ${fragmentOrderLine} + ${fulfillmentFragment} + fragment OrderDetailsFragment on Order { + id + billingAddress { + ...AddressFragment + } + canFinalize + created + customerNote + events { + ...OrderEventFragment + } + fulfillments { + ...FulfillmentFragment + } + lines { + ...OrderLineFragment + } + number + paymentStatus + shippingAddress { + ...AddressFragment + } + shippingMethod { + id + } + shippingMethodName + shippingPrice { + gross { + amount + currency + } + } + status + subtotal { + gross { + amount + currency + } + } + total { + gross { + amount + currency + } + tax { + amount + currency + } + } + actions + totalAuthorized { + amount + currency + } + totalCaptured { + amount + currency + } + user { + id + email + } + userEmail + availableShippingMethods { + id + name + price { + amount + currency + } + } + discount { + amount + currency + } + } +`; diff --git a/src/fragments/pageInfo.ts b/src/fragments/pageInfo.ts new file mode 100644 index 000000000..413c5ff25 --- /dev/null +++ b/src/fragments/pageInfo.ts @@ -0,0 +1,10 @@ +import gql from "graphql-tag"; + +export const pageInfoFragment = gql` + fragment PageInfoFragment on PageInfo { + endCursor + hasNextPage + hasPreviousPage + startCursor + } +`; diff --git a/src/fragments/pages.ts b/src/fragments/pages.ts new file mode 100644 index 000000000..ea2e13d60 --- /dev/null +++ b/src/fragments/pages.ts @@ -0,0 +1,21 @@ +import gql from "graphql-tag"; + +export const pageFragment = gql` + fragment PageFragment on Page { + id + title + slug + isPublished + } +`; + +export const pageDetailsFragment = gql` + ${pageFragment} + fragment PageDetailsFragment on Page { + ...PageFragment + contentJson + seoTitle + seoDescription + publicationDate + } +`; diff --git a/src/fragments/permissionGroups.ts b/src/fragments/permissionGroups.ts new file mode 100644 index 000000000..d16a0afbe --- /dev/null +++ b/src/fragments/permissionGroups.ts @@ -0,0 +1,38 @@ +import gql from "graphql-tag"; + +import { staffMemberFragment } from "./staff"; + +export const permissionGroupFragment = gql` + fragment PermissionGroupFragment on Group { + id + name + userCanManage + users { + id + firstName + lastName + } + } +`; + +export const permissionFragment = gql` + fragment PermissionFragment on Permission { + code + name + } +`; + +export const permissionGroupDetailsFragment = gql` + ${permissionGroupFragment} + ${permissionFragment} + ${staffMemberFragment} + fragment PermissionGroupDetailsFragment on Group { + ...PermissionGroupFragment + permissions { + ...PermissionFragment + } + users { + ...StaffMemberFragment + } + } +`; diff --git a/src/fragments/plugins.ts b/src/fragments/plugins.ts new file mode 100644 index 000000000..3a128af56 --- /dev/null +++ b/src/fragments/plugins.ts @@ -0,0 +1,24 @@ +import gql from "graphql-tag"; + +export const pluginsFragment = gql` + fragment PluginFragment on Plugin { + id + name + description + active + } +`; + +export const pluginsDetailsFragment = gql` + ${pluginsFragment} + fragment PluginsDetailsFragment on Plugin { + ...PluginFragment + configuration { + name + type + value + helpText + label + } + } +`; diff --git a/src/fragments/productTypes.ts b/src/fragments/productTypes.ts new file mode 100644 index 000000000..0e6f00ef7 --- /dev/null +++ b/src/fragments/productTypes.ts @@ -0,0 +1,34 @@ +import gql from "graphql-tag"; + +import { attributeFragment } from "./attributes"; + +export const productTypeFragment = gql` + fragment ProductTypeFragment on ProductType { + id + name + hasVariants + isShippingRequired + taxType { + description + taxCode + } + } +`; + +export const productTypeDetailsFragment = gql` + ${attributeFragment} + ${productTypeFragment} + fragment ProductTypeDetailsFragment on ProductType { + ...ProductTypeFragment + productAttributes { + ...AttributeFragment + } + variantAttributes { + ...AttributeFragment + } + weight { + unit + value + } + } +`; diff --git a/src/fragments/products.ts b/src/fragments/products.ts new file mode 100644 index 000000000..499127ab1 --- /dev/null +++ b/src/fragments/products.ts @@ -0,0 +1,233 @@ +import gql from "graphql-tag"; + +export const stockFragment = gql` + fragment StockFragment on Stock { + id + quantity + quantityAllocated + warehouse { + id + name + } + } +`; + +export const fragmentMoney = gql` + fragment Money on Money { + amount + currency + } +`; + +export const fragmentProductImage = gql` + fragment ProductImageFragment on ProductImage { + id + alt + sortOrder + url + } +`; + +export const productFragment = gql` + fragment ProductFragment on Product { + id + name + thumbnail { + url + } + isAvailable + isPublished + productType { + id + name + hasVariants + } + } +`; + +export const productVariantAttributesFragment = gql` + ${fragmentMoney} + fragment ProductVariantAttributesFragment on Product { + id + attributes { + attribute { + id + slug + name + inputType + valueRequired + values { + id + name + slug + } + } + values { + id + name + slug + } + } + productType { + id + variantAttributes { + id + name + values { + id + name + slug + } + } + } + pricing { + priceRangeUndiscounted { + start { + gross { + ...Money + } + } + stop { + gross { + ...Money + } + } + } + } + } +`; + +export const productFragmentDetails = gql` + ${fragmentProductImage} + ${fragmentMoney} + ${productVariantAttributesFragment} + ${stockFragment} + fragment Product on Product { + ...ProductVariantAttributesFragment + name + descriptionJson + seoTitle + seoDescription + category { + id + name + } + collections { + id + name + } + margin { + start + stop + } + purchaseCost { + start { + ...Money + } + stop { + ...Money + } + } + isAvailable + isPublished + chargeTaxes + publicationDate + pricing { + priceRangeUndiscounted { + start { + gross { + ...Money + } + } + stop { + gross { + ...Money + } + } + } + } + images { + ...ProductImageFragment + } + variants { + id + sku + name + price { + ...Money + } + margin + stocks { + ...StockFragment + } + trackInventory + } + productType { + id + name + hasVariants + } + } +`; + +export const fragmentVariant = gql` + ${fragmentMoney} + ${fragmentProductImage} + ${stockFragment} + fragment ProductVariant on ProductVariant { + id + attributes { + attribute { + id + name + slug + valueRequired + values { + id + name + slug + } + } + values { + id + name + slug + } + } + costPrice { + ...Money + } + images { + id + url + } + name + price { + ...Money + } + product { + id + images { + ...ProductImageFragment + } + name + thumbnail { + url + } + variants { + id + name + sku + images { + id + url + } + } + } + sku + stocks { + ...StockFragment + } + trackInventory + } +`; diff --git a/src/fragments/services.ts b/src/fragments/services.ts new file mode 100644 index 000000000..fa99ae421 --- /dev/null +++ b/src/fragments/services.ts @@ -0,0 +1,25 @@ +import gql from "graphql-tag"; + +export const serviceFragment = gql` + fragment ServiceFragment on ServiceAccount { + id + name + isActive + } +`; + +export const serviceDetailsFragment = gql` + ${serviceFragment} + fragment ServiceDetailsFragment on ServiceAccount { + ...ServiceFragment + permissions { + code + name + } + tokens { + id + name + authToken + } + } +`; diff --git a/src/fragments/shipping.ts b/src/fragments/shipping.ts new file mode 100644 index 000000000..b2845edc7 --- /dev/null +++ b/src/fragments/shipping.ts @@ -0,0 +1,54 @@ +import gql from "graphql-tag"; + +export const shippingZoneFragment = gql` + fragment ShippingZoneFragment on ShippingZone { + id + countries { + code + country + } + name + } +`; +export const shippingMethodFragment = gql` + fragment ShippingMethodFragment on ShippingMethod { + id + minimumOrderPrice { + amount + currency + } + minimumOrderWeight { + unit + value + } + maximumOrderPrice { + amount + currency + } + maximumOrderWeight { + unit + value + } + name + price { + amount + currency + } + type + } +`; +export const shippingZoneDetailsFragment = gql` + ${shippingZoneFragment} + ${shippingMethodFragment} + fragment ShippingZoneDetailsFragment on ShippingZone { + ...ShippingZoneFragment + default + shippingMethods { + ...ShippingMethodFragment + } + warehouses { + id + name + } + } +`; diff --git a/src/fragments/shop.ts b/src/fragments/shop.ts new file mode 100644 index 000000000..b7e05eebe --- /dev/null +++ b/src/fragments/shop.ts @@ -0,0 +1,28 @@ +import gql from "graphql-tag"; + +import { fragmentAddress } from "./address"; + +export const shopFragment = gql` + ${fragmentAddress} + fragment ShopFragment on Shop { + authorizationKeys { + key + name + } + companyAddress { + ...AddressFragment + } + countries { + code + country + } + customerSetPasswordUrl + defaultMailSenderAddress + defaultMailSenderName + description + domain { + host + } + name + } +`; diff --git a/src/fragments/staff.ts b/src/fragments/staff.ts new file mode 100644 index 000000000..4262563c8 --- /dev/null +++ b/src/fragments/staff.ts @@ -0,0 +1,29 @@ +import gql from "graphql-tag"; + +export const staffMemberFragment = gql` + fragment StaffMemberFragment on User { + id + email + firstName + isActive + lastName + avatar { + url + } + } +`; +export const staffMemberDetailsFragment = gql` + ${staffMemberFragment} + fragment StaffMemberDetailsFragment on User { + ...StaffMemberFragment + permissionGroups { + id + name + userCanManage + } + userPermissions { + code + name + } + } +`; diff --git a/src/fragments/taxes.ts b/src/fragments/taxes.ts new file mode 100644 index 000000000..026bc00f4 --- /dev/null +++ b/src/fragments/taxes.ts @@ -0,0 +1,28 @@ +import gql from "graphql-tag"; + +export const countryFragment = gql` + fragment CountryFragment on CountryDisplay { + country + code + } +`; +export const countryWithTaxesFragment = gql` + ${countryFragment} + fragment CountryWithTaxesFragment on CountryDisplay { + ...CountryFragment + vat { + standardRate + reducedRates { + rateType + rate + } + } + } +`; +export const shopTaxesFragment = gql` + fragment ShopTaxesFragment on Shop { + chargeTaxesOnShipping + includeTaxesInPrices + displayGrossPrices + } +`; diff --git a/src/fragments/translations.ts b/src/fragments/translations.ts new file mode 100644 index 000000000..2a05816f4 --- /dev/null +++ b/src/fragments/translations.ts @@ -0,0 +1,172 @@ +import gql from "graphql-tag"; + +export const categoryTranslationFragment = gql` + fragment CategoryTranslationFragment on Category { + id + name + descriptionJson + seoDescription + seoTitle + translation(languageCode: $language) { + id + descriptionJson + language { + language + } + name + seoDescription + seoTitle + } + } +`; +export const collectionTranslationFragment = gql` + fragment CollectionTranslationFragment on Collection { + id + name + descriptionJson + seoDescription + seoTitle + translation(languageCode: $language) { + id + descriptionJson + language { + language + } + name + seoDescription + seoTitle + } + } +`; +export const productTranslationFragment = gql` + fragment ProductTranslationFragment on Product { + id + name + descriptionJson + seoDescription + seoTitle + translation(languageCode: $language) { + id + descriptionJson + language { + code + language + } + name + seoDescription + seoTitle + } + } +`; +export const saleTranslationFragment = gql` + fragment SaleTranslationFragment on Sale { + id + name + translation(languageCode: $language) { + id + language { + code + language + } + name + } + } +`; +export const voucherTranslationFragment = gql` + fragment VoucherTranslationFragment on Voucher { + id + name + translation(languageCode: $language) { + id + language { + code + language + } + name + } + } +`; +export const shippingMethodTranslationFragment = gql` + fragment ShippingMethodTranslationFragment on ShippingMethod { + id + name + translation(languageCode: $language) { + id + language { + code + language + } + name + } + } +`; +export const pageTranslationFragment = gql` + fragment PageTranslationFragment on Page { + id + contentJson + seoDescription + seoTitle + title + + translation(languageCode: $language) { + id + contentJson + seoDescription + seoTitle + title + language { + code + language + } + } + } +`; +export const pageTranslatableFragment = gql` + fragment PageTranslatableFragment on PageTranslatableContent { + id + contentJson + seoDescription + seoTitle + title + + translation(languageCode: $language) { + id + contentJson + seoDescription + seoTitle + title + language { + code + language + } + } + } +`; +export const productTypeTranslationFragment = gql` + fragment AttributeTranslationFragment on Attribute { + id + name + translation(languageCode: $language) { + id + name + } + values { + id + name + translation(languageCode: $language) { + id + name + } + } + } + fragment ProductTypeTranslationFragment on ProductType { + id + name + productAttributes { + ...AttributeTranslationFragment + } + variantAttributes { + ...AttributeTranslationFragment + } + } +`; diff --git a/src/customers/types/AccountErrorFragment.ts b/src/fragments/types/AccountErrorFragment.ts similarity index 100% rename from src/customers/types/AccountErrorFragment.ts rename to src/fragments/types/AccountErrorFragment.ts diff --git a/src/orders/types/AddressFragment.ts b/src/fragments/types/AddressFragment.ts similarity index 100% rename from src/orders/types/AddressFragment.ts rename to src/fragments/types/AddressFragment.ts diff --git a/src/attributes/types/AttributeDetailsFragment.ts b/src/fragments/types/AttributeDetailsFragment.ts similarity index 100% rename from src/attributes/types/AttributeDetailsFragment.ts rename to src/fragments/types/AttributeDetailsFragment.ts diff --git a/src/attributes/types/AttributeFragment.ts b/src/fragments/types/AttributeFragment.ts similarity index 100% rename from src/attributes/types/AttributeFragment.ts rename to src/fragments/types/AttributeFragment.ts diff --git a/src/translations/types/AttributeTranslationFragment.ts b/src/fragments/types/AttributeTranslationFragment.ts similarity index 100% rename from src/translations/types/AttributeTranslationFragment.ts rename to src/fragments/types/AttributeTranslationFragment.ts diff --git a/src/products/types/BulkProductErrorFragment.ts b/src/fragments/types/BulkProductErrorFragment.ts similarity index 100% rename from src/products/types/BulkProductErrorFragment.ts rename to src/fragments/types/BulkProductErrorFragment.ts diff --git a/src/products/types/BulkStockErrorFragment.ts b/src/fragments/types/BulkStockErrorFragment.ts similarity index 100% rename from src/products/types/BulkStockErrorFragment.ts rename to src/fragments/types/BulkStockErrorFragment.ts diff --git a/src/categories/types/CategoryDetailsFragment.ts b/src/fragments/types/CategoryDetailsFragment.ts similarity index 100% rename from src/categories/types/CategoryDetailsFragment.ts rename to src/fragments/types/CategoryDetailsFragment.ts diff --git a/src/categories/types/CategoryFragment.ts b/src/fragments/types/CategoryFragment.ts similarity index 100% rename from src/categories/types/CategoryFragment.ts rename to src/fragments/types/CategoryFragment.ts diff --git a/src/translations/types/CategoryTranslationFragment.ts b/src/fragments/types/CategoryTranslationFragment.ts similarity index 100% rename from src/translations/types/CategoryTranslationFragment.ts rename to src/fragments/types/CategoryTranslationFragment.ts diff --git a/src/collections/types/CollectionDetailsFragment.ts b/src/fragments/types/CollectionDetailsFragment.ts similarity index 100% rename from src/collections/types/CollectionDetailsFragment.ts rename to src/fragments/types/CollectionDetailsFragment.ts diff --git a/src/collections/types/CollectionFragment.ts b/src/fragments/types/CollectionFragment.ts similarity index 100% rename from src/collections/types/CollectionFragment.ts rename to src/fragments/types/CollectionFragment.ts diff --git a/src/collections/types/CollectionProductFragment.ts b/src/fragments/types/CollectionProductFragment.ts similarity index 100% rename from src/collections/types/CollectionProductFragment.ts rename to src/fragments/types/CollectionProductFragment.ts diff --git a/src/translations/types/CollectionTranslationFragment.ts b/src/fragments/types/CollectionTranslationFragment.ts similarity index 100% rename from src/translations/types/CollectionTranslationFragment.ts rename to src/fragments/types/CollectionTranslationFragment.ts diff --git a/src/taxes/types/CountryFragment.ts b/src/fragments/types/CountryFragment.ts similarity index 100% rename from src/taxes/types/CountryFragment.ts rename to src/fragments/types/CountryFragment.ts diff --git a/src/taxes/types/CountryWithTaxesFragment.ts b/src/fragments/types/CountryWithTaxesFragment.ts similarity index 100% rename from src/taxes/types/CountryWithTaxesFragment.ts rename to src/fragments/types/CountryWithTaxesFragment.ts diff --git a/src/customers/types/CustomerAddressesFragment.ts b/src/fragments/types/CustomerAddressesFragment.ts similarity index 100% rename from src/customers/types/CustomerAddressesFragment.ts rename to src/fragments/types/CustomerAddressesFragment.ts diff --git a/src/customers/types/CustomerDetailsFragment.ts b/src/fragments/types/CustomerDetailsFragment.ts similarity index 100% rename from src/customers/types/CustomerDetailsFragment.ts rename to src/fragments/types/CustomerDetailsFragment.ts diff --git a/src/customers/types/CustomerFragment.ts b/src/fragments/types/CustomerFragment.ts similarity index 100% rename from src/customers/types/CustomerFragment.ts rename to src/fragments/types/CustomerFragment.ts diff --git a/src/discounts/types/DiscountErrorFragment.ts b/src/fragments/types/DiscountErrorFragment.ts similarity index 100% rename from src/discounts/types/DiscountErrorFragment.ts rename to src/fragments/types/DiscountErrorFragment.ts diff --git a/src/orders/types/FulfillmentFragment.ts b/src/fragments/types/FulfillmentFragment.ts similarity index 100% rename from src/orders/types/FulfillmentFragment.ts rename to src/fragments/types/FulfillmentFragment.ts diff --git a/src/navigation/types/MenuDetailsFragment.ts b/src/fragments/types/MenuDetailsFragment.ts similarity index 100% rename from src/navigation/types/MenuDetailsFragment.ts rename to src/fragments/types/MenuDetailsFragment.ts diff --git a/src/navigation/types/MenuErrorFragment.ts b/src/fragments/types/MenuErrorFragment.ts similarity index 100% rename from src/navigation/types/MenuErrorFragment.ts rename to src/fragments/types/MenuErrorFragment.ts diff --git a/src/navigation/types/MenuFragment.ts b/src/fragments/types/MenuFragment.ts similarity index 100% rename from src/navigation/types/MenuFragment.ts rename to src/fragments/types/MenuFragment.ts diff --git a/src/navigation/types/MenuItemFragment.ts b/src/fragments/types/MenuItemFragment.ts similarity index 100% rename from src/navigation/types/MenuItemFragment.ts rename to src/fragments/types/MenuItemFragment.ts diff --git a/src/navigation/types/MenuItemNestedFragment.ts b/src/fragments/types/MenuItemNestedFragment.ts similarity index 100% rename from src/navigation/types/MenuItemNestedFragment.ts rename to src/fragments/types/MenuItemNestedFragment.ts diff --git a/src/products/types/Money.ts b/src/fragments/types/Money.ts similarity index 100% rename from src/products/types/Money.ts rename to src/fragments/types/Money.ts diff --git a/src/orders/types/OrderDetailsFragment.ts b/src/fragments/types/OrderDetailsFragment.ts similarity index 100% rename from src/orders/types/OrderDetailsFragment.ts rename to src/fragments/types/OrderDetailsFragment.ts diff --git a/src/orders/types/OrderErrorFragment.ts b/src/fragments/types/OrderErrorFragment.ts similarity index 100% rename from src/orders/types/OrderErrorFragment.ts rename to src/fragments/types/OrderErrorFragment.ts diff --git a/src/orders/types/OrderEventFragment.ts b/src/fragments/types/OrderEventFragment.ts similarity index 100% rename from src/orders/types/OrderEventFragment.ts rename to src/fragments/types/OrderEventFragment.ts diff --git a/src/orders/types/OrderLineFragment.ts b/src/fragments/types/OrderLineFragment.ts similarity index 100% rename from src/orders/types/OrderLineFragment.ts rename to src/fragments/types/OrderLineFragment.ts diff --git a/src/pages/types/PageDetailsFragment.ts b/src/fragments/types/PageDetailsFragment.ts similarity index 100% rename from src/pages/types/PageDetailsFragment.ts rename to src/fragments/types/PageDetailsFragment.ts diff --git a/src/pages/types/PageErrorFragment.ts b/src/fragments/types/PageErrorFragment.ts similarity index 100% rename from src/pages/types/PageErrorFragment.ts rename to src/fragments/types/PageErrorFragment.ts diff --git a/src/pages/types/PageFragment.ts b/src/fragments/types/PageFragment.ts similarity index 100% rename from src/pages/types/PageFragment.ts rename to src/fragments/types/PageFragment.ts diff --git a/src/types/PageInfoFragment.ts b/src/fragments/types/PageInfoFragment.ts similarity index 100% rename from src/types/PageInfoFragment.ts rename to src/fragments/types/PageInfoFragment.ts diff --git a/src/translations/types/PageTranslatableFragment.ts b/src/fragments/types/PageTranslatableFragment.ts similarity index 100% rename from src/translations/types/PageTranslatableFragment.ts rename to src/fragments/types/PageTranslatableFragment.ts diff --git a/src/translations/types/PageTranslationFragment.ts b/src/fragments/types/PageTranslationFragment.ts similarity index 100% rename from src/translations/types/PageTranslationFragment.ts rename to src/fragments/types/PageTranslationFragment.ts diff --git a/src/permissionGroups/types/PermissionFragment.ts b/src/fragments/types/PermissionFragment.ts similarity index 100% rename from src/permissionGroups/types/PermissionFragment.ts rename to src/fragments/types/PermissionFragment.ts diff --git a/src/permissionGroups/types/PermissionGroupDetailsFragment.ts b/src/fragments/types/PermissionGroupDetailsFragment.ts similarity index 100% rename from src/permissionGroups/types/PermissionGroupDetailsFragment.ts rename to src/fragments/types/PermissionGroupDetailsFragment.ts diff --git a/src/permissionGroups/types/PermissionGroupErrorFragment.ts b/src/fragments/types/PermissionGroupErrorFragment.ts similarity index 100% rename from src/permissionGroups/types/PermissionGroupErrorFragment.ts rename to src/fragments/types/PermissionGroupErrorFragment.ts diff --git a/src/permissionGroups/types/PermissionGroupFragment.ts b/src/fragments/types/PermissionGroupFragment.ts similarity index 100% rename from src/permissionGroups/types/PermissionGroupFragment.ts rename to src/fragments/types/PermissionGroupFragment.ts diff --git a/src/plugins/types/PluginFragment.ts b/src/fragments/types/PluginFragment.ts similarity index 100% rename from src/plugins/types/PluginFragment.ts rename to src/fragments/types/PluginFragment.ts diff --git a/src/plugins/types/PluginsDetailsFragment.ts b/src/fragments/types/PluginsDetailsFragment.ts similarity index 100% rename from src/plugins/types/PluginsDetailsFragment.ts rename to src/fragments/types/PluginsDetailsFragment.ts diff --git a/src/products/types/Product.ts b/src/fragments/types/Product.ts similarity index 100% rename from src/products/types/Product.ts rename to src/fragments/types/Product.ts diff --git a/src/attributes/types/ProductErrorFragment.ts b/src/fragments/types/ProductErrorFragment.ts similarity index 100% rename from src/attributes/types/ProductErrorFragment.ts rename to src/fragments/types/ProductErrorFragment.ts diff --git a/src/products/types/ProductFragment.ts b/src/fragments/types/ProductFragment.ts similarity index 100% rename from src/products/types/ProductFragment.ts rename to src/fragments/types/ProductFragment.ts diff --git a/src/products/types/ProductImageFragment.ts b/src/fragments/types/ProductImageFragment.ts similarity index 100% rename from src/products/types/ProductImageFragment.ts rename to src/fragments/types/ProductImageFragment.ts diff --git a/src/translations/types/ProductTranslationFragment.ts b/src/fragments/types/ProductTranslationFragment.ts similarity index 100% rename from src/translations/types/ProductTranslationFragment.ts rename to src/fragments/types/ProductTranslationFragment.ts diff --git a/src/productTypes/types/ProductTypeDetailsFragment.ts b/src/fragments/types/ProductTypeDetailsFragment.ts similarity index 100% rename from src/productTypes/types/ProductTypeDetailsFragment.ts rename to src/fragments/types/ProductTypeDetailsFragment.ts diff --git a/src/productTypes/types/ProductTypeFragment.ts b/src/fragments/types/ProductTypeFragment.ts similarity index 100% rename from src/productTypes/types/ProductTypeFragment.ts rename to src/fragments/types/ProductTypeFragment.ts diff --git a/src/translations/types/ProductTypeTranslationFragment.ts b/src/fragments/types/ProductTypeTranslationFragment.ts similarity index 100% rename from src/translations/types/ProductTypeTranslationFragment.ts rename to src/fragments/types/ProductTypeTranslationFragment.ts diff --git a/src/products/types/ProductVariant.ts b/src/fragments/types/ProductVariant.ts similarity index 100% rename from src/products/types/ProductVariant.ts rename to src/fragments/types/ProductVariant.ts diff --git a/src/products/types/ProductVariantAttributesFragment.ts b/src/fragments/types/ProductVariantAttributesFragment.ts similarity index 100% rename from src/products/types/ProductVariantAttributesFragment.ts rename to src/fragments/types/ProductVariantAttributesFragment.ts diff --git a/src/discounts/types/SaleDetailsFragment.ts b/src/fragments/types/SaleDetailsFragment.ts similarity index 100% rename from src/discounts/types/SaleDetailsFragment.ts rename to src/fragments/types/SaleDetailsFragment.ts diff --git a/src/discounts/types/SaleFragment.ts b/src/fragments/types/SaleFragment.ts similarity index 100% rename from src/discounts/types/SaleFragment.ts rename to src/fragments/types/SaleFragment.ts diff --git a/src/translations/types/SaleTranslationFragment.ts b/src/fragments/types/SaleTranslationFragment.ts similarity index 100% rename from src/translations/types/SaleTranslationFragment.ts rename to src/fragments/types/SaleTranslationFragment.ts diff --git a/src/services/types/ServiceDetailsFragment.ts b/src/fragments/types/ServiceDetailsFragment.ts similarity index 100% rename from src/services/types/ServiceDetailsFragment.ts rename to src/fragments/types/ServiceDetailsFragment.ts diff --git a/src/services/types/ServiceFragment.ts b/src/fragments/types/ServiceFragment.ts similarity index 100% rename from src/services/types/ServiceFragment.ts rename to src/fragments/types/ServiceFragment.ts diff --git a/src/shipping/types/ShippingErrorFragment.ts b/src/fragments/types/ShippingErrorFragment.ts similarity index 100% rename from src/shipping/types/ShippingErrorFragment.ts rename to src/fragments/types/ShippingErrorFragment.ts diff --git a/src/shipping/types/ShippingMethodFragment.ts b/src/fragments/types/ShippingMethodFragment.ts similarity index 100% rename from src/shipping/types/ShippingMethodFragment.ts rename to src/fragments/types/ShippingMethodFragment.ts diff --git a/src/translations/types/ShippingMethodTranslationFragment.ts b/src/fragments/types/ShippingMethodTranslationFragment.ts similarity index 100% rename from src/translations/types/ShippingMethodTranslationFragment.ts rename to src/fragments/types/ShippingMethodTranslationFragment.ts diff --git a/src/shipping/types/ShippingZoneDetailsFragment.ts b/src/fragments/types/ShippingZoneDetailsFragment.ts similarity index 100% rename from src/shipping/types/ShippingZoneDetailsFragment.ts rename to src/fragments/types/ShippingZoneDetailsFragment.ts diff --git a/src/shipping/types/ShippingZoneFragment.ts b/src/fragments/types/ShippingZoneFragment.ts similarity index 100% rename from src/shipping/types/ShippingZoneFragment.ts rename to src/fragments/types/ShippingZoneFragment.ts diff --git a/src/collections/types/ShopErrorFragment.ts b/src/fragments/types/ShopErrorFragment.ts similarity index 100% rename from src/collections/types/ShopErrorFragment.ts rename to src/fragments/types/ShopErrorFragment.ts diff --git a/src/siteSettings/types/ShopFragment.ts b/src/fragments/types/ShopFragment.ts similarity index 100% rename from src/siteSettings/types/ShopFragment.ts rename to src/fragments/types/ShopFragment.ts diff --git a/src/taxes/types/ShopTaxesFragment.ts b/src/fragments/types/ShopTaxesFragment.ts similarity index 100% rename from src/taxes/types/ShopTaxesFragment.ts rename to src/fragments/types/ShopTaxesFragment.ts diff --git a/src/staff/types/StaffErrorFragment.ts b/src/fragments/types/StaffErrorFragment.ts similarity index 100% rename from src/staff/types/StaffErrorFragment.ts rename to src/fragments/types/StaffErrorFragment.ts diff --git a/src/staff/types/StaffMemberDetailsFragment.ts b/src/fragments/types/StaffMemberDetailsFragment.ts similarity index 100% rename from src/staff/types/StaffMemberDetailsFragment.ts rename to src/fragments/types/StaffMemberDetailsFragment.ts diff --git a/src/staff/types/StaffMemberFragment.ts b/src/fragments/types/StaffMemberFragment.ts similarity index 100% rename from src/staff/types/StaffMemberFragment.ts rename to src/fragments/types/StaffMemberFragment.ts diff --git a/src/products/types/StockErrorFragment.ts b/src/fragments/types/StockErrorFragment.ts similarity index 100% rename from src/products/types/StockErrorFragment.ts rename to src/fragments/types/StockErrorFragment.ts diff --git a/src/products/types/StockFragment.ts b/src/fragments/types/StockFragment.ts similarity index 100% rename from src/products/types/StockFragment.ts rename to src/fragments/types/StockFragment.ts diff --git a/src/auth/types/User.ts b/src/fragments/types/User.ts similarity index 100% rename from src/auth/types/User.ts rename to src/fragments/types/User.ts diff --git a/src/discounts/types/VoucherDetailsFragment.ts b/src/fragments/types/VoucherDetailsFragment.ts similarity index 100% rename from src/discounts/types/VoucherDetailsFragment.ts rename to src/fragments/types/VoucherDetailsFragment.ts diff --git a/src/discounts/types/VoucherFragment.ts b/src/fragments/types/VoucherFragment.ts similarity index 100% rename from src/discounts/types/VoucherFragment.ts rename to src/fragments/types/VoucherFragment.ts diff --git a/src/translations/types/VoucherTranslationFragment.ts b/src/fragments/types/VoucherTranslationFragment.ts similarity index 100% rename from src/translations/types/VoucherTranslationFragment.ts rename to src/fragments/types/VoucherTranslationFragment.ts diff --git a/src/warehouses/types/WarehouseDetailsFragment.ts b/src/fragments/types/WarehouseDetailsFragment.ts similarity index 100% rename from src/warehouses/types/WarehouseDetailsFragment.ts rename to src/fragments/types/WarehouseDetailsFragment.ts diff --git a/src/warehouses/types/WarehouseErrorFragment.ts b/src/fragments/types/WarehouseErrorFragment.ts similarity index 100% rename from src/warehouses/types/WarehouseErrorFragment.ts rename to src/fragments/types/WarehouseErrorFragment.ts diff --git a/src/warehouses/types/WarehouseFragment.ts b/src/fragments/types/WarehouseFragment.ts similarity index 100% rename from src/warehouses/types/WarehouseFragment.ts rename to src/fragments/types/WarehouseFragment.ts diff --git a/src/warehouses/types/WarehouseWithShippingFragment.ts b/src/fragments/types/WarehouseWithShippingFragment.ts similarity index 100% rename from src/warehouses/types/WarehouseWithShippingFragment.ts rename to src/fragments/types/WarehouseWithShippingFragment.ts diff --git a/src/webhooks/types/WebhookErrorFragment.ts b/src/fragments/types/WebhookErrorFragment.ts similarity index 100% rename from src/webhooks/types/WebhookErrorFragment.ts rename to src/fragments/types/WebhookErrorFragment.ts diff --git a/src/webhooks/types/WebhookFragment.ts b/src/fragments/types/WebhookFragment.ts similarity index 100% rename from src/webhooks/types/WebhookFragment.ts rename to src/fragments/types/WebhookFragment.ts diff --git a/src/webhooks/types/WebhooksDetailsFragment.ts b/src/fragments/types/WebhooksDetailsFragment.ts similarity index 100% rename from src/webhooks/types/WebhooksDetailsFragment.ts rename to src/fragments/types/WebhooksDetailsFragment.ts diff --git a/src/fragments/warehouses.ts b/src/fragments/warehouses.ts new file mode 100644 index 000000000..49eb9d843 --- /dev/null +++ b/src/fragments/warehouses.ts @@ -0,0 +1,35 @@ +import gql from "graphql-tag"; + +import { fragmentAddress } from "./address"; + +export const warehouseFragment = gql` + fragment WarehouseFragment on Warehouse { + id + name + } +`; +export const warehouseWithShippingFragment = gql` + ${warehouseFragment} + fragment WarehouseWithShippingFragment on Warehouse { + ...WarehouseFragment + shippingZones(first: 100) { + edges { + node { + id + name + } + } + } + } +`; + +export const warehouseDetailsFragment = gql` + ${fragmentAddress} + ${warehouseWithShippingFragment} + fragment WarehouseDetailsFragment on Warehouse { + ...WarehouseWithShippingFragment + address { + ...AddressFragment + } + } +`; diff --git a/src/fragments/webhooks.ts b/src/fragments/webhooks.ts new file mode 100644 index 000000000..c31e454bd --- /dev/null +++ b/src/fragments/webhooks.ts @@ -0,0 +1,20 @@ +import gql from "graphql-tag"; + +export const webhooksFragment = gql` + fragment WebhookFragment on Webhook { + id + name + isActive + serviceAccount { + id + name + } + } +`; + +export const webhooksDetailsFragment = gql` + ${webhooksFragment} + fragment WebhooksDetailsFragment on Webhook { + ...WebhookFragment + } +`; diff --git a/src/hooks/makeTopLevelSearch.ts b/src/hooks/makeTopLevelSearch.ts index 26793ddcf..0e81770b7 100644 --- a/src/hooks/makeTopLevelSearch.ts +++ b/src/hooks/makeTopLevelSearch.ts @@ -1,4 +1,4 @@ -import { PageInfoFragment } from "@saleor/types/PageInfoFragment"; +import { PageInfoFragment } from "@saleor/fragments/types/PageInfoFragment"; import { DocumentNode } from "graphql"; import makeSearch, { SearchVariables, UseSearchHook } from "./makeSearch"; diff --git a/src/hooks/useAddressValidation.ts b/src/hooks/useAddressValidation.ts index c14efc6b7..de9f81bad 100644 --- a/src/hooks/useAddressValidation.ts +++ b/src/hooks/useAddressValidation.ts @@ -1,5 +1,5 @@ import { AddressTypeInput } from "@saleor/customers/types"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import { transformFormToAddress } from "@saleor/misc"; import { AccountErrorCode, AddressInput } from "@saleor/types/globalTypes"; import { add, remove } from "@saleor/utils/lists"; diff --git a/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx b/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx index d93292c3b..200a9ed0b 100644 --- a/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx +++ b/src/navigation/components/MenuCreateDialog/MenuCreateDialog.tsx @@ -8,8 +8,8 @@ import ConfirmButton, { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; +import { MenuErrorFragment } from "@saleor/fragments/types/MenuErrorFragment"; import { buttonMessages } from "@saleor/intl"; -import { MenuErrorFragment } from "@saleor/navigation/types/MenuErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getMenuErrorMessage from "@saleor/utils/errors/menu"; import React from "react"; diff --git a/src/navigation/components/MenuDetailsPage/MenuDetailsPage.tsx b/src/navigation/components/MenuDetailsPage/MenuDetailsPage.tsx index 00802f811..93c093ff8 100644 --- a/src/navigation/components/MenuDetailsPage/MenuDetailsPage.tsx +++ b/src/navigation/components/MenuDetailsPage/MenuDetailsPage.tsx @@ -6,8 +6,8 @@ import Container from "@saleor/components/Container"; import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; +import { MenuErrorFragment } from "@saleor/fragments/types/MenuErrorFragment"; import { sectionNames } from "@saleor/intl"; -import { MenuErrorFragment } from "@saleor/navigation/types/MenuErrorFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/navigation/components/MenuItemDialog/MenuItemDialog.tsx b/src/navigation/components/MenuItemDialog/MenuItemDialog.tsx index 6c2224b46..394c2ec46 100644 --- a/src/navigation/components/MenuItemDialog/MenuItemDialog.tsx +++ b/src/navigation/components/MenuItemDialog/MenuItemDialog.tsx @@ -10,11 +10,11 @@ import ConfirmButton, { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import FormSpacer from "@saleor/components/FormSpacer"; +import { MenuErrorFragment } from "@saleor/fragments/types/MenuErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import useModalDialogOpen from "@saleor/hooks/useModalDialogOpen"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { buttonMessages, sectionNames } from "@saleor/intl"; -import { MenuErrorFragment } from "@saleor/navigation/types/MenuErrorFragment"; import { SearchCategories_search_edges_node } from "@saleor/searches/types/SearchCategories"; import { SearchCollections_search_edges_node } from "@saleor/searches/types/SearchCollections"; import { SearchPages_search_edges_node } from "@saleor/searches/types/SearchPages"; diff --git a/src/navigation/components/MenuProperties/MenuProperties.tsx b/src/navigation/components/MenuProperties/MenuProperties.tsx index 4db982832..8182a95b7 100644 --- a/src/navigation/components/MenuProperties/MenuProperties.tsx +++ b/src/navigation/components/MenuProperties/MenuProperties.tsx @@ -2,8 +2,8 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; +import { MenuErrorFragment } from "@saleor/fragments/types/MenuErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { MenuErrorFragment } from "@saleor/navigation/types/MenuErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getMenuErrorMessage from "@saleor/utils/errors/menu"; import React from "react"; diff --git a/src/navigation/mutations.ts b/src/navigation/mutations.ts index 433844ccb..3df68787b 100644 --- a/src/navigation/mutations.ts +++ b/src/navigation/mutations.ts @@ -1,7 +1,11 @@ +import { menuErrorFragment } from "@saleor/fragments/errors"; +import { + menuItemFragment, + menuItemNestedFragment +} from "@saleor/fragments/navigation"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { menuItemFragment, menuItemNestedFragment } from "./queries"; import { MenuBulkDelete, MenuBulkDeleteVariables @@ -18,13 +22,6 @@ import { } from "./types/MenuItemUpdate"; import { MenuUpdate, MenuUpdateVariables } from "./types/MenuUpdate"; -const menuErrorFragment = gql` - fragment MenuErrorFragment on MenuError { - code - field - } -`; - const menuCreate = gql` ${menuErrorFragment} mutation MenuCreate($input: MenuCreateInput!) { diff --git a/src/navigation/queries.ts b/src/navigation/queries.ts index 8528c4dc4..4bb0316cc 100644 --- a/src/navigation/queries.ts +++ b/src/navigation/queries.ts @@ -1,78 +1,15 @@ +import { + menuDetailsFragment, + menuFragment +} from "@saleor/fragments/navigation"; +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; -import { pageInfoFragment, TypedQuery } from "../queries"; +import { TypedQuery } from "../queries"; import { MenuDetails, MenuDetailsVariables } from "./types/MenuDetails"; import { MenuList, MenuListVariables } from "./types/MenuList"; -export const menuFragment = gql` - fragment MenuFragment on Menu { - id - name - items { - id - } - } -`; - -export const menuItemFragment = gql` - fragment MenuItemFragment on MenuItem { - category { - id - name - } - collection { - id - name - } - id - level - name - page { - id - title - } - url - } -`; - -// GraphQL does not support recurive fragments -export const menuItemNestedFragment = gql` - ${menuItemFragment} - fragment MenuItemNestedFragment on MenuItem { - ...MenuItemFragment - children { - ...MenuItemFragment - children { - ...MenuItemFragment - children { - ...MenuItemFragment - children { - ...MenuItemFragment - children { - ...MenuItemFragment - children { - ...MenuItemFragment - } - } - } - } - } - } - } -`; - -export const menuDetailsFragment = gql` - ${menuItemNestedFragment} - fragment MenuDetailsFragment on Menu { - id - items { - ...MenuItemNestedFragment - } - name - } -`; - const menuList = gql` ${menuFragment} ${pageInfoFragment} diff --git a/src/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx b/src/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx index 7a1924db6..4a3f10622 100644 --- a/src/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx +++ b/src/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx @@ -10,12 +10,12 @@ import ConfirmButton, { } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; import { AddressTypeInput } from "@saleor/customers/types"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import useAddressValidation from "@saleor/hooks/useAddressValidation"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { buttonMessages } from "@saleor/intl"; import { maybe } from "@saleor/misc"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import { AddressInput } from "@saleor/types/globalTypes"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; import React from "react"; diff --git a/src/orders/components/OrderCancelDialog/OrderCancelDialog.tsx b/src/orders/components/OrderCancelDialog/OrderCancelDialog.tsx index 67c5a2922..393c78591 100644 --- a/src/orders/components/OrderCancelDialog/OrderCancelDialog.tsx +++ b/src/orders/components/OrderCancelDialog/OrderCancelDialog.tsx @@ -8,9 +8,9 @@ import ConfirmButton, { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import FormSpacer from "@saleor/components/FormSpacer"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import { buttonMessages } from "@saleor/intl"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/orders/components/OrderDraftCancelDialog/OrderDraftCancelDialog.tsx b/src/orders/components/OrderDraftCancelDialog/OrderDraftCancelDialog.tsx index ff22afe31..403d07f32 100644 --- a/src/orders/components/OrderDraftCancelDialog/OrderDraftCancelDialog.tsx +++ b/src/orders/components/OrderDraftCancelDialog/OrderDraftCancelDialog.tsx @@ -2,8 +2,8 @@ import DialogContentText from "@material-ui/core/DialogContentText"; import ActionDialog from "@saleor/components/ActionDialog"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import FormSpacer from "@saleor/components/FormSpacer"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/orders/components/OrderDraftFinalizeDialog/OrderDraftFinalizeDialog.tsx b/src/orders/components/OrderDraftFinalizeDialog/OrderDraftFinalizeDialog.tsx index 58a569efe..ba8ab3482 100644 --- a/src/orders/components/OrderDraftFinalizeDialog/OrderDraftFinalizeDialog.tsx +++ b/src/orders/components/OrderDraftFinalizeDialog/OrderDraftFinalizeDialog.tsx @@ -2,8 +2,8 @@ import DialogContentText from "@material-ui/core/DialogContentText"; import ActionDialog from "@saleor/components/ActionDialog"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import FormSpacer from "@saleor/components/FormSpacer"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import React from "react"; import { FormattedMessage, IntlShape, useIntl } from "react-intl"; diff --git a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx index dee9de540..e8e157f5b 100644 --- a/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx +++ b/src/orders/components/OrderFulfillPage/OrderFulfillPage.tsx @@ -19,6 +19,7 @@ import ResponsiveTable from "@saleor/components/ResponsiveTable"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import Skeleton from "@saleor/components/Skeleton"; import TableCellAvatar from "@saleor/components/TableCellAvatar"; +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import useFormset, { FormsetData } from "@saleor/hooks/useFormset"; import { renderCollection } from "@saleor/misc"; import { FulfillOrder_orderFulfill_errors } from "@saleor/orders/types/FulfillOrder"; @@ -31,7 +32,6 @@ import { OrderFulfillStockInput } from "@saleor/types/globalTypes"; import { update } from "@saleor/utils/lists"; -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import classNames from "classnames"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/orders/components/OrderFulfillmentCancelDialog/OrderFulfillmentCancelDialog.tsx b/src/orders/components/OrderFulfillmentCancelDialog/OrderFulfillmentCancelDialog.tsx index 8fffae8e1..256a40ae2 100644 --- a/src/orders/components/OrderFulfillmentCancelDialog/OrderFulfillmentCancelDialog.tsx +++ b/src/orders/components/OrderFulfillmentCancelDialog/OrderFulfillmentCancelDialog.tsx @@ -11,11 +11,11 @@ import ConfirmButton, { import Form from "@saleor/components/Form"; import FormSpacer from "@saleor/components/FormSpacer"; import SingleAutocompleteSelectField from "@saleor/components/SingleAutocompleteSelectField"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import { buttonMessages } from "@saleor/intl"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx b/src/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx index 32fb30a4e..6ac29031a 100644 --- a/src/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx +++ b/src/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx @@ -19,8 +19,8 @@ import ResponsiveTable from "@saleor/components/ResponsiveTable"; import TableCellAvatar, { AVATAR_MARGIN } from "@saleor/components/TableCellAvatar"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import { buttonMessages } from "@saleor/intl"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import React from "react"; diff --git a/src/orders/components/OrderFulfillmentTrackingDialog/OrderFulfillmentTrackingDialog.tsx b/src/orders/components/OrderFulfillmentTrackingDialog/OrderFulfillmentTrackingDialog.tsx index d6b32e1d8..93a119b2f 100644 --- a/src/orders/components/OrderFulfillmentTrackingDialog/OrderFulfillmentTrackingDialog.tsx +++ b/src/orders/components/OrderFulfillmentTrackingDialog/OrderFulfillmentTrackingDialog.tsx @@ -10,9 +10,9 @@ import ConfirmButton, { } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; import FormSpacer from "@saleor/components/FormSpacer"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import { buttonMessages } from "@saleor/intl"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import React from "react"; diff --git a/src/orders/components/OrderMarkAsPaidDialog/OrderMarkAsPaidDialog.tsx b/src/orders/components/OrderMarkAsPaidDialog/OrderMarkAsPaidDialog.tsx index 3cf3eaed8..9f00813c1 100644 --- a/src/orders/components/OrderMarkAsPaidDialog/OrderMarkAsPaidDialog.tsx +++ b/src/orders/components/OrderMarkAsPaidDialog/OrderMarkAsPaidDialog.tsx @@ -2,8 +2,8 @@ import DialogContentText from "@material-ui/core/DialogContentText"; import ActionDialog from "@saleor/components/ActionDialog"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import FormSpacer from "@saleor/components/FormSpacer"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/orders/components/OrderPaymentDialog/OrderPaymentDialog.tsx b/src/orders/components/OrderPaymentDialog/OrderPaymentDialog.tsx index d4e59c1bc..40d56382e 100644 --- a/src/orders/components/OrderPaymentDialog/OrderPaymentDialog.tsx +++ b/src/orders/components/OrderPaymentDialog/OrderPaymentDialog.tsx @@ -10,8 +10,8 @@ import ConfirmButton, { } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; import FormSpacer from "@saleor/components/FormSpacer"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import { buttonMessages } from "@saleor/intl"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import React from "react"; diff --git a/src/orders/components/OrderPaymentVoidDialog/OrderPaymentVoidDialog.tsx b/src/orders/components/OrderPaymentVoidDialog/OrderPaymentVoidDialog.tsx index ab812154d..eed639a95 100644 --- a/src/orders/components/OrderPaymentVoidDialog/OrderPaymentVoidDialog.tsx +++ b/src/orders/components/OrderPaymentVoidDialog/OrderPaymentVoidDialog.tsx @@ -8,8 +8,8 @@ import ConfirmButton, { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import FormSpacer from "@saleor/components/FormSpacer"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import { buttonMessages } from "@saleor/intl"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx b/src/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx index c97b3a778..0330b72ee 100644 --- a/src/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx +++ b/src/orders/components/OrderProductAddDialog/OrderProductAddDialog.tsx @@ -18,12 +18,12 @@ import FormSpacer from "@saleor/components/FormSpacer"; import Money from "@saleor/components/Money"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; import TableCellAvatar from "@saleor/components/TableCellAvatar"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import useModalDialogOpen from "@saleor/hooks/useModalDialogOpen"; import useSearchQuery from "@saleor/hooks/useSearchQuery"; import { buttonMessages } from "@saleor/intl"; import { maybe, renderCollection } from "@saleor/misc"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import { FetchMoreProps } from "@saleor/types"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import React from "react"; diff --git a/src/orders/components/OrderShippingMethodEditDialog/OrderShippingMethodEditDialog.tsx b/src/orders/components/OrderShippingMethodEditDialog/OrderShippingMethodEditDialog.tsx index 73a40ce01..43419630b 100644 --- a/src/orders/components/OrderShippingMethodEditDialog/OrderShippingMethodEditDialog.tsx +++ b/src/orders/components/OrderShippingMethodEditDialog/OrderShippingMethodEditDialog.tsx @@ -12,9 +12,9 @@ import Form from "@saleor/components/Form"; import FormSpacer from "@saleor/components/FormSpacer"; import Money from "@saleor/components/Money"; import { SingleSelectField } from "@saleor/components/SingleSelectField"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import { buttonMessages } from "@saleor/intl"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getOrderErrorMessage from "@saleor/utils/errors/order"; import React from "react"; diff --git a/src/orders/mutations.ts b/src/orders/mutations.ts index 4c32064c2..3819a5276 100644 --- a/src/orders/mutations.ts +++ b/src/orders/mutations.ts @@ -1,12 +1,13 @@ +import { fragmentAddress } from "@saleor/fragments/address"; +import { orderErrorFragment } from "@saleor/fragments/errors"; +import { + fragmentOrderDetails, + fragmentOrderEvent +} from "@saleor/fragments/orders"; import makeMutation from "@saleor/hooks/makeMutation"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { - fragmentAddress, - fragmentOrderDetails, - fragmentOrderEvent -} from "./queries"; import { FulfillOrder, FulfillOrderVariables } from "./types/FulfillOrder"; import { OrderAddNote, OrderAddNoteVariables } from "./types/OrderAddNote"; import { OrderCancel, OrderCancelVariables } from "./types/OrderCancel"; @@ -57,13 +58,6 @@ import { import { OrderUpdate, OrderUpdateVariables } from "./types/OrderUpdate"; import { OrderVoid, OrderVoidVariables } from "./types/OrderVoid"; -export const orderErrorFragment = gql` - fragment OrderErrorFragment on OrderError { - code - field - } -`; - const orderCancelMutation = gql` ${fragmentOrderDetails} ${orderErrorFragment} diff --git a/src/orders/queries.ts b/src/orders/queries.ts index a266dd352..334c15538 100644 --- a/src/orders/queries.ts +++ b/src/orders/queries.ts @@ -1,3 +1,5 @@ +import { fragmentAddress } from "@saleor/fragments/address"; +import { fragmentOrderDetails } from "@saleor/fragments/orders"; import makeQuery from "@saleor/hooks/makeQuery"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; import gql from "graphql-tag"; @@ -18,169 +20,6 @@ import { SearchOrderVariantVariables } from "./types/SearchOrderVariant"; -export const fragmentOrderEvent = gql` - fragment OrderEventFragment on OrderEvent { - id - amount - date - email - emailType - message - quantity - type - user { - id - email - } - } -`; -export const fragmentAddress = gql` - fragment AddressFragment on Address { - city - cityArea - companyName - country { - __typename - code - country - } - countryArea - firstName - id - lastName - phone - postalCode - streetAddress1 - streetAddress2 - } -`; -export const fragmentOrderLine = gql` - fragment OrderLineFragment on OrderLine { - id - isShippingRequired - productName - productSku - quantity - quantityFulfilled - unitPrice { - gross { - amount - currency - } - net { - amount - currency - } - } - thumbnail { - url - } - } -`; -export const fulfillmentFragment = gql` - ${fragmentOrderLine} - fragment FulfillmentFragment on Fulfillment { - id - lines { - id - quantity - orderLine { - ...OrderLineFragment - } - } - fulfillmentOrder - status - trackingNumber - warehouse { - id - name - } - } -`; - -export const fragmentOrderDetails = gql` - ${fragmentAddress} - ${fragmentOrderEvent} - ${fragmentOrderLine} - ${fulfillmentFragment} - fragment OrderDetailsFragment on Order { - id - billingAddress { - ...AddressFragment - } - canFinalize - created - customerNote - events { - ...OrderEventFragment - } - fulfillments { - ...FulfillmentFragment - } - lines { - ...OrderLineFragment - } - number - paymentStatus - shippingAddress { - ...AddressFragment - } - shippingMethod { - id - } - shippingMethodName - shippingPrice { - gross { - amount - currency - } - } - status - subtotal { - gross { - amount - currency - } - } - total { - gross { - amount - currency - } - tax { - amount - currency - } - } - actions - totalAuthorized { - amount - currency - } - totalCaptured { - amount - currency - } - user { - id - email - } - userEmail - availableShippingMethods { - id - name - price { - amount - currency - } - } - discount { - amount - currency - } - } -`; - export const orderListQuery = gql` ${fragmentAddress} query OrderList( diff --git a/src/orders/types/OrderRelease.ts b/src/orders/types/OrderRelease.ts deleted file mode 100644 index 0fb77a66f..000000000 --- a/src/orders/types/OrderRelease.ts +++ /dev/null @@ -1,267 +0,0 @@ -/* tslint:disable */ -// This file was automatically generated and should not be edited. - -import { OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus } from "./../../types/globalTypes"; - -// ==================================================== -// GraphQL mutation operation: OrderRelease -// ==================================================== - -export interface OrderRelease_orderRelease_order_billingAddress_country { - __typename: "CountryDisplay"; - code: string; - country: string; -} - -export interface OrderRelease_orderRelease_order_billingAddress { - __typename: "Address"; - city: string; - cityArea: string; - companyName: string; - country: OrderRelease_orderRelease_order_billingAddress_country; - countryArea: string; - firstName: string; - id: string; - lastName: string; - phone: string | null; - postalCode: string; - streetAddress1: string; - streetAddress2: string; -} - -export interface OrderRelease_orderRelease_order_events_user { - __typename: "User"; - email: string; -} - -export interface OrderRelease_orderRelease_order_events { - __typename: "OrderEvent"; - id: string; - amount: number | null; - date: any | null; - email: string | null; - emailType: OrderEventsEmailsEnum | null; - message: string | null; - quantity: number | null; - type: OrderEventsEnum | null; - user: OrderRelease_orderRelease_order_events_user | null; -} - -export interface OrderRelease_orderRelease_order_fulfillments_lines_edges_node_orderLine_unitPrice_gross { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_fulfillments_lines_edges_node_orderLine_unitPrice_net { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_fulfillments_lines_edges_node_orderLine_unitPrice { - __typename: "TaxedMoney"; - gross: OrderRelease_orderRelease_order_fulfillments_lines_edges_node_orderLine_unitPrice_gross; - net: OrderRelease_orderRelease_order_fulfillments_lines_edges_node_orderLine_unitPrice_net; -} - -export interface OrderRelease_orderRelease_order_fulfillments_lines_edges_node_orderLine { - __typename: "OrderLine"; - id: string; - productName: string; - productSku: string; - quantity: number; - quantityFulfilled: number; - unitPrice: OrderRelease_orderRelease_order_fulfillments_lines_edges_node_orderLine_unitPrice | null; - thumbnailUrl: string | null; -} - -export interface OrderRelease_orderRelease_order_fulfillments_lines_edges_node { - __typename: "FulfillmentLine"; - id: string; - quantity: number; - orderLine: OrderRelease_orderRelease_order_fulfillments_lines_edges_node_orderLine | null; -} - -export interface OrderRelease_orderRelease_order_fulfillments_lines_edges { - __typename: "FulfillmentLineCountableEdge"; - node: OrderRelease_orderRelease_order_fulfillments_lines_edges_node; -} - -export interface OrderRelease_orderRelease_order_fulfillments_lines { - __typename: "FulfillmentLineCountableConnection"; - edges: OrderRelease_orderRelease_order_fulfillments_lines_edges[]; -} - -export interface OrderRelease_orderRelease_order_fulfillments { - __typename: "Fulfillment"; - id: string; - lines: OrderRelease_orderRelease_order_fulfillments_lines | null; - fulfillmentOrder: number; - status: FulfillmentStatus; - trackingNumber: string; -} - -export interface OrderRelease_orderRelease_order_lines_unitPrice_gross { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_lines_unitPrice_net { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_lines_unitPrice { - __typename: "TaxedMoney"; - gross: OrderRelease_orderRelease_order_lines_unitPrice_gross; - net: OrderRelease_orderRelease_order_lines_unitPrice_net; -} - -export interface OrderRelease_orderRelease_order_lines { - __typename: "OrderLine"; - id: string; - productName: string; - productSku: string; - quantity: number; - quantityFulfilled: number; - unitPrice: OrderRelease_orderRelease_order_lines_unitPrice | null; - thumbnailUrl: string | null; -} - -export interface OrderRelease_orderRelease_order_shippingAddress_country { - __typename: "CountryDisplay"; - code: string; - country: string; -} - -export interface OrderRelease_orderRelease_order_shippingAddress { - __typename: "Address"; - city: string; - cityArea: string; - companyName: string; - country: OrderRelease_orderRelease_order_shippingAddress_country; - countryArea: string; - firstName: string; - id: string; - lastName: string; - phone: string | null; - postalCode: string; - streetAddress1: string; - streetAddress2: string; -} - -export interface OrderRelease_orderRelease_order_shippingMethod { - __typename: "ShippingMethod"; - id: string; -} - -export interface OrderRelease_orderRelease_order_shippingPrice_gross { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_shippingPrice { - __typename: "TaxedMoney"; - gross: OrderRelease_orderRelease_order_shippingPrice_gross; -} - -export interface OrderRelease_orderRelease_order_subtotal_gross { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_subtotal { - __typename: "TaxedMoney"; - gross: OrderRelease_orderRelease_order_subtotal_gross; -} - -export interface OrderRelease_orderRelease_order_total_gross { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_total_tax { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_total { - __typename: "TaxedMoney"; - gross: OrderRelease_orderRelease_order_total_gross; - tax: OrderRelease_orderRelease_order_total_tax; -} - -export interface OrderRelease_orderRelease_order_totalAuthorized { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_totalCaptured { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_user { - __typename: "User"; - id: string; - email: string; -} - -export interface OrderRelease_orderRelease_order_availableShippingMethods_price { - __typename: "Money"; - amount: number; - currency: string; -} - -export interface OrderRelease_orderRelease_order_availableShippingMethods { - __typename: "ShippingMethod"; - id: string; - name: string; - price: OrderRelease_orderRelease_order_availableShippingMethods_price | null; -} - -export interface OrderRelease_orderRelease_order { - __typename: "Order"; - id: string; - billingAddress: OrderRelease_orderRelease_order_billingAddress | null; - created: any; - events: (OrderRelease_orderRelease_order_events | null)[] | null; - fulfillments: (OrderRelease_orderRelease_order_fulfillments | null)[]; - lines: (OrderRelease_orderRelease_order_lines | null)[]; - number: string | null; - paymentStatus: PaymentChargeStatusEnum | null; - shippingAddress: OrderRelease_orderRelease_order_shippingAddress | null; - shippingMethod: OrderRelease_orderRelease_order_shippingMethod | null; - shippingMethodName: string | null; - shippingPrice: OrderRelease_orderRelease_order_shippingPrice | null; - status: OrderStatus; - subtotal: OrderRelease_orderRelease_order_subtotal | null; - total: OrderRelease_orderRelease_order_total | null; - totalAuthorized: OrderRelease_orderRelease_order_totalAuthorized | null; - totalCaptured: OrderRelease_orderRelease_order_totalCaptured | null; - user: OrderRelease_orderRelease_order_user | null; - userEmail: string | null; - availableShippingMethods: (OrderRelease_orderRelease_order_availableShippingMethods | null)[] | null; -} - -export interface OrderRelease_orderRelease { - __typename: "OrderRelease"; - order: OrderRelease_orderRelease_order | null; -} - -export interface OrderRelease { - orderRelease: OrderRelease_orderRelease | null; -} - -export interface OrderReleaseVariables { - id: string; -} diff --git a/src/orders/types/OrderShippingMethods.ts b/src/orders/types/OrderShippingMethods.ts deleted file mode 100644 index 818adf916..000000000 --- a/src/orders/types/OrderShippingMethods.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* tslint:disable */ -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL query operation: OrderShippingMethods -// ==================================================== - -export interface OrderShippingMethods_shippingZones_edges_node_shippingMethods { - __typename: "ShippingMethod"; - id: string; - name: string; -} - -export interface OrderShippingMethods_shippingZones_edges_node { - __typename: "ShippingZone"; - shippingMethods: (OrderShippingMethods_shippingZones_edges_node_shippingMethods | null)[] | null; -} - -export interface OrderShippingMethods_shippingZones_edges { - __typename: "ShippingZoneCountableEdge"; - node: OrderShippingMethods_shippingZones_edges_node; -} - -export interface OrderShippingMethods_shippingZones { - __typename: "ShippingZoneCountableConnection"; - edges: OrderShippingMethods_shippingZones_edges[]; -} - -export interface OrderShippingMethods { - shippingZones: OrderShippingMethods_shippingZones | null; -} diff --git a/src/pages/components/PageDetailsPage/PageDetailsPage.tsx b/src/pages/components/PageDetailsPage/PageDetailsPage.tsx index a43e8161b..7c062a956 100644 --- a/src/pages/components/PageDetailsPage/PageDetailsPage.tsx +++ b/src/pages/components/PageDetailsPage/PageDetailsPage.tsx @@ -8,9 +8,9 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import SeoForm from "@saleor/components/SeoForm"; import VisibilityCard from "@saleor/components/VisibilityCard"; +import { PageErrorFragment } from "@saleor/fragments/types/PageErrorFragment"; import useDateLocalize from "@saleor/hooks/useDateLocalize"; import { sectionNames } from "@saleor/intl"; -import { PageErrorFragment } from "@saleor/pages/types/PageErrorFragment"; import { ContentState, convertFromRaw, diff --git a/src/pages/components/PageInfo/PageInfo.tsx b/src/pages/components/PageInfo/PageInfo.tsx index 908e65ede..c89a2883f 100644 --- a/src/pages/components/PageInfo/PageInfo.tsx +++ b/src/pages/components/PageInfo/PageInfo.tsx @@ -5,8 +5,8 @@ import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; import FormSpacer from "@saleor/components/FormSpacer"; import RichTextEditor from "@saleor/components/RichTextEditor"; +import { PageErrorFragment } from "@saleor/fragments/types/PageErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { PageErrorFragment } from "@saleor/pages/types/PageErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getPageErrorMessage from "@saleor/utils/errors/page"; import React from "react"; diff --git a/src/pages/components/PageSlug/PageSlug.tsx b/src/pages/components/PageSlug/PageSlug.tsx index 5b4ff55f6..256ddcfd4 100644 --- a/src/pages/components/PageSlug/PageSlug.tsx +++ b/src/pages/components/PageSlug/PageSlug.tsx @@ -2,7 +2,7 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; -import { PageErrorFragment } from "@saleor/pages/types/PageErrorFragment"; +import { PageErrorFragment } from "@saleor/fragments/types/PageErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getPageErrorMessage from "@saleor/utils/errors/page"; import React from "react"; diff --git a/src/pages/mutations.ts b/src/pages/mutations.ts index d5b55d325..9cc38a9c1 100644 --- a/src/pages/mutations.ts +++ b/src/pages/mutations.ts @@ -1,7 +1,8 @@ +import { pageErrorFragment } from "@saleor/fragments/errors"; +import { pageDetailsFragment } from "@saleor/fragments/pages"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { pageDetailsFragment } from "./queries"; import { PageBulkPublish, PageBulkPublishVariables @@ -14,13 +15,6 @@ import { PageCreate, PageCreateVariables } from "./types/PageCreate"; import { PageRemove, PageRemoveVariables } from "./types/PageRemove"; import { PageUpdate, PageUpdateVariables } from "./types/PageUpdate"; -const pageErrorFragment = gql` - fragment PageErrorFragment on PageError { - code - field - } -`; - const pageCreate = gql` ${pageDetailsFragment} ${pageErrorFragment} diff --git a/src/pages/queries.ts b/src/pages/queries.ts index 7cd2ae6db..8dd8618c6 100644 --- a/src/pages/queries.ts +++ b/src/pages/queries.ts @@ -1,3 +1,4 @@ +import { pageDetailsFragment, pageFragment } from "@saleor/fragments/pages"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; @@ -5,26 +6,6 @@ import { TypedQuery } from "../queries"; import { PageDetails, PageDetailsVariables } from "./types/PageDetails"; import { PageList, PageListVariables } from "./types/PageList"; -export const pageFragment = gql` - fragment PageFragment on Page { - id - title - slug - isPublished - } -`; - -export const pageDetailsFragment = gql` - ${pageFragment} - fragment PageDetailsFragment on Page { - ...PageFragment - contentJson - seoTitle - seoDescription - publicationDate - } -`; - const pageList = gql` ${pageFragment} query PageList( diff --git a/src/permissionGroups/components/PermissionGroupCreatePage/PermissionGroupCreatePage.tsx b/src/permissionGroups/components/PermissionGroupCreatePage/PermissionGroupCreatePage.tsx index 2ebb9bbda..8987a26a6 100644 --- a/src/permissionGroups/components/PermissionGroupCreatePage/PermissionGroupCreatePage.tsx +++ b/src/permissionGroups/components/PermissionGroupCreatePage/PermissionGroupCreatePage.tsx @@ -5,8 +5,8 @@ import Container from "@saleor/components/Container"; import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; +import { PermissionGroupErrorFragment } from "@saleor/fragments/types/PermissionGroupErrorFragment"; import { sectionNames } from "@saleor/intl"; -import { PermissionGroupErrorFragment } from "@saleor/permissionGroups/types/PermissionGroupErrorFragment"; import { PermissionEnum } from "@saleor/types/globalTypes"; import { getFormErrors } from "@saleor/utils/errors"; import getPermissionGroupErrorMessage from "@saleor/utils/errors/permissionGroups"; diff --git a/src/permissionGroups/components/PermissionGroupDeleteDialog/PermissionGroupDeleteDialog.stories.tsx b/src/permissionGroups/components/PermissionGroupDeleteDialog/PermissionGroupDeleteDialog.stories.tsx index 6a15328c9..37671be5b 100644 --- a/src/permissionGroups/components/PermissionGroupDeleteDialog/PermissionGroupDeleteDialog.stories.tsx +++ b/src/permissionGroups/components/PermissionGroupDeleteDialog/PermissionGroupDeleteDialog.stories.tsx @@ -1,7 +1,7 @@ +import { PermissionGroupErrorFragment } from "@saleor/fragments/types/PermissionGroupErrorFragment"; import PermissionGroupDeleteDialog, { PermissionDeleteDialogProps } from "@saleor/permissionGroups/components/PermissionGroupDeleteDialog"; -import { PermissionGroupErrorFragment } from "@saleor/permissionGroups/types/PermissionGroupErrorFragment"; import Decorator from "@saleor/storybook/Decorator"; import { PermissionGroupErrorCode } from "@saleor/types/globalTypes"; import { storiesOf } from "@storybook/react"; diff --git a/src/permissionGroups/components/PermissionGroupDeleteDialog/PermissionGroupDeleteDialog.tsx b/src/permissionGroups/components/PermissionGroupDeleteDialog/PermissionGroupDeleteDialog.tsx index 20742f30d..a1193db15 100644 --- a/src/permissionGroups/components/PermissionGroupDeleteDialog/PermissionGroupDeleteDialog.tsx +++ b/src/permissionGroups/components/PermissionGroupDeleteDialog/PermissionGroupDeleteDialog.tsx @@ -2,7 +2,7 @@ import { Typography } from "@material-ui/core"; import DialogContentText from "@material-ui/core/DialogContentText"; import ActionDialog from "@saleor/components/ActionDialog"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; -import { PermissionGroupErrorFragment } from "@saleor/permissionGroups/types/PermissionGroupErrorFragment"; +import { PermissionGroupErrorFragment } from "@saleor/fragments/types/PermissionGroupErrorFragment"; import { PermissionGroupErrorCode } from "@saleor/types/globalTypes"; import getPermissionGroupErrorMessage from "@saleor/utils/errors/permissionGroups"; import React from "react"; diff --git a/src/permissionGroups/components/PermissionGroupDetailsPage/PermissionGroupDetailsPage.tsx b/src/permissionGroups/components/PermissionGroupDetailsPage/PermissionGroupDetailsPage.tsx index d941c3a6f..996afa327 100644 --- a/src/permissionGroups/components/PermissionGroupDetailsPage/PermissionGroupDetailsPage.tsx +++ b/src/permissionGroups/components/PermissionGroupDetailsPage/PermissionGroupDetailsPage.tsx @@ -8,8 +8,8 @@ import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo"; +import { PermissionGroupErrorFragment } from "@saleor/fragments/types/PermissionGroupErrorFragment"; import { sectionNames } from "@saleor/intl"; -import { PermissionGroupErrorFragment } from "@saleor/permissionGroups/types/PermissionGroupErrorFragment"; import { MembersListUrlSortField } from "@saleor/permissionGroups/urls"; import { extractPermissionCodes, diff --git a/src/permissionGroups/components/PermissionGroupInfo/PermissionGroupInfo.tsx b/src/permissionGroups/components/PermissionGroupInfo/PermissionGroupInfo.tsx index 195d94af5..ec64abc6f 100644 --- a/src/permissionGroups/components/PermissionGroupInfo/PermissionGroupInfo.tsx +++ b/src/permissionGroups/components/PermissionGroupInfo/PermissionGroupInfo.tsx @@ -2,9 +2,9 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; +import { PermissionGroupErrorFragment } from "@saleor/fragments/types/PermissionGroupErrorFragment"; import { FormChange } from "@saleor/hooks/useForm"; import { commonMessages } from "@saleor/intl"; -import { PermissionGroupErrorFragment } from "@saleor/permissionGroups/types/PermissionGroupErrorFragment"; import { getFieldError, getFormErrors } from "@saleor/utils/errors"; import getPermissionGroupErrorMessage from "@saleor/utils/errors/permissionGroups"; import React from "react"; diff --git a/src/permissionGroups/fixtures.ts b/src/permissionGroups/fixtures.ts index 51f5b5ca3..f0e1e3b5b 100644 --- a/src/permissionGroups/fixtures.ts +++ b/src/permissionGroups/fixtures.ts @@ -1,4 +1,5 @@ import * as avatarImg from "@assets/images/avatars/avatar1.png"; +import { PermissionGroupErrorFragment } from "@saleor/fragments/types/PermissionGroupErrorFragment"; import { SearchStaffMembers_search_edges_node } from "@saleor/searches/types/SearchStaffMembers"; import { StaffMemberDetails_user_permissionGroups } from "@saleor/staff/types/StaffMemberDetails"; /* eslint-disable sort-keys */ @@ -8,7 +9,6 @@ import { } from "@saleor/types/globalTypes"; import { PermissionGroupDetails_permissionGroup } from "./types/PermissionGroupDetails"; -import { PermissionGroupErrorFragment } from "./types/PermissionGroupErrorFragment"; import { PermissionGroupList_permissionGroups_edges_node } from "./types/PermissionGroupList"; export const permissionGroups: PermissionGroupList_permissionGroups_edges_node[] = [ diff --git a/src/permissionGroups/mutations.ts b/src/permissionGroups/mutations.ts index 0d6ef8ae8..4ec5356d1 100644 --- a/src/permissionGroups/mutations.ts +++ b/src/permissionGroups/mutations.ts @@ -1,7 +1,8 @@ +import { permissionGroupErrorFragment } from "@saleor/fragments/errors"; +import { permissionGroupDetailsFragment } from "@saleor/fragments/permissionGroups"; import makeMutation from "@saleor/hooks/makeMutation"; import gql from "graphql-tag"; -import { permissionGroupDetailsFragment } from "./queries"; import { PermissionGroupCreate, PermissionGroupCreateVariables @@ -15,13 +16,6 @@ import { PermissionGroupUpdateVariables } from "./types/PermissionGroupUpdate"; -export const permissionGroupErrorFragment = gql` - fragment PermissionGroupErrorFragment on PermissionGroupError { - code - field - } -`; - export const permissionGroupDelete = gql` ${permissionGroupErrorFragment} mutation PermissionGroupDelete($id: ID!) { diff --git a/src/permissionGroups/queries.ts b/src/permissionGroups/queries.ts index 7bafcfd57..927032edf 100644 --- a/src/permissionGroups/queries.ts +++ b/src/permissionGroups/queries.ts @@ -1,8 +1,11 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; +import { + permissionGroupDetailsFragment, + permissionGroupFragment +} from "@saleor/fragments/permissionGroups"; import makeQuery from "@saleor/hooks/makeQuery"; -import { staffMemberFragment } from "@saleor/staff/queries"; import gql from "graphql-tag"; -import { pageInfoFragment } from "../queries"; import { PermissionGroupDetails, PermissionGroupDetailsVariables @@ -11,40 +14,6 @@ import { PermissionGroupList, PermissionGroupListVariables } from "./types/PermissionGroupList"; -export const permissionGroupFragment = gql` - fragment PermissionGroupFragment on Group { - id - name - userCanManage - users { - id - firstName - lastName - } - } -`; - -export const permissionFragment = gql` - fragment PermissionFragment on Permission { - code - name - } -`; - -export const permissionGroupDetailsFragment = gql` - ${permissionGroupFragment} - ${permissionFragment} - ${staffMemberFragment} - fragment PermissionGroupDetailsFragment on Group { - ...PermissionGroupFragment - permissions { - ...PermissionFragment - } - users { - ...StaffMemberFragment - } - } -`; export const permissionGroupListQuery = gql` ${pageInfoFragment} diff --git a/src/permissionGroups/utils.ts b/src/permissionGroups/utils.ts index 50f251ef9..b924f1cd9 100644 --- a/src/permissionGroups/utils.ts +++ b/src/permissionGroups/utils.ts @@ -1,5 +1,5 @@ -import { User } from "@saleor/auth/types/User"; import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo"; +import { User } from "@saleor/fragments/types/User"; import difference from "lodash-es/difference"; import { PermissionGroupDetailsPageFormData } from "./components/PermissionGroupDetailsPage"; diff --git a/src/permissionGroups/views/PermissionGroupList/PermissionGroupList.tsx b/src/permissionGroups/views/PermissionGroupList/PermissionGroupList.tsx index 93b7f3361..b696f2557 100644 --- a/src/permissionGroups/views/PermissionGroupList/PermissionGroupList.tsx +++ b/src/permissionGroups/views/PermissionGroupList/PermissionGroupList.tsx @@ -1,4 +1,5 @@ import { configurationMenuUrl } from "@saleor/configuration"; +import { PermissionGroupErrorFragment } from "@saleor/fragments/types/PermissionGroupErrorFragment"; import useListSettings from "@saleor/hooks/useListSettings"; import useNavigator from "@saleor/hooks/useNavigator"; import useNotifier from "@saleor/hooks/useNotifier"; @@ -10,7 +11,6 @@ import PermissionGroupDeleteDialog from "@saleor/permissionGroups/components/Per import { usePermissionGroupDelete } from "@saleor/permissionGroups/mutations"; import { usePermissionGroupListQuery } from "@saleor/permissionGroups/queries"; import { PermissionGroupDelete } from "@saleor/permissionGroups/types/PermissionGroupDelete"; -import { PermissionGroupErrorFragment } from "@saleor/permissionGroups/types/PermissionGroupErrorFragment"; import { ListViews } from "@saleor/types"; import createDialogActionHandlers from "@saleor/utils/handlers/dialogActionHandlers"; import createSortHandler from "@saleor/utils/handlers/sortHandler"; diff --git a/src/plugins/mutations.ts b/src/plugins/mutations.ts index 9a23fada4..0d073c06e 100644 --- a/src/plugins/mutations.ts +++ b/src/plugins/mutations.ts @@ -1,7 +1,7 @@ +import { pluginsDetailsFragment } from "@saleor/fragments/plugins"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { pluginsDetailsFragment } from "./queries"; import { PluginUpdate, PluginUpdateVariables } from "./types/PluginUpdate"; const pluginUpdate = gql` diff --git a/src/plugins/queries.ts b/src/plugins/queries.ts index 903600dba..801d8436f 100644 --- a/src/plugins/queries.ts +++ b/src/plugins/queries.ts @@ -1,3 +1,7 @@ +import { + pluginsDetailsFragment, + pluginsFragment +} from "@saleor/fragments/plugins"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; @@ -5,29 +9,6 @@ import { TypedQuery } from "../queries"; import { Plugin, PluginVariables } from "./types/Plugin"; import { Plugins, PluginsVariables } from "./types/Plugins"; -export const pluginsFragment = gql` - fragment PluginFragment on Plugin { - id - name - description - active - } -`; - -export const pluginsDetailsFragment = gql` - ${pluginsFragment} - fragment PluginsDetailsFragment on Plugin { - ...PluginFragment - configuration { - name - type - value - helpText - label - } - } -`; - const pluginsList = gql` ${pluginsFragment} query Plugins( diff --git a/src/productTypes/containers/ProductTypeOperations.tsx b/src/productTypes/containers/ProductTypeOperations.tsx index 085073df2..15798e127 100644 --- a/src/productTypes/containers/ProductTypeOperations.tsx +++ b/src/productTypes/containers/ProductTypeOperations.tsx @@ -1,3 +1,7 @@ +import { + ProductTypeDetailsFragment, + ProductTypeDetailsFragment_productAttributes +} from "@saleor/fragments/types/ProductTypeDetailsFragment"; import { AttributeTypeEnum, ReorderInput } from "@saleor/types/globalTypes"; import React from "react"; import { MutationFunction } from "react-apollo"; @@ -23,10 +27,6 @@ import { ProductTypeDelete, ProductTypeDeleteVariables } from "../types/ProductTypeDelete"; -import { - ProductTypeDetailsFragment, - ProductTypeDetailsFragment_productAttributes -} from "../types/ProductTypeDetailsFragment"; import { ProductTypeUpdate, ProductTypeUpdateVariables @@ -37,9 +37,7 @@ import { } from "../types/UnassignAttribute"; function moveAttribute( - attributes: - | ProductTypeDetailsFragment_productAttributes[] - | ProductTypeDetailsFragment_productAttributes[], + attributes: ProductTypeDetailsFragment_productAttributes[], move: ReorderInput ) { const attributeIndex = attributes.findIndex( diff --git a/src/productTypes/hooks/useAvailableAttributeSearch/index.tsx b/src/productTypes/hooks/useAvailableAttributeSearch/index.tsx index cf15ab33a..0aa5830da 100644 --- a/src/productTypes/hooks/useAvailableAttributeSearch/index.tsx +++ b/src/productTypes/hooks/useAvailableAttributeSearch/index.tsx @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeSearch from "@saleor/hooks/makeSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { diff --git a/src/productTypes/mutations.ts b/src/productTypes/mutations.ts index 7d103d756..b7c9fcc28 100644 --- a/src/productTypes/mutations.ts +++ b/src/productTypes/mutations.ts @@ -1,7 +1,7 @@ +import { productTypeDetailsFragment } from "@saleor/fragments/productTypes"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { productTypeDetailsFragment } from "./queries"; import { AssignAttribute, AssignAttributeVariables diff --git a/src/productTypes/queries.ts b/src/productTypes/queries.ts index f7381809d..d0d289d0e 100644 --- a/src/productTypes/queries.ts +++ b/src/productTypes/queries.ts @@ -1,8 +1,12 @@ -import { attributeFragment } from "@saleor/attributes/queries"; +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; +import { + productTypeDetailsFragment, + productTypeFragment +} from "@saleor/fragments/productTypes"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; -import { pageInfoFragment, TypedQuery } from "../queries"; +import { TypedQuery } from "../queries"; import { ProductTypeCreateData } from "./types/ProductTypeCreateData"; import { ProductTypeDetails, @@ -13,37 +17,6 @@ import { ProductTypeListVariables } from "./types/ProductTypeList"; -export const productTypeFragment = gql` - fragment ProductTypeFragment on ProductType { - id - name - hasVariants - isShippingRequired - taxType { - description - taxCode - } - } -`; - -export const productTypeDetailsFragment = gql` - ${attributeFragment} - ${productTypeFragment} - fragment ProductTypeDetailsFragment on ProductType { - ...ProductTypeFragment - productAttributes { - ...AttributeFragment - } - variantAttributes { - ...AttributeFragment - } - weight { - unit - value - } - } -`; - export const productTypeListQuery = gql` ${pageInfoFragment} ${productTypeFragment} diff --git a/src/productTypes/types/AttributeCreate.ts b/src/productTypes/types/AttributeCreate.ts deleted file mode 100644 index 63548a3bc..000000000 --- a/src/productTypes/types/AttributeCreate.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// This file was automatically generated and should not be edited. - -import { AttributeCreateInput, AttributeTypeEnum, TaxRateType } from "./../../types/globalTypes"; - -// ==================================================== -// GraphQL mutation operation: AttributeCreate -// ==================================================== - -export interface AttributeCreate_attributeCreate_errors { - __typename: "Error"; - field: string | null; - message: string | null; -} - -export interface AttributeCreate_attributeCreate_productType_productAttributes_values { - __typename: "AttributeValue"; - id: string; - name: string | null; - slug: string | null; -} - -export interface AttributeCreate_attributeCreate_productType_productAttributes { - __typename: "Attribute"; - id: string; - name: string | null; - slug: string | null; - values: (AttributeCreate_attributeCreate_productType_productAttributes_values | null)[] | null; -} - -export interface AttributeCreate_attributeCreate_productType_variantAttributes_values { - __typename: "AttributeValue"; - id: string; - name: string | null; - slug: string | null; -} - -export interface AttributeCreate_attributeCreate_productType_variantAttributes { - __typename: "Attribute"; - id: string; - name: string | null; - slug: string | null; - values: (AttributeCreate_attributeCreate_productType_variantAttributes_values | null)[] | null; -} - -export interface AttributeCreate_attributeCreate_productType_weight { - __typename: "Weight"; - unit: string; - value: number; -} - -export interface AttributeCreate_attributeCreate_productType { - __typename: "ProductType"; - id: string; - name: string; - hasVariants: boolean; - isShippingRequired: boolean; - taxRate: TaxRateType | null; - productAttributes: (AttributeCreate_attributeCreate_productType_productAttributes | null)[] | null; - variantAttributes: (AttributeCreate_attributeCreate_productType_variantAttributes | null)[] | null; - weight: AttributeCreate_attributeCreate_productType_weight | null; -} - -export interface AttributeCreate_attributeCreate { - __typename: "AttributeCreate"; - errors: AttributeCreate_attributeCreate_errors[] | null; - productType: AttributeCreate_attributeCreate_productType | null; -} - -export interface AttributeCreate { - attributeCreate: AttributeCreate_attributeCreate | null; -} - -export interface AttributeCreateVariables { - id: string; - input: AttributeCreateInput; - type: AttributeTypeEnum; -} diff --git a/src/productTypes/types/AttributeDelete.ts b/src/productTypes/types/AttributeDelete.ts deleted file mode 100644 index f62cd728f..000000000 --- a/src/productTypes/types/AttributeDelete.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// This file was automatically generated and should not be edited. - -import { TaxRateType } from "./../../types/globalTypes"; - -// ==================================================== -// GraphQL mutation operation: AttributeDelete -// ==================================================== - -export interface AttributeDelete_attributeDelete_errors { - __typename: "Error"; - field: string | null; - message: string | null; -} - -export interface AttributeDelete_attributeDelete_productType_productAttributes_values { - __typename: "AttributeValue"; - id: string; - name: string | null; - slug: string | null; -} - -export interface AttributeDelete_attributeDelete_productType_productAttributes { - __typename: "Attribute"; - id: string; - name: string | null; - slug: string | null; - values: (AttributeDelete_attributeDelete_productType_productAttributes_values | null)[] | null; -} - -export interface AttributeDelete_attributeDelete_productType_variantAttributes_values { - __typename: "AttributeValue"; - id: string; - name: string | null; - slug: string | null; -} - -export interface AttributeDelete_attributeDelete_productType_variantAttributes { - __typename: "Attribute"; - id: string; - name: string | null; - slug: string | null; - values: (AttributeDelete_attributeDelete_productType_variantAttributes_values | null)[] | null; -} - -export interface AttributeDelete_attributeDelete_productType_weight { - __typename: "Weight"; - unit: string; - value: number; -} - -export interface AttributeDelete_attributeDelete_productType { - __typename: "ProductType"; - id: string; - name: string; - hasVariants: boolean; - isShippingRequired: boolean; - taxRate: TaxRateType | null; - productAttributes: (AttributeDelete_attributeDelete_productType_productAttributes | null)[] | null; - variantAttributes: (AttributeDelete_attributeDelete_productType_variantAttributes | null)[] | null; - weight: AttributeDelete_attributeDelete_productType_weight | null; -} - -export interface AttributeDelete_attributeDelete { - __typename: "AttributeDelete"; - errors: AttributeDelete_attributeDelete_errors[] | null; - productType: AttributeDelete_attributeDelete_productType | null; -} - -export interface AttributeDelete { - attributeDelete: AttributeDelete_attributeDelete | null; -} - -export interface AttributeDeleteVariables { - id: string; -} diff --git a/src/productTypes/types/AttributeFragment.ts b/src/productTypes/types/AttributeFragment.ts deleted file mode 100644 index 35a35464f..000000000 --- a/src/productTypes/types/AttributeFragment.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL fragment: AttributeFragment -// ==================================================== - -export interface AttributeFragment_values { - __typename: "AttributeValue"; - id: string; - name: string | null; - slug: string | null; -} - -export interface AttributeFragment { - __typename: "Attribute"; - id: string; - name: string | null; - slug: string | null; - values: (AttributeFragment_values | null)[] | null; -} diff --git a/src/productTypes/types/AttributeUpdate.ts b/src/productTypes/types/AttributeUpdate.ts deleted file mode 100644 index 08245fd55..000000000 --- a/src/productTypes/types/AttributeUpdate.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// This file was automatically generated and should not be edited. - -import { AttributeUpdateInput } from "./../../types/globalTypes"; - -// ==================================================== -// GraphQL mutation operation: AttributeUpdate -// ==================================================== - -export interface AttributeUpdate_attributeUpdate_errors { - __typename: "Error"; - field: string | null; - message: string | null; -} - -export interface AttributeUpdate_attributeUpdate_attribute_values { - __typename: "AttributeValue"; - id: string; - name: string | null; - slug: string | null; -} - -export interface AttributeUpdate_attributeUpdate_attribute { - __typename: "Attribute"; - id: string; - name: string | null; - slug: string | null; - values: (AttributeUpdate_attributeUpdate_attribute_values | null)[] | null; -} - -export interface AttributeUpdate_attributeUpdate { - __typename: "AttributeUpdate"; - errors: AttributeUpdate_attributeUpdate_errors[] | null; - attribute: AttributeUpdate_attributeUpdate_attribute | null; -} - -export interface AttributeUpdate { - attributeUpdate: AttributeUpdate_attributeUpdate | null; -} - -export interface AttributeUpdateVariables { - id: string; - input: AttributeUpdateInput; -} diff --git a/src/products/components/ProductCreatePage/ProductCreatePage.tsx b/src/products/components/ProductCreatePage/ProductCreatePage.tsx index 19a017726..97d965e91 100644 --- a/src/products/components/ProductCreatePage/ProductCreatePage.tsx +++ b/src/products/components/ProductCreatePage/ProductCreatePage.tsx @@ -1,4 +1,3 @@ -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import AppHeader from "@saleor/components/AppHeader"; import CardSpacer from "@saleor/components/CardSpacer"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; @@ -10,6 +9,7 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import SeoForm from "@saleor/components/SeoForm"; import VisibilityCard from "@saleor/components/VisibilityCard"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import useDateLocalize from "@saleor/hooks/useDateLocalize"; import useFormset from "@saleor/hooks/useFormset"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; diff --git a/src/products/components/ProductDetailsForm/ProductDetailsForm.tsx b/src/products/components/ProductDetailsForm/ProductDetailsForm.tsx index bce9d852c..aac585345 100644 --- a/src/products/components/ProductDetailsForm/ProductDetailsForm.tsx +++ b/src/products/components/ProductDetailsForm/ProductDetailsForm.tsx @@ -1,10 +1,10 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import CardTitle from "@saleor/components/CardTitle"; import FormSpacer from "@saleor/components/FormSpacer"; import RichTextEditor from "@saleor/components/RichTextEditor"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { commonMessages } from "@saleor/intl"; import { getFormErrors, getProductErrorMessage } from "@saleor/utils/errors"; import { RawDraftContentState } from "draft-js"; diff --git a/src/products/components/ProductList/ProductList.tsx b/src/products/components/ProductList/ProductList.tsx index db60cc5f0..0a163a684 100644 --- a/src/products/components/ProductList/ProductList.tsx +++ b/src/products/components/ProductList/ProductList.tsx @@ -21,7 +21,7 @@ import { getAttributeIdFromColumnValue, isAttributeColumnValue } from "@saleor/products/components/ProductListPage/utils"; -import { AvailableInGridAttributes_grid_edges_node } from "@saleor/products/types/AvailableInGridAttributes"; +import { GridAttributes_grid_edges_node } from "@saleor/products/types/GridAttributes"; import { ProductList_products_edges_node, ProductList_products_edges_node_pricing_priceRangeUndiscounted @@ -104,7 +104,7 @@ interface ProductListProps ListActions, SortPage { activeAttributeSortId: string; - gridAttributes: AvailableInGridAttributes_grid_edges_node[]; + gridAttributes: GridAttributes_grid_edges_node[]; products: ProductList_products_edges_node[]; } diff --git a/src/products/components/ProductListPage/ProductListPage.tsx b/src/products/components/ProductListPage/ProductListPage.tsx index 37a2fa8d9..6652fc6bd 100644 --- a/src/products/components/ProductListPage/ProductListPage.tsx +++ b/src/products/components/ProductListPage/ProductListPage.tsx @@ -10,9 +10,9 @@ import PageHeader from "@saleor/components/PageHeader"; import { ProductListColumns } from "@saleor/config"; import { sectionNames } from "@saleor/intl"; import { - AvailableInGridAttributes_availableInGrid_edges_node, - AvailableInGridAttributes_grid_edges_node -} from "@saleor/products/types/AvailableInGridAttributes"; + GridAttributes_availableInGrid_edges_node, + GridAttributes_grid_edges_node +} from "@saleor/products/types/GridAttributes"; import { ProductList_products_edges_node } from "@saleor/products/types/ProductList"; import { FetchMoreProps, @@ -39,9 +39,9 @@ export interface ProductListPageProps FetchMoreProps, SortPage { activeAttributeSortId: string; - availableInGridAttributes: AvailableInGridAttributes_availableInGrid_edges_node[]; + availableInGridAttributes: GridAttributes_availableInGrid_edges_node[]; currencySymbol: string; - gridAttributes: AvailableInGridAttributes_grid_edges_node[]; + gridAttributes: GridAttributes_grid_edges_node[]; totalGridAttributes: number; products: ProductList_products_edges_node[]; } diff --git a/src/products/components/ProductOrganization/ProductOrganization.tsx b/src/products/components/ProductOrganization/ProductOrganization.tsx index b6d400ba2..123ebeb7c 100644 --- a/src/products/components/ProductOrganization/ProductOrganization.tsx +++ b/src/products/components/ProductOrganization/ProductOrganization.tsx @@ -2,7 +2,6 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import { makeStyles } from "@material-ui/core/styles"; import Typography from "@material-ui/core/Typography"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import CardSpacer from "@saleor/components/CardSpacer"; import CardTitle from "@saleor/components/CardTitle"; import { FormSpacer } from "@saleor/components/FormSpacer"; @@ -13,6 +12,7 @@ import MultiAutocompleteSelectField, { import SingleAutocompleteSelectField, { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { ChangeEvent } from "@saleor/hooks/useForm"; import { maybe } from "@saleor/misc"; import { FetchMoreProps } from "@saleor/types"; diff --git a/src/products/components/ProductPricing/ProductPricing.tsx b/src/products/components/ProductPricing/ProductPricing.tsx index c7e7ee5ed..c51119e69 100644 --- a/src/products/components/ProductPricing/ProductPricing.tsx +++ b/src/products/components/ProductPricing/ProductPricing.tsx @@ -1,10 +1,10 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import { makeStyles } from "@material-ui/core/styles"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import CardTitle from "@saleor/components/CardTitle"; import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; import PriceField from "@saleor/components/PriceField"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { getFormErrors, getProductErrorMessage } from "@saleor/utils/errors"; import React from "react"; import { useIntl } from "react-intl"; diff --git a/src/products/components/ProductStocks/ProductStocks.tsx b/src/products/components/ProductStocks/ProductStocks.tsx index 189da0a71..1ab107907 100644 --- a/src/products/components/ProductStocks/ProductStocks.tsx +++ b/src/products/components/ProductStocks/ProductStocks.tsx @@ -21,13 +21,13 @@ import CardTitle from "@saleor/components/CardTitle"; import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; import FormSpacer from "@saleor/components/FormSpacer"; import Hr from "@saleor/components/Hr"; +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import { FormChange } from "@saleor/hooks/useForm"; import { FormsetAtomicData, FormsetChange } from "@saleor/hooks/useFormset"; import { renderCollection } from "@saleor/misc"; import { ICONBUTTON_SIZE } from "@saleor/theme"; import { UserError } from "@saleor/types"; import { getFieldError } from "@saleor/utils/errors"; -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx b/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx index ec2d7df57..eff25a7c5 100644 --- a/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx +++ b/src/products/components/ProductUpdatePage/ProductUpdatePage.tsx @@ -1,4 +1,3 @@ -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import AppHeader from "@saleor/components/AppHeader"; import CardSpacer from "@saleor/components/CardSpacer"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; @@ -9,6 +8,8 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import SeoForm from "@saleor/components/SeoForm"; import VisibilityCard from "@saleor/components/VisibilityCard"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import useDateLocalize from "@saleor/hooks/useDateLocalize"; import useFormset from "@saleor/hooks/useFormset"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; @@ -19,7 +20,6 @@ import { SearchCollections_search_edges_node } from "@saleor/searches/types/Sear import { FetchMoreProps, ListActions } from "@saleor/types"; import createMultiAutocompleteSelectHandler from "@saleor/utils/handlers/multiAutocompleteSelectChangeHandler"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import { convertFromRaw, RawDraftContentState } from "draft-js"; import { diff } from "fast-array-diff"; import React from "react"; diff --git a/src/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx b/src/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx index 02c561c82..40890e58e 100644 --- a/src/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx +++ b/src/products/components/ProductVariantAttributes/ProductVariantAttributes.tsx @@ -8,6 +8,7 @@ import SingleAutocompleteSelectField, { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; import Skeleton from "@saleor/components/Skeleton"; +import { ProductVariant_attributes_attribute_values } from "@saleor/fragments/types/ProductVariant"; import { FormsetAtomicData, FormsetChange } from "@saleor/hooks/useFormset"; import { commonMessages } from "@saleor/intl"; import { VariantCreate_productVariantCreate_errors } from "@saleor/products/types/VariantCreate"; @@ -15,8 +16,6 @@ import { ProductErrorCode } from "@saleor/types/globalTypes"; import React from "react"; import { IntlShape, useIntl } from "react-intl"; -import { ProductVariant_attributes_attribute_values } from "../../types/ProductVariant"; - export interface VariantAttributeInputData { values: ProductVariant_attributes_attribute_values[]; } diff --git a/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx b/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx index 7af12ed0b..d4df87e0d 100644 --- a/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx +++ b/src/products/components/ProductVariantCreatePage/ProductVariantCreatePage.tsx @@ -1,4 +1,3 @@ -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import AppHeader from "@saleor/components/AppHeader"; import CardSpacer from "@saleor/components/CardSpacer"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; @@ -7,6 +6,7 @@ import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import useFormset, { FormsetChange, FormsetData diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx index 0451ee6cd..9919e5a3f 100644 --- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx +++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorContent.tsx @@ -1,7 +1,7 @@ +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import { ProductDetails_product_productType_variantAttributes } from "@saleor/products/types/ProductDetails"; import { ProductVariantBulkCreate_productVariantBulkCreate_errors } from "@saleor/products/types/ProductVariantBulkCreate"; import { isSelected } from "@saleor/utils/lists"; -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import React from "react"; import { ProductVariantCreateFormData } from "./form"; diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPriceAndSku.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPriceAndSku.tsx index b3f72a6f3..79b0a7324 100644 --- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPriceAndSku.tsx +++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorPriceAndSku.tsx @@ -1,6 +1,6 @@ import CardSpacer from "@saleor/components/CardSpacer"; +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import { ProductDetails_product_productType_variantAttributes } from "@saleor/products/types/ProductDetails"; -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import React from "react"; import { diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorStock.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorStock.tsx index a2d0a1bac..51770851a 100644 --- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorStock.tsx +++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorStock.tsx @@ -12,9 +12,9 @@ import ControlledCheckbox from "@saleor/components/ControlledCheckbox"; import FormSpacer from "@saleor/components/FormSpacer"; import Hr from "@saleor/components/Hr"; import SingleSelectField from "@saleor/components/SingleSelectField"; +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import { ProductDetails_product_productType_variantAttributes } from "@saleor/products/types/ProductDetails"; import { isSelected } from "@saleor/utils/lists"; -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorSummary.tsx b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorSummary.tsx index 8bc54a78b..904a2e181 100644 --- a/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorSummary.tsx +++ b/src/products/components/ProductVariantCreatorPage/ProductVariantCreatorSummary.tsx @@ -10,11 +10,11 @@ import TextField from "@material-ui/core/TextField"; import DeleteIcon from "@material-ui/icons/Delete"; import CardTitle from "@saleor/components/CardTitle"; import Hr from "@saleor/components/Hr"; +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import { ProductVariantBulkCreate_productVariantBulkCreate_errors } from "@saleor/products/types/ProductVariantBulkCreate"; import { ProductVariantBulkCreateInput } from "@saleor/types/globalTypes"; import { getFormErrors } from "@saleor/utils/errors"; import { getBulkProductErrorMessage } from "@saleor/utils/errors/product"; -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import classNames from "classnames"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/products/components/ProductVariantCreatorPage/fixtures.ts b/src/products/components/ProductVariantCreatorPage/fixtures.ts index 0fb07ede9..c0878f527 100644 --- a/src/products/components/ProductVariantCreatorPage/fixtures.ts +++ b/src/products/components/ProductVariantCreatorPage/fixtures.ts @@ -1,4 +1,4 @@ -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import { createVariants } from "./createVariants"; import { diff --git a/src/products/components/ProductVariantCreatorPage/form.ts b/src/products/components/ProductVariantCreatorPage/form.ts index 8b80e9d46..1622dd86e 100644 --- a/src/products/components/ProductVariantCreatorPage/form.ts +++ b/src/products/components/ProductVariantCreatorPage/form.ts @@ -1,5 +1,5 @@ +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import { ProductDetails_product_productType_variantAttributes } from "@saleor/products/types/ProductDetails"; -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import { ProductVariantBulkCreateInput } from "../../../types/globalTypes"; diff --git a/src/products/components/ProductVariantImageSelectDialog/ProductVariantImageSelectDialog.tsx b/src/products/components/ProductVariantImageSelectDialog/ProductVariantImageSelectDialog.tsx index 4d59ac08d..97606ee2b 100644 --- a/src/products/components/ProductVariantImageSelectDialog/ProductVariantImageSelectDialog.tsx +++ b/src/products/components/ProductVariantImageSelectDialog/ProductVariantImageSelectDialog.tsx @@ -4,13 +4,12 @@ import DialogActions from "@material-ui/core/DialogActions"; import DialogContent from "@material-ui/core/DialogContent"; import DialogTitle from "@material-ui/core/DialogTitle"; import { makeStyles } from "@material-ui/core/styles"; +import { ProductImageFragment } from "@saleor/fragments/types/ProductImageFragment"; import { buttonMessages } from "@saleor/intl"; import classNames from "classnames"; import React from "react"; import { FormattedMessage } from "react-intl"; -import { ProductImage } from "../../types/ProductImage"; - const useStyles = makeStyles( theme => ({ image: { @@ -49,7 +48,7 @@ const useStyles = makeStyles( ); interface ProductVariantImageSelectDialogProps { - images?: ProductImage[]; + images?: ProductImageFragment[]; selectedImages?: string[]; open: boolean; onClose(); diff --git a/src/products/components/ProductVariantImages/ProductVariantImages.tsx b/src/products/components/ProductVariantImages/ProductVariantImages.tsx index 55738c30c..2ac624c68 100644 --- a/src/products/components/ProductVariantImages/ProductVariantImages.tsx +++ b/src/products/components/ProductVariantImages/ProductVariantImages.tsx @@ -5,11 +5,10 @@ import { makeStyles } from "@material-ui/core/styles"; import Typography from "@material-ui/core/Typography"; import CardTitle from "@saleor/components/CardTitle"; import Skeleton from "@saleor/components/Skeleton"; +import { ProductImageFragment } from "@saleor/fragments/types/ProductImageFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; -import { ProductImage } from "../../types/ProductImage"; - const useStyles = makeStyles( theme => ({ gridElement: { @@ -43,7 +42,7 @@ const useStyles = makeStyles( ); interface ProductVariantImagesProps { - images?: ProductImage[]; + images?: ProductImageFragment[]; placeholderImage?: string; disabled: boolean; onImageAdd(); diff --git a/src/products/components/ProductVariantPage/ProductVariantPage.tsx b/src/products/components/ProductVariantPage/ProductVariantPage.tsx index a1d66af03..95af691a3 100644 --- a/src/products/components/ProductVariantPage/ProductVariantPage.tsx +++ b/src/products/components/ProductVariantPage/ProductVariantPage.tsx @@ -6,6 +6,8 @@ import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; +import { ProductVariant } from "@saleor/fragments/types/ProductVariant"; +import { WarehouseFragment } from "@saleor/fragments/types/WarehouseFragment"; import useFormset, { FormsetChange, FormsetData @@ -15,12 +17,10 @@ import { getAttributeInputFromVariant, getStockInputFromVariant } from "@saleor/products/utils/data"; -import { WarehouseFragment } from "@saleor/warehouses/types/WarehouseFragment"; import { diff } from "fast-array-diff"; import React from "react"; import { maybe } from "../../../misc"; -import { ProductVariant } from "../../types/ProductVariant"; import ProductStocks, { ProductStockInput } from "../ProductStocks"; import ProductVariantAttributes, { VariantAttributeInputData diff --git a/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx b/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx index 487683719..1f89122a8 100644 --- a/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx +++ b/src/products/components/ProductVariantPrice/ProductVariantPrice.tsx @@ -1,9 +1,9 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import { makeStyles } from "@material-ui/core/styles"; -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; import CardTitle from "@saleor/components/CardTitle"; import PriceField from "@saleor/components/PriceField"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { getFormErrors, getProductErrorMessage } from "@saleor/utils/errors"; import React from "react"; import { useIntl } from "react-intl"; diff --git a/src/products/components/ProductVariants/ProductVariants.tsx b/src/products/components/ProductVariants/ProductVariants.tsx index 97fe9748b..86ee81aa4 100644 --- a/src/products/components/ProductVariants/ProductVariants.tsx +++ b/src/products/components/ProductVariants/ProductVariants.tsx @@ -15,6 +15,7 @@ import ResponsiveTable from "@saleor/components/ResponsiveTable"; import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; import Skeleton from "@saleor/components/Skeleton"; import TableHead from "@saleor/components/TableHead"; +import { ProductVariant_costPrice } from "@saleor/fragments/types/ProductVariant"; import React from "react"; import { FormattedMessage, IntlShape, useIntl } from "react-intl"; @@ -24,7 +25,6 @@ import { ProductDetails_product_variants, ProductDetails_product_variants_stocks_warehouse } from "../../types/ProductDetails"; -import { ProductVariant_costPrice } from "../../types/ProductVariant"; function getWarehouseChoices( variants: ProductDetails_product_variants[], diff --git a/src/products/fixtures.ts b/src/products/fixtures.ts index f9f6c161a..09598e874 100644 --- a/src/products/fixtures.ts +++ b/src/products/fixtures.ts @@ -1,10 +1,10 @@ +import { ProductVariant } from "@saleor/fragments/types/ProductVariant"; import { AttributeInputTypeEnum } from "@saleor/types/globalTypes"; import { warehouseList } from "@saleor/warehouses/fixtures"; import { content } from "../storybook/stories/components/RichTextEditor"; import { ProductDetails_product } from "./types/ProductDetails"; import { ProductList_products_edges_node } from "./types/ProductList"; -import { ProductVariant } from "./types/ProductVariant"; import { ProductVariantCreateData_product } from "./types/ProductVariantCreateData"; export const product: ( diff --git a/src/products/mutations.ts b/src/products/mutations.ts index ce34b70e6..e4d38590a 100644 --- a/src/products/mutations.ts +++ b/src/products/mutations.ts @@ -1,9 +1,17 @@ -import { productErrorFragment } from "@saleor/attributes/mutations"; +import { + bulkProductErrorFragment, + bulkStockErrorFragment, + productErrorFragment, + stockErrorFragment +} from "@saleor/fragments/errors"; +import { + fragmentVariant, + productFragmentDetails +} from "@saleor/fragments/products"; import makeMutation from "@saleor/hooks/makeMutation"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { fragmentVariant, productFragmentDetails } from "./queries"; import { productBulkDelete, productBulkDeleteVariables @@ -55,27 +63,6 @@ import { } from "./types/VariantImageUnassign"; import { VariantUpdate, VariantUpdateVariables } from "./types/VariantUpdate"; -export const bulkProductErrorFragment = gql` - fragment BulkProductErrorFragment on BulkProductError { - field - code - index - } -`; -const bulkStockErrorFragment = gql` - fragment BulkStockErrorFragment on BulkStockError { - code - field - index - } -`; -const stockErrorFragment = gql` - fragment StockErrorFragment on StockError { - code - field - } -`; - export const productImageCreateMutation = gql` ${productErrorFragment} ${productFragmentDetails} diff --git a/src/products/queries.ts b/src/products/queries.ts index ae361b59f..017fd0bf7 100644 --- a/src/products/queries.ts +++ b/src/products/queries.ts @@ -1,16 +1,24 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; +import { + fragmentMoney, + fragmentVariant, + productFragment, + productFragmentDetails, + productVariantAttributesFragment +} from "@saleor/fragments/products"; +import { warehouseFragment } from "@saleor/fragments/warehouses"; import makeQuery from "@saleor/hooks/makeQuery"; -import { warehouseFragment } from "@saleor/warehouses/queries"; import gql from "graphql-tag"; -import { pageInfoFragment, TypedQuery } from "../queries"; -import { - AvailableInGridAttributes, - AvailableInGridAttributesVariables -} from "./types/AvailableInGridAttributes"; +import { TypedQuery } from "../queries"; import { CreateMultipleVariantsData, CreateMultipleVariantsDataVariables } from "./types/CreateMultipleVariantsData"; +import { + GridAttributes, + GridAttributesVariables +} from "./types/GridAttributes"; import { InitialProductFilterData, InitialProductFilterDataVariables @@ -33,238 +41,6 @@ import { ProductVariantDetailsVariables } from "./types/ProductVariantDetails"; -export const stockFragment = gql` - fragment StockFragment on Stock { - id - quantity - quantityAllocated - warehouse { - id - name - } - } -`; - -export const fragmentMoney = gql` - fragment Money on Money { - amount - currency - } -`; - -export const fragmentProductImage = gql` - fragment ProductImageFragment on ProductImage { - id - alt - sortOrder - url - } -`; - -export const productFragment = gql` - fragment ProductFragment on Product { - id - name - thumbnail { - url - } - isAvailable - isPublished - productType { - id - name - hasVariants - } - } -`; - -const productVariantAttributesFragment = gql` - ${fragmentMoney} - fragment ProductVariantAttributesFragment on Product { - id - attributes { - attribute { - id - slug - name - inputType - valueRequired - values { - id - name - slug - } - } - values { - id - name - slug - } - } - productType { - id - variantAttributes { - id - name - values { - id - name - slug - } - } - } - pricing { - priceRangeUndiscounted { - start { - gross { - ...Money - } - } - stop { - gross { - ...Money - } - } - } - } - } -`; - -export const productFragmentDetails = gql` - ${fragmentProductImage} - ${fragmentMoney} - ${productVariantAttributesFragment} - ${stockFragment} - fragment Product on Product { - ...ProductVariantAttributesFragment - name - descriptionJson - seoTitle - seoDescription - category { - id - name - } - collections { - id - name - } - margin { - start - stop - } - purchaseCost { - start { - ...Money - } - stop { - ...Money - } - } - isAvailable - isPublished - chargeTaxes - publicationDate - pricing { - priceRangeUndiscounted { - start { - gross { - ...Money - } - } - stop { - gross { - ...Money - } - } - } - } - images { - ...ProductImageFragment - } - variants { - id - sku - name - price { - ...Money - } - margin - stocks { - ...StockFragment - } - trackInventory - } - productType { - id - name - hasVariants - } - } -`; - -export const fragmentVariant = gql` - ${fragmentMoney} - ${fragmentProductImage} - ${stockFragment} - fragment ProductVariant on ProductVariant { - id - attributes { - attribute { - id - name - slug - valueRequired - values { - id - name - slug - } - } - values { - id - name - slug - } - } - costPrice { - ...Money - } - images { - id - url - } - name - price { - ...Money - } - product { - id - images { - ...ProductImageFragment - } - name - thumbnail { - url - } - variants { - id - name - sku - images { - id - url - } - } - } - sku - stocks { - ...StockFragment - } - trackInventory - } -`; - const initialProductFilterDataQuery = gql` query InitialProductFilterData( $categories: [ID!] @@ -500,8 +276,8 @@ const availableInGridAttributes = gql` } `; export const AvailableInGridAttributesQuery = TypedQuery< - AvailableInGridAttributes, - AvailableInGridAttributesVariables + GridAttributes, + GridAttributesVariables >(availableInGridAttributes); const createMultipleVariantsData = gql` diff --git a/src/products/types/AvailableInGridAttributes.ts b/src/products/types/AvailableInGridAttributes.ts deleted file mode 100644 index e87d2abdf..000000000 --- a/src/products/types/AvailableInGridAttributes.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL query operation: AvailableInGridAttributes -// ==================================================== - -export interface AvailableInGridAttributes_availableInGrid_edges_node { - __typename: "Attribute"; - id: string; - name: string | null; -} - -export interface AvailableInGridAttributes_availableInGrid_edges { - __typename: "AttributeCountableEdge"; - node: AvailableInGridAttributes_availableInGrid_edges_node; -} - -export interface AvailableInGridAttributes_availableInGrid_pageInfo { - __typename: "PageInfo"; - endCursor: string | null; - hasNextPage: boolean; - hasPreviousPage: boolean; - startCursor: string | null; -} - -export interface AvailableInGridAttributes_availableInGrid { - __typename: "AttributeCountableConnection"; - edges: AvailableInGridAttributes_availableInGrid_edges[]; - pageInfo: AvailableInGridAttributes_availableInGrid_pageInfo; - totalCount: number | null; -} - -export interface AvailableInGridAttributes_grid_edges_node { - __typename: "Attribute"; - id: string; - name: string | null; -} - -export interface AvailableInGridAttributes_grid_edges { - __typename: "AttributeCountableEdge"; - node: AvailableInGridAttributes_grid_edges_node; -} - -export interface AvailableInGridAttributes_grid { - __typename: "AttributeCountableConnection"; - edges: AvailableInGridAttributes_grid_edges[]; -} - -export interface AvailableInGridAttributes { - availableInGrid: AvailableInGridAttributes_availableInGrid | null; - grid: AvailableInGridAttributes_grid | null; -} - -export interface AvailableInGridAttributesVariables { - first: number; - after?: string | null; - ids: string[]; -} diff --git a/src/products/types/ProductImage.ts b/src/products/types/ProductImage.ts deleted file mode 100644 index 8a5b981af..000000000 --- a/src/products/types/ProductImage.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* tslint:disable */ -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL fragment: ProductImage -// ==================================================== - -export interface ProductImage { - __typename: "ProductImage"; - id: string; - alt: string; - sortOrder: number; - url: string; -} diff --git a/src/products/utils/data.ts b/src/products/utils/data.ts index 54a73afbc..e0ac8391f 100644 --- a/src/products/utils/data.ts +++ b/src/products/utils/data.ts @@ -1,5 +1,6 @@ import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField"; import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; +import { ProductVariant } from "@saleor/fragments/types/ProductVariant"; import { FormsetAtomicData } from "@saleor/hooks/useFormset"; import { maybe } from "@saleor/misc"; import { @@ -14,7 +15,6 @@ import { RawDraftContentState } from "draft-js"; import { ProductAttributeInput } from "../components/ProductAttributes"; import { ProductStockInput } from "../components/ProductStocks"; import { VariantAttributeInput } from "../components/ProductVariantAttributes"; -import { ProductVariant } from "../types/ProductVariant"; import { ProductVariantCreateData_product } from "../types/ProductVariantCreateData"; export interface Collection { diff --git a/src/queries.tsx b/src/queries.tsx index b08942af6..55f878368 100644 --- a/src/queries.tsx +++ b/src/queries.tsx @@ -1,6 +1,5 @@ import { ApolloQueryResult } from "apollo-client"; import { DocumentNode } from "graphql"; -import gql from "graphql-tag"; import React from "react"; import { Query, QueryResult } from "react-apollo"; import { useIntl } from "react-intl"; @@ -163,12 +162,3 @@ export function TypedQuery( ); }; } - -export const pageInfoFragment = gql` - fragment PageInfoFragment on PageInfo { - endCursor - hasNextPage - hasPreviousPage - startCursor - } -`; diff --git a/src/searches/useCategorySearch.ts b/src/searches/useCategorySearch.ts index 9afd24740..8c86ddbec 100644 --- a/src/searches/useCategorySearch.ts +++ b/src/searches/useCategorySearch.ts @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { diff --git a/src/searches/useCollectionSearch.ts b/src/searches/useCollectionSearch.ts index 8c4bf3b87..371033f06 100644 --- a/src/searches/useCollectionSearch.ts +++ b/src/searches/useCollectionSearch.ts @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { diff --git a/src/searches/useCustomerSearch.ts b/src/searches/useCustomerSearch.ts index 07d890a8e..8cfd16229 100644 --- a/src/searches/useCustomerSearch.ts +++ b/src/searches/useCustomerSearch.ts @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { diff --git a/src/searches/usePageSearch.ts b/src/searches/usePageSearch.ts index 1218a8f77..1027ec2f3 100644 --- a/src/searches/usePageSearch.ts +++ b/src/searches/usePageSearch.ts @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { SearchPages, SearchPagesVariables } from "./types/SearchPages"; diff --git a/src/searches/usePermissionGroupSearch.ts b/src/searches/usePermissionGroupSearch.ts index d4730b3fd..9445794a1 100644 --- a/src/searches/usePermissionGroupSearch.ts +++ b/src/searches/usePermissionGroupSearch.ts @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { diff --git a/src/searches/useProductSearch.ts b/src/searches/useProductSearch.ts index 295db0da5..1da659a51 100644 --- a/src/searches/useProductSearch.ts +++ b/src/searches/useProductSearch.ts @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { diff --git a/src/searches/useProductTypeSearch.ts b/src/searches/useProductTypeSearch.ts index 9097eb75e..e5cad1f89 100644 --- a/src/searches/useProductTypeSearch.ts +++ b/src/searches/useProductTypeSearch.ts @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { diff --git a/src/searches/useServiceAccountSearch.ts b/src/searches/useServiceAccountSearch.ts index 99b56296e..92bd38659 100644 --- a/src/searches/useServiceAccountSearch.ts +++ b/src/searches/useServiceAccountSearch.ts @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { diff --git a/src/searches/useStaffMemberSearch.ts b/src/searches/useStaffMemberSearch.ts index ef1628f91..6f0616912 100644 --- a/src/searches/useStaffMemberSearch.ts +++ b/src/searches/useStaffMemberSearch.ts @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { diff --git a/src/searches/useWarehouseSearch.ts b/src/searches/useWarehouseSearch.ts index c7a21056b..d37ab01a6 100644 --- a/src/searches/useWarehouseSearch.ts +++ b/src/searches/useWarehouseSearch.ts @@ -1,5 +1,5 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; import makeTopLevelSearch from "@saleor/hooks/makeTopLevelSearch"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { diff --git a/src/services/components/ServiceCreatePage/ServiceCreatePage.tsx b/src/services/components/ServiceCreatePage/ServiceCreatePage.tsx index 994ca547a..d1c87ed8a 100644 --- a/src/services/components/ServiceCreatePage/ServiceCreatePage.tsx +++ b/src/services/components/ServiceCreatePage/ServiceCreatePage.tsx @@ -9,7 +9,7 @@ import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import { sectionNames } from "@saleor/intl"; import { PermissionEnum } from "@saleor/types/globalTypes"; import { getFormErrors } from "@saleor/utils/errors"; diff --git a/src/services/components/ServiceDetailsPage/ServiceDetailsPage.tsx b/src/services/components/ServiceDetailsPage/ServiceDetailsPage.tsx index b4a3234cd..a56ab8d8c 100644 --- a/src/services/components/ServiceDetailsPage/ServiceDetailsPage.tsx +++ b/src/services/components/ServiceDetailsPage/ServiceDetailsPage.tsx @@ -9,7 +9,7 @@ import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { ShopInfo_shop_permissions } from "@saleor/components/Shop/types/ShopInfo"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import { sectionNames } from "@saleor/intl"; import { maybe } from "@saleor/misc"; import { ServiceDetails_serviceAccount } from "@saleor/services/types/ServiceDetails"; diff --git a/src/services/components/ServiceInfo/ServiceInfo.tsx b/src/services/components/ServiceInfo/ServiceInfo.tsx index bd09460e3..df2b7c807 100644 --- a/src/services/components/ServiceInfo/ServiceInfo.tsx +++ b/src/services/components/ServiceInfo/ServiceInfo.tsx @@ -2,7 +2,7 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import { FormChange } from "@saleor/hooks/useForm"; import { getFormErrors } from "@saleor/utils/errors"; import getAccountErrorMessage from "@saleor/utils/errors/account"; diff --git a/src/services/components/ServiceTokens/ServiceTokens.tsx b/src/services/components/ServiceTokens/ServiceTokens.tsx index 07fab1f04..1e6c183c2 100644 --- a/src/services/components/ServiceTokens/ServiceTokens.tsx +++ b/src/services/components/ServiceTokens/ServiceTokens.tsx @@ -10,8 +10,8 @@ import DeleteIcon from "@material-ui/icons/Delete"; import CardTitle from "@saleor/components/CardTitle"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; +import { ServiceDetailsFragment_tokens } from "@saleor/fragments/types/ServiceDetailsFragment"; import { maybe, renderCollection } from "@saleor/misc"; -import { ServiceDetailsFragment_tokens } from "@saleor/services/types/ServiceDetailsFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/services/mutations.ts b/src/services/mutations.ts index d8230b766..b6912387a 100644 --- a/src/services/mutations.ts +++ b/src/services/mutations.ts @@ -1,8 +1,11 @@ -import { accountErrorFragment } from "@saleor/customers/mutations"; +import { accountErrorFragment } from "@saleor/fragments/errors"; +import { + serviceDetailsFragment, + serviceFragment +} from "@saleor/fragments/services"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { serviceDetailsFragment, serviceFragment } from "./queries"; import { ServiceCreate, ServiceCreateVariables } from "./types/ServiceCreate"; import { ServiceDelete, ServiceDeleteVariables } from "./types/ServiceDelete"; import { diff --git a/src/services/queries.ts b/src/services/queries.ts index 1e97f0720..84c654796 100644 --- a/src/services/queries.ts +++ b/src/services/queries.ts @@ -1,21 +1,18 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; +import { + serviceDetailsFragment, + serviceFragment +} from "@saleor/fragments/services"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; -import { pageInfoFragment, TypedQuery } from "../queries"; +import { TypedQuery } from "../queries"; import { ServiceDetails, ServiceDetailsVariables } from "./types/ServiceDetails"; import { ServiceList, ServiceListVariables } from "./types/ServiceList"; -export const serviceFragment = gql` - fragment ServiceFragment on ServiceAccount { - id - name - isActive - } -`; - const serviceList = gql` ${pageInfoFragment} ${serviceFragment} @@ -50,22 +47,6 @@ export const useServiceListQuery = makeQuery( serviceList ); -export const serviceDetailsFragment = gql` - ${serviceFragment} - fragment ServiceDetailsFragment on ServiceAccount { - ...ServiceFragment - permissions { - code - name - } - tokens { - id - name - authToken - } - } -`; - const serviceDetails = gql` ${serviceDetailsFragment} query ServiceDetails($id: ID!) { diff --git a/src/shipping/components/ShippingZoneAddWarehouseDialog/ShippingZoneAddWarehouseDialog.tsx b/src/shipping/components/ShippingZoneAddWarehouseDialog/ShippingZoneAddWarehouseDialog.tsx index e6c9bfefe..f0fc2b3f6 100644 --- a/src/shipping/components/ShippingZoneAddWarehouseDialog/ShippingZoneAddWarehouseDialog.tsx +++ b/src/shipping/components/ShippingZoneAddWarehouseDialog/ShippingZoneAddWarehouseDialog.tsx @@ -14,6 +14,7 @@ import FormSpacer from "@saleor/components/FormSpacer"; import Hr from "@saleor/components/Hr"; import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo"; import { AddressTypeInput } from "@saleor/customers/types"; +import { WarehouseErrorFragment } from "@saleor/fragments/types/WarehouseErrorFragment"; import useAddressValidation from "@saleor/hooks/useAddressValidation"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import useModalDialogOpen from "@saleor/hooks/useModalDialogOpen"; @@ -21,7 +22,6 @@ import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { buttonMessages } from "@saleor/intl"; import { DialogProps } from "@saleor/types"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; -import { WarehouseErrorFragment } from "@saleor/warehouses/types/WarehouseErrorFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/shipping/components/ShippingZoneCreatePage/ShippingZoneCreatePage.tsx b/src/shipping/components/ShippingZoneCreatePage/ShippingZoneCreatePage.tsx index de5985a98..a357ef81d 100644 --- a/src/shipping/components/ShippingZoneCreatePage/ShippingZoneCreatePage.tsx +++ b/src/shipping/components/ShippingZoneCreatePage/ShippingZoneCreatePage.tsx @@ -7,12 +7,12 @@ import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; +import { CountryFragment } from "@saleor/fragments/types/CountryFragment"; +import { ShippingErrorFragment } from "@saleor/fragments/types/ShippingErrorFragment"; import { sectionNames } from "@saleor/intl"; -import { ShippingErrorFragment } from "@saleor/shipping/types/ShippingErrorFragment"; import React from "react"; import { useIntl } from "react-intl"; -import { CountryFragment } from "../../../taxes/types/CountryFragment"; import ShippingZoneCountriesAssignDialog from "../ShippingZoneCountriesAssignDialog"; import ShippingZoneInfo from "../ShippingZoneInfo"; diff --git a/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx b/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx index 72d77ee0f..31c41233a 100644 --- a/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx +++ b/src/shipping/components/ShippingZoneDetailsPage/ShippingZoneDetailsPage.tsx @@ -9,8 +9,12 @@ import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocomplet import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; +import { ShippingErrorFragment } from "@saleor/fragments/types/ShippingErrorFragment"; +import { + ShippingZoneDetailsFragment, + ShippingZoneDetailsFragment_warehouses +} from "@saleor/fragments/types/ShippingZoneDetailsFragment"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; -import { ShippingErrorFragment } from "@saleor/shipping/types/ShippingErrorFragment"; import createMultiAutocompleteSelectHandler from "@saleor/utils/handlers/multiAutocompleteSelectChangeHandler"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; @@ -18,10 +22,6 @@ import { FormattedMessage, useIntl } from "react-intl"; import { getStringOrPlaceholder } from "../../../misc"; import { FetchMoreProps, SearchProps } from "../../../types"; import { ShippingMethodTypeEnum } from "../../../types/globalTypes"; -import { - ShippingZoneDetailsFragment, - ShippingZoneDetailsFragment_warehouses -} from "../../types/ShippingZoneDetailsFragment"; import ShippingZoneInfo from "../ShippingZoneInfo"; import ShippingZoneRates from "../ShippingZoneRates"; import ShippingZoneWarehouses from "../ShippingZoneWarehouses"; diff --git a/src/shipping/components/ShippingZoneInfo/ShippingZoneInfo.tsx b/src/shipping/components/ShippingZoneInfo/ShippingZoneInfo.tsx index 4e01737c0..ffca78e2a 100644 --- a/src/shipping/components/ShippingZoneInfo/ShippingZoneInfo.tsx +++ b/src/shipping/components/ShippingZoneInfo/ShippingZoneInfo.tsx @@ -2,8 +2,8 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; +import { ShippingErrorFragment } from "@saleor/fragments/types/ShippingErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { ShippingErrorFragment } from "@saleor/shipping/types/ShippingErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getShippingErrorMessage from "@saleor/utils/errors/shipping"; import React from "react"; diff --git a/src/shipping/components/ShippingZoneRateDialog/ShippingZoneRateDialog.tsx b/src/shipping/components/ShippingZoneRateDialog/ShippingZoneRateDialog.tsx index d94b8fab9..904cb2117 100644 --- a/src/shipping/components/ShippingZoneRateDialog/ShippingZoneRateDialog.tsx +++ b/src/shipping/components/ShippingZoneRateDialog/ShippingZoneRateDialog.tsx @@ -14,9 +14,10 @@ import Form from "@saleor/components/Form"; import FormSpacer from "@saleor/components/FormSpacer"; import Hr from "@saleor/components/Hr"; import Skeleton from "@saleor/components/Skeleton"; +import { ShippingErrorFragment } from "@saleor/fragments/types/ShippingErrorFragment"; +import { ShippingZoneDetailsFragment_shippingMethods } from "@saleor/fragments/types/ShippingZoneDetailsFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import { buttonMessages } from "@saleor/intl"; -import { ShippingErrorFragment } from "@saleor/shipping/types/ShippingErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getShippingErrorMessage from "@saleor/utils/errors/shipping"; import React from "react"; @@ -24,7 +25,6 @@ import { FormattedMessage, useIntl } from "react-intl"; import { maybe } from "../../../misc"; import { ShippingMethodTypeEnum } from "../../../types/globalTypes"; -import { ShippingZoneDetailsFragment_shippingMethods } from "../../types/ShippingZoneDetailsFragment"; import { getShippingPriceRateErrorMessage, getShippingWeightRateErrorMessage diff --git a/src/shipping/components/ShippingZoneRateDialog/errors.ts b/src/shipping/components/ShippingZoneRateDialog/errors.ts index 48296b16f..c8170e5b8 100644 --- a/src/shipping/components/ShippingZoneRateDialog/errors.ts +++ b/src/shipping/components/ShippingZoneRateDialog/errors.ts @@ -1,9 +1,8 @@ +import { ShippingErrorFragment } from "@saleor/fragments/types/ShippingErrorFragment"; import { ShippingErrorCode } from "@saleor/types/globalTypes"; import getShippingErrorMessage from "@saleor/utils/errors/shipping"; import { defineMessages, IntlShape } from "react-intl"; -import { ShippingErrorFragment } from "../../types/ShippingErrorFragment"; - const messages = defineMessages({ price: { defaultMessage: "Maximum price cannot be lower than minimum", diff --git a/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx b/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx index b6b269b3a..40b4eb145 100644 --- a/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx +++ b/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx @@ -14,12 +14,12 @@ import MoneyRange from "@saleor/components/MoneyRange"; import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; import WeightRange from "@saleor/components/WeightRange"; +import { ShippingZoneDetailsFragment_shippingMethods } from "@saleor/fragments/types/ShippingZoneDetailsFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; import { maybe, renderCollection } from "../../../misc"; import { ICONBUTTON_SIZE } from "../../../theme"; -import { ShippingZoneDetailsFragment_shippingMethods } from "../../types/ShippingZoneDetailsFragment"; export interface ShippingZoneRatesProps { disabled: boolean; diff --git a/src/shipping/components/ShippingZonesList/ShippingZonesList.tsx b/src/shipping/components/ShippingZonesList/ShippingZonesList.tsx index 08452331f..80a879229 100644 --- a/src/shipping/components/ShippingZonesList/ShippingZonesList.tsx +++ b/src/shipping/components/ShippingZonesList/ShippingZonesList.tsx @@ -13,14 +13,13 @@ import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; import TableHead from "@saleor/components/TableHead"; import TablePagination from "@saleor/components/TablePagination"; +import { ShippingZoneFragment } from "@saleor/fragments/types/ShippingZoneFragment"; import { maybe, renderCollection } from "@saleor/misc"; import { ICONBUTTON_SIZE } from "@saleor/theme"; import { ListActions, ListProps } from "@saleor/types"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; -import { ShippingZoneFragment } from "../../types/ShippingZoneFragment"; - export interface ShippingZonesListProps extends ListProps, ListActions { shippingZones: ShippingZoneFragment[]; onAdd: () => void; diff --git a/src/shipping/components/ShippingZonesListPage/ShippingZonesListPage.tsx b/src/shipping/components/ShippingZonesListPage/ShippingZonesListPage.tsx index d723eca7a..39ecadbd5 100644 --- a/src/shipping/components/ShippingZonesListPage/ShippingZonesListPage.tsx +++ b/src/shipping/components/ShippingZonesListPage/ShippingZonesListPage.tsx @@ -3,13 +3,13 @@ import Container from "@saleor/components/Container"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import RequirePermissions from "@saleor/components/RequirePermissions"; +import { ShippingZoneFragment } from "@saleor/fragments/types/ShippingZoneFragment"; import { sectionNames } from "@saleor/intl"; import { ListActions, PageListProps, UserPermissionProps } from "@saleor/types"; import { PermissionEnum, WeightUnitsEnum } from "@saleor/types/globalTypes"; import React from "react"; import { useIntl } from "react-intl"; -import { ShippingZoneFragment } from "../../types/ShippingZoneFragment"; import ShippingWeightUnitForm from "../ShippingWeightUnitForm"; import ShippingZonesList from "../ShippingZonesList"; diff --git a/src/shipping/fixtures.ts b/src/shipping/fixtures.ts index 77eab37f9..123831135 100644 --- a/src/shipping/fixtures.ts +++ b/src/shipping/fixtures.ts @@ -1,6 +1,7 @@ +import { ShippingZoneDetailsFragment } from "@saleor/fragments/types/ShippingZoneDetailsFragment"; +import { ShippingZoneFragment } from "@saleor/fragments/types/ShippingZoneFragment"; + import { ShippingMethodTypeEnum } from "../types/globalTypes"; -import { ShippingZoneDetailsFragment } from "./types/ShippingZoneDetailsFragment"; -import { ShippingZoneFragment } from "./types/ShippingZoneFragment"; export const shippingZones: ShippingZoneFragment[] = [ { diff --git a/src/shipping/mutations.ts b/src/shipping/mutations.ts index cbd974e2d..e437bfa81 100644 --- a/src/shipping/mutations.ts +++ b/src/shipping/mutations.ts @@ -1,8 +1,12 @@ +import { shippingErrorFragment } from "@saleor/fragments/errors"; +import { + shippingMethodFragment, + shippingZoneDetailsFragment +} from "@saleor/fragments/shipping"; +import { countryFragment } from "@saleor/fragments/taxes"; import makeMutation from "@saleor/hooks/makeMutation"; import gql from "graphql-tag"; -import { countryFragment } from "../taxes/queries"; -import { shippingMethodFragment, shippingZoneDetailsFragment } from "./queries"; import { BulkDeleteShippingRate, BulkDeleteShippingRateVariables @@ -40,13 +44,6 @@ import { UpdateShippingZoneVariables } from "./types/UpdateShippingZone"; -export const shippingErrorFragment = gql` - fragment ShippingErrorFragment on ShippingError { - code - field - } -`; - const deleteShippingZone = gql` ${shippingErrorFragment} mutation DeleteShippingZone($id: ID!) { diff --git a/src/shipping/queries.ts b/src/shipping/queries.ts index cc7bdc146..6f4eb71b3 100644 --- a/src/shipping/queries.ts +++ b/src/shipping/queries.ts @@ -1,63 +1,14 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; +import { + shippingZoneDetailsFragment, + shippingZoneFragment +} from "@saleor/fragments/shipping"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; -import { pageInfoFragment } from "../queries"; import { ShippingZone, ShippingZoneVariables } from "./types/ShippingZone"; import { ShippingZones, ShippingZonesVariables } from "./types/ShippingZones"; -export const shippingZoneFragment = gql` - fragment ShippingZoneFragment on ShippingZone { - id - countries { - code - country - } - name - } -`; -export const shippingMethodFragment = gql` - fragment ShippingMethodFragment on ShippingMethod { - id - minimumOrderPrice { - amount - currency - } - minimumOrderWeight { - unit - value - } - maximumOrderPrice { - amount - currency - } - maximumOrderWeight { - unit - value - } - name - price { - amount - currency - } - type - } -`; -export const shippingZoneDetailsFragment = gql` - ${shippingZoneFragment} - ${shippingMethodFragment} - fragment ShippingZoneDetailsFragment on ShippingZone { - ...ShippingZoneFragment - default - shippingMethods { - ...ShippingMethodFragment - } - warehouses { - id - name - } - } -`; - const shippingZones = gql` ${pageInfoFragment} ${shippingZoneFragment} diff --git a/src/siteSettings/components/SiteSettingsDetails/SiteSettingsDetails.tsx b/src/siteSettings/components/SiteSettingsDetails/SiteSettingsDetails.tsx index 75d7407f4..111c3e71b 100644 --- a/src/siteSettings/components/SiteSettingsDetails/SiteSettingsDetails.tsx +++ b/src/siteSettings/components/SiteSettingsDetails/SiteSettingsDetails.tsx @@ -3,8 +3,8 @@ import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; import FormSpacer from "@saleor/components/FormSpacer"; +import { ShopErrorFragment } from "@saleor/fragments/types/ShopErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { ShopErrorFragment } from "@saleor/siteSettings/types/ShopErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getShopErrorMessage from "@saleor/utils/errors/shop"; import React from "react"; diff --git a/src/siteSettings/components/SiteSettingsKeyDialog/SiteSettingsKeyDialog.tsx b/src/siteSettings/components/SiteSettingsKeyDialog/SiteSettingsKeyDialog.tsx index 1478fd76f..9d5b2f135 100644 --- a/src/siteSettings/components/SiteSettingsKeyDialog/SiteSettingsKeyDialog.tsx +++ b/src/siteSettings/components/SiteSettingsKeyDialog/SiteSettingsKeyDialog.tsx @@ -7,8 +7,8 @@ import TextField from "@material-ui/core/TextField"; import Form from "@saleor/components/Form"; import { FormSpacer } from "@saleor/components/FormSpacer"; import SingleSelectField from "@saleor/components/SingleSelectField"; +import { ShopErrorFragment } from "@saleor/fragments/types/ShopErrorFragment"; import { buttonMessages } from "@saleor/intl"; -import { ShopErrorFragment } from "@saleor/siteSettings/types/ShopErrorFragment"; import { DialogProps } from "@saleor/types"; import { getFormErrors } from "@saleor/utils/errors"; import getShopErrorMessage from "@saleor/utils/errors/shop"; diff --git a/src/siteSettings/components/SiteSettingsMailing/SiteSettingsMailing.tsx b/src/siteSettings/components/SiteSettingsMailing/SiteSettingsMailing.tsx index 71ed8de36..4c08cb3e8 100644 --- a/src/siteSettings/components/SiteSettingsMailing/SiteSettingsMailing.tsx +++ b/src/siteSettings/components/SiteSettingsMailing/SiteSettingsMailing.tsx @@ -6,7 +6,7 @@ import Typography from "@material-ui/core/Typography"; import CardTitle from "@saleor/components/CardTitle"; import FormSpacer from "@saleor/components/FormSpacer"; import Hr from "@saleor/components/Hr"; -import { ShopErrorFragment } from "@saleor/siteSettings/types/ShopErrorFragment"; +import { ShopErrorFragment } from "@saleor/fragments/types/ShopErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getShopErrorMessage from "@saleor/utils/errors/shop"; import React from "react"; diff --git a/src/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx b/src/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx index 45f5d4942..b05db7280 100644 --- a/src/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx +++ b/src/siteSettings/components/SiteSettingsPage/SiteSettingsPage.tsx @@ -9,10 +9,10 @@ import Grid from "@saleor/components/Grid"; import Hr from "@saleor/components/Hr"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; +import { ShopErrorFragment } from "@saleor/fragments/types/ShopErrorFragment"; import useAddressValidation from "@saleor/hooks/useAddressValidation"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { commonMessages, sectionNames } from "@saleor/intl"; -import { ShopErrorFragment } from "@saleor/siteSettings/types/ShopErrorFragment"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; import { mapCountriesToChoices } from "@saleor/utils/maps"; import React from "react"; diff --git a/src/siteSettings/mutations.ts b/src/siteSettings/mutations.ts index c13b45f7f..50baaf211 100644 --- a/src/siteSettings/mutations.ts +++ b/src/siteSettings/mutations.ts @@ -1,8 +1,9 @@ +import { fragmentAddress } from "@saleor/fragments/address"; +import { shopErrorFragment } from "@saleor/fragments/errors"; +import { shopFragment } from "@saleor/fragments/shop"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { fragmentAddress } from "../orders/queries"; -import { shopFragment } from "./queries"; import { AuthorizationKeyAdd, AuthorizationKeyAddVariables @@ -16,12 +17,6 @@ import { ShopSettingsUpdateVariables } from "./types/ShopSettingsUpdate"; -const shopErrorFragment = gql` - fragment ShopErrorFragment on ShopError { - code - field - } -`; const authorizationKeyAdd = gql` ${shopErrorFragment} ${shopFragment} diff --git a/src/siteSettings/queries.ts b/src/siteSettings/queries.ts index 12364ce05..7432cd0e7 100644 --- a/src/siteSettings/queries.ts +++ b/src/siteSettings/queries.ts @@ -1,33 +1,9 @@ +import { shopFragment } from "@saleor/fragments/shop"; import gql from "graphql-tag"; -import { fragmentAddress } from "../orders/queries"; import { TypedQuery } from "../queries"; import { SiteSettings } from "./types/SiteSettings"; -export const shopFragment = gql` - ${fragmentAddress} - fragment ShopFragment on Shop { - authorizationKeys { - key - name - } - companyAddress { - ...AddressFragment - } - countries { - code - country - } - customerSetPasswordUrl - defaultMailSenderAddress - defaultMailSenderName - description - domain { - host - } - name - } -`; const siteSettings = gql` ${shopFragment} query SiteSettings { diff --git a/src/siteSettings/types/ShopErrorFragment.ts b/src/siteSettings/types/ShopErrorFragment.ts deleted file mode 100644 index ae705f05f..000000000 --- a/src/siteSettings/types/ShopErrorFragment.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// This file was automatically generated and should not be edited. - -import { ShopErrorCode } from "./../../types/globalTypes"; - -// ==================================================== -// GraphQL fragment: ShopErrorFragment -// ==================================================== - -export interface ShopErrorFragment { - __typename: "ShopError"; - code: ShopErrorCode; - field: string | null; -} diff --git a/src/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx b/src/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx index a229643eb..3b93382d1 100644 --- a/src/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx +++ b/src/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx @@ -10,10 +10,10 @@ import ConfirmButton, { } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; import FormSpacer from "@saleor/components/FormSpacer"; +import { StaffErrorFragment } from "@saleor/fragments/types/StaffErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import { buttonMessages, commonMessages } from "@saleor/intl"; import { SearchPermissionGroups_search_edges_node } from "@saleor/searches/types/SearchPermissionGroups"; -import { StaffErrorFragment } from "@saleor/staff/types/StaffErrorFragment"; import { FetchMoreProps, SearchPageProps } from "@saleor/types"; import { getFormErrors } from "@saleor/utils/errors"; import getStaffErrorMessage from "@saleor/utils/errors/staff"; diff --git a/src/staff/components/StaffDetailsPage/StaffDetailsPage.tsx b/src/staff/components/StaffDetailsPage/StaffDetailsPage.tsx index ffec07945..e1fa5cc78 100644 --- a/src/staff/components/StaffDetailsPage/StaffDetailsPage.tsx +++ b/src/staff/components/StaffDetailsPage/StaffDetailsPage.tsx @@ -11,12 +11,12 @@ import Grid from "@saleor/components/Grid"; import { MultiAutocompleteChoiceType } from "@saleor/components/MultiAutocompleteSelectField"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; +import { StaffErrorFragment } from "@saleor/fragments/types/StaffErrorFragment"; import useLocale from "@saleor/hooks/useLocale"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { sectionNames } from "@saleor/intl"; import { getUserName } from "@saleor/misc"; import { SearchPermissionGroups_search_edges_node } from "@saleor/searches/types/SearchPermissionGroups"; -import { StaffErrorFragment } from "@saleor/staff/types/StaffErrorFragment"; import { FetchMoreProps, SearchPageProps } from "@saleor/types"; import createMultiAutocompleteSelectHandler from "@saleor/utils/handlers/multiAutocompleteSelectChangeHandler"; import React from "react"; diff --git a/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx b/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx index d45468c26..429984bdf 100644 --- a/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx +++ b/src/staff/components/StaffPasswordResetDialog/StaffPasswordResetDialog.tsx @@ -9,7 +9,7 @@ import ConfirmButton, { } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; import FormSpacer from "@saleor/components/FormSpacer"; -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import { buttonMessages } from "@saleor/intl"; import { DialogProps } from "@saleor/types"; diff --git a/src/staff/components/StaffProperties/StaffProperties.tsx b/src/staff/components/StaffProperties/StaffProperties.tsx index d429af7a7..1fa153f4d 100644 --- a/src/staff/components/StaffProperties/StaffProperties.tsx +++ b/src/staff/components/StaffProperties/StaffProperties.tsx @@ -5,8 +5,8 @@ import { makeStyles } from "@material-ui/core/styles"; import TextField from "@material-ui/core/TextField"; import Typography from "@material-ui/core/Typography"; import CardTitle from "@saleor/components/CardTitle"; +import { StaffErrorFragment } from "@saleor/fragments/types/StaffErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { StaffErrorFragment } from "@saleor/staff/types/StaffErrorFragment"; import { getFormErrors } from "@saleor/utils/errors"; import getStaffErrorMessage from "@saleor/utils/errors/staff"; import React from "react"; diff --git a/src/staff/mutations.ts b/src/staff/mutations.ts index 27b1b9615..c51044584 100644 --- a/src/staff/mutations.ts +++ b/src/staff/mutations.ts @@ -1,9 +1,12 @@ -import { accountErrorFragment } from "@saleor/customers/mutations"; +import { + accountErrorFragment, + staffErrorFragment +} from "@saleor/fragments/errors"; +import { staffMemberDetailsFragment } from "@saleor/fragments/staff"; import makeMutation from "@saleor/hooks/makeMutation"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { staffMemberDetailsFragment } from "./queries"; import { ChangeStaffPassword, ChangeStaffPasswordVariables @@ -26,20 +29,6 @@ import { StaffMemberUpdateVariables } from "./types/StaffMemberUpdate"; -export const staffErrorFragment = gql` - fragment StaffErrorFragment on StaffError { - code - field - } -`; - -export const staffFragmentError = gql` - fragment StaffErrorFragment on StaffError { - code - field - } -`; - const staffMemberAddMutation = gql` ${staffErrorFragment} ${staffMemberDetailsFragment} diff --git a/src/staff/queries.ts b/src/staff/queries.ts index 11872f7f9..b8a86103c 100644 --- a/src/staff/queries.ts +++ b/src/staff/queries.ts @@ -1,3 +1,7 @@ +import { + staffMemberDetailsFragment, + staffMemberFragment +} from "@saleor/fragments/staff"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; @@ -8,33 +12,6 @@ import { StaffMemberDetailsVariables } from "./types/StaffMemberDetails"; -export const staffMemberFragment = gql` - fragment StaffMemberFragment on User { - id - email - firstName - isActive - lastName - avatar { - url - } - } -`; -export const staffMemberDetailsFragment = gql` - ${staffMemberFragment} - fragment StaffMemberDetailsFragment on User { - ...StaffMemberFragment - permissionGroups { - id - name - userCanManage - } - userPermissions { - code - name - } - } -`; const staffList = gql` ${staffMemberFragment} query StaffList( diff --git a/src/storybook/stories/configuration/ConfigurationPage.tsx b/src/storybook/stories/configuration/ConfigurationPage.tsx index cd3ac54d8..0c9e2d258 100644 --- a/src/storybook/stories/configuration/ConfigurationPage.tsx +++ b/src/storybook/stories/configuration/ConfigurationPage.tsx @@ -1,6 +1,6 @@ -import { User } from "@saleor/auth/types/User"; import { createConfigurationMenu } from "@saleor/configuration"; import ConfigurationPage from "@saleor/configuration/ConfigurationPage"; +import { User } from "@saleor/fragments/types/User"; import { staffMember } from "@saleor/staff/fixtures"; import Decorator from "@saleor/storybook/Decorator"; import { storiesOf } from "@storybook/react"; diff --git a/src/taxes/mutations.ts b/src/taxes/mutations.ts index 053a5ee09..914b6b632 100644 --- a/src/taxes/mutations.ts +++ b/src/taxes/mutations.ts @@ -1,7 +1,7 @@ +import { countryFragment, shopTaxesFragment } from "@saleor/fragments/taxes"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { countryFragment, shopTaxesFragment } from "./queries"; import { FetchTaxes } from "./types/FetchTaxes"; import { UpdateTaxSettings, diff --git a/src/taxes/queries.ts b/src/taxes/queries.ts index 836478c91..342756eb4 100644 --- a/src/taxes/queries.ts +++ b/src/taxes/queries.ts @@ -1,35 +1,12 @@ +import { + countryWithTaxesFragment, + shopTaxesFragment +} from "@saleor/fragments/taxes"; import gql from "graphql-tag"; import { TypedQuery } from "../queries"; import { CountryList } from "./types/CountryList"; -export const countryFragment = gql` - fragment CountryFragment on CountryDisplay { - country - code - } -`; -export const countryWithTaxesFragment = gql` - ${countryFragment} - fragment CountryWithTaxesFragment on CountryDisplay { - ...CountryFragment - vat { - standardRate - reducedRates { - rateType - rate - } - } - } -`; -export const shopTaxesFragment = gql` - fragment ShopTaxesFragment on Shop { - chargeTaxesOnShipping - includeTaxesInPrices - displayGrossPrices - } -`; - const countryList = gql` ${countryWithTaxesFragment} ${shopTaxesFragment} diff --git a/src/translations/components/TranslationsCategoriesPage/TranslationsCategoriesPage.tsx b/src/translations/components/TranslationsCategoriesPage/TranslationsCategoriesPage.tsx index ce5bf47b8..f18e4d5fc 100644 --- a/src/translations/components/TranslationsCategoriesPage/TranslationsCategoriesPage.tsx +++ b/src/translations/components/TranslationsCategoriesPage/TranslationsCategoriesPage.tsx @@ -3,14 +3,14 @@ import CardSpacer from "@saleor/components/CardSpacer"; import Container from "@saleor/components/Container"; import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; +import { CategoryTranslationFragment } from "@saleor/fragments/types/CategoryTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { TranslationsEntitiesPageProps } from "@saleor/translations/types"; import React from "react"; import { useIntl } from "react-intl"; import { maybe } from "../../../misc"; import { LanguageCodeEnum } from "../../../types/globalTypes"; -import { CategoryTranslationFragment } from "../../types/CategoryTranslationFragment"; -import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage"; import TranslationFields from "../TranslationFields"; export interface TranslationsCategoriesPageProps diff --git a/src/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx b/src/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx index fb9f4e7ab..580600a6d 100644 --- a/src/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx +++ b/src/translations/components/TranslationsCollectionsPage/TranslationsCollectionsPage.tsx @@ -3,14 +3,14 @@ import CardSpacer from "@saleor/components/CardSpacer"; import Container from "@saleor/components/Container"; import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; +import { CollectionTranslationFragment } from "@saleor/fragments/types/CollectionTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { TranslationsEntitiesPageProps } from "@saleor/translations/types"; import React from "react"; import { useIntl } from "react-intl"; import { maybe } from "../../../misc"; import { LanguageCodeEnum } from "../../../types/globalTypes"; -import { CollectionTranslationFragment } from "../../types/CollectionTranslationFragment"; -import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage"; import TranslationFields from "../TranslationFields"; export interface TranslationsCollectionsPageProps diff --git a/src/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx b/src/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx index 1633a75b6..dd929aab0 100644 --- a/src/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx +++ b/src/translations/components/TranslationsPagesPage/TranslationsPagesPage.tsx @@ -3,14 +3,14 @@ import CardSpacer from "@saleor/components/CardSpacer"; import Container from "@saleor/components/Container"; import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; +import { PageTranslationFragment } from "@saleor/fragments/types/PageTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { TranslationsEntitiesPageProps } from "@saleor/translations/types"; import React from "react"; import { useIntl } from "react-intl"; import { maybe } from "../../../misc"; import { LanguageCodeEnum } from "../../../types/globalTypes"; -import { PageTranslationFragment } from "../../types/PageTranslationFragment"; -import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage"; import TranslationFields from "../TranslationFields"; export interface TranslationsPagesPageProps diff --git a/src/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx b/src/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx index 7c59cc4d3..c2578742b 100644 --- a/src/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx +++ b/src/translations/components/TranslationsProductTypesPage/TranslationsProductTypesPage.tsx @@ -3,14 +3,14 @@ import CardSpacer from "@saleor/components/CardSpacer"; import Container from "@saleor/components/Container"; import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; +import { ProductTypeTranslationFragment } from "@saleor/fragments/types/ProductTypeTranslationFragment"; import { sectionNames } from "@saleor/intl"; +import { TranslationsEntitiesPageProps } from "@saleor/translations/types"; import React from "react"; import { useIntl } from "react-intl"; import { maybe } from "../../../misc"; import { LanguageCodeEnum } from "../../../types/globalTypes"; -import { ProductTypeTranslationFragment } from "../../types/ProductTypeTranslationFragment"; -import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage"; import TranslationFields from "../TranslationFields"; export interface TranslationsProductTypesPageProps diff --git a/src/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx b/src/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx index 4db7ad6ae..1f263e43d 100644 --- a/src/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx +++ b/src/translations/components/TranslationsProductsPage/TranslationsProductsPage.tsx @@ -3,14 +3,14 @@ import CardSpacer from "@saleor/components/CardSpacer"; import Container from "@saleor/components/Container"; import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; +import { ProductTranslationFragment } from "@saleor/fragments/types/ProductTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { TranslationsEntitiesPageProps } from "@saleor/translations/types"; import React from "react"; import { useIntl } from "react-intl"; import { maybe } from "../../../misc"; import { LanguageCodeEnum } from "../../../types/globalTypes"; -import { ProductTranslationFragment } from "../../types/ProductTranslationFragment"; -import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage"; import TranslationFields from "../TranslationFields"; export interface TranslationsProductsPageProps diff --git a/src/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx b/src/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx index 97d16688f..646b97d75 100644 --- a/src/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx +++ b/src/translations/components/TranslationsSalesPage/TranslationsSalesPage.tsx @@ -2,14 +2,14 @@ import AppHeader from "@saleor/components/AppHeader"; import Container from "@saleor/components/Container"; import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; +import { SaleTranslationFragment } from "@saleor/fragments/types/SaleTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { TranslationsEntitiesPageProps } from "@saleor/translations/types"; import React from "react"; import { useIntl } from "react-intl"; import { maybe } from "../../../misc"; import { LanguageCodeEnum } from "../../../types/globalTypes"; -import { SaleTranslationFragment } from "../../types/SaleTranslationFragment"; -import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage"; import TranslationFields from "../TranslationFields"; export interface TranslationsSalesPageProps diff --git a/src/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx b/src/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx index 4bf3096d4..cee3a8246 100644 --- a/src/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx +++ b/src/translations/components/TranslationsVouchersPage/TranslationsVouchersPage.tsx @@ -2,14 +2,14 @@ import AppHeader from "@saleor/components/AppHeader"; import Container from "@saleor/components/Container"; import LanguageSwitch from "@saleor/components/LanguageSwitch"; import PageHeader from "@saleor/components/PageHeader"; +import { VoucherTranslationFragment } from "@saleor/fragments/types/VoucherTranslationFragment"; import { commonMessages, sectionNames } from "@saleor/intl"; +import { TranslationsEntitiesPageProps } from "@saleor/translations/types"; import React from "react"; import { useIntl } from "react-intl"; import { maybe } from "../../../misc"; import { LanguageCodeEnum } from "../../../types/globalTypes"; -import { TranslationsEntitiesPageProps } from "../../types/TranslationsEntitiesPage"; -import { VoucherTranslationFragment } from "../../types/VoucherTranslationFragment"; import TranslationFields from "../TranslationFields"; export interface TranslationsVouchersPageProps diff --git a/src/translations/mutations.ts b/src/translations/mutations.ts index 8328208ec..5cf950aef 100644 --- a/src/translations/mutations.ts +++ b/src/translations/mutations.ts @@ -1,6 +1,3 @@ -import gql from "graphql-tag"; - -import { TypedMutation } from "../mutations"; import { categoryTranslationFragment, collectionTranslationFragment, @@ -8,7 +5,10 @@ import { productTranslationFragment, saleTranslationFragment, voucherTranslationFragment -} from "./queries"; +} from "@saleor/fragments/translations"; +import gql from "graphql-tag"; + +import { TypedMutation } from "../mutations"; import { UpdateAttributeTranslations, UpdateAttributeTranslationsVariables diff --git a/src/translations/queries.ts b/src/translations/queries.ts index 19b977379..1cedc9b56 100644 --- a/src/translations/queries.ts +++ b/src/translations/queries.ts @@ -1,6 +1,16 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; +import { + categoryTranslationFragment, + collectionTranslationFragment, + pageTranslationFragment, + productTranslationFragment, + productTypeTranslationFragment, + saleTranslationFragment, + voucherTranslationFragment +} from "@saleor/fragments/translations"; import gql from "graphql-tag"; -import { pageInfoFragment, TypedQuery } from "../queries"; +import { TypedQuery } from "../queries"; import { CategoryTranslationDetails, CategoryTranslationDetailsVariables @@ -58,177 +68,6 @@ import { VoucherTranslationsVariables } from "./types/VoucherTranslations"; -export const categoryTranslationFragment = gql` - fragment CategoryTranslationFragment on Category { - id - name - descriptionJson - seoDescription - seoTitle - translation(languageCode: $language) { - id - descriptionJson - language { - language - } - name - seoDescription - seoTitle - } - } -`; -export const collectionTranslationFragment = gql` - fragment CollectionTranslationFragment on Collection { - id - name - descriptionJson - seoDescription - seoTitle - translation(languageCode: $language) { - id - descriptionJson - language { - language - } - name - seoDescription - seoTitle - } - } -`; -export const productTranslationFragment = gql` - fragment ProductTranslationFragment on Product { - id - name - descriptionJson - seoDescription - seoTitle - translation(languageCode: $language) { - id - descriptionJson - language { - code - language - } - name - seoDescription - seoTitle - } - } -`; -export const saleTranslationFragment = gql` - fragment SaleTranslationFragment on Sale { - id - name - translation(languageCode: $language) { - id - language { - code - language - } - name - } - } -`; -export const voucherTranslationFragment = gql` - fragment VoucherTranslationFragment on Voucher { - id - name - translation(languageCode: $language) { - id - language { - code - language - } - name - } - } -`; -export const shippingMethodTranslationFragment = gql` - fragment ShippingMethodTranslationFragment on ShippingMethod { - id - name - translation(languageCode: $language) { - id - language { - code - language - } - name - } - } -`; -export const pageTranslationFragment = gql` - fragment PageTranslationFragment on Page { - id - contentJson - seoDescription - seoTitle - title - - translation(languageCode: $language) { - id - contentJson - seoDescription - seoTitle - title - language { - code - language - } - } - } -`; -export const pageTranslatableFragment = gql` - fragment PageTranslatableFragment on PageTranslatableContent { - id - contentJson - seoDescription - seoTitle - title - - translation(languageCode: $language) { - id - contentJson - seoDescription - seoTitle - title - language { - code - language - } - } - } -`; -export const productTypeTranslationFragment = gql` - fragment AttributeTranslationFragment on Attribute { - id - name - translation(languageCode: $language) { - id - name - } - values { - id - name - translation(languageCode: $language) { - id - name - } - } - } - fragment ProductTypeTranslationFragment on ProductType { - id - name - productAttributes { - ...AttributeTranslationFragment - } - variantAttributes { - ...AttributeTranslationFragment - } - } -`; - const categoryTranslations = gql` ${pageInfoFragment} ${categoryTranslationFragment} diff --git a/src/translations/types/TranslationsEntitiesPage.ts b/src/translations/types.ts similarity index 70% rename from src/translations/types/TranslationsEntitiesPage.ts rename to src/translations/types.ts index 93a204c99..8c56c4bf1 100644 --- a/src/translations/types/TranslationsEntitiesPage.ts +++ b/src/translations/types.ts @@ -1,5 +1,5 @@ -import { ConfirmButtonTransitionState } from "../../components/ConfirmButton"; -import { ShopInfo_shop_languages } from "../../components/Shop/types/ShopInfo"; +import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; +import { ShopInfo_shop_languages } from "@saleor/components/Shop/types/ShopInfo"; export interface TranslationsEntitiesPageProps { activeField: string; diff --git a/src/translations/views/TranslationsEntities.tsx b/src/translations/views/TranslationsEntities.tsx index 5a69d36c2..e76b3d02c 100644 --- a/src/translations/views/TranslationsEntities.tsx +++ b/src/translations/views/TranslationsEntities.tsx @@ -1,3 +1,4 @@ +import { AttributeTranslationFragment } from "@saleor/fragments/types/AttributeTranslationFragment"; import useNavigator from "@saleor/hooks/useNavigator"; import usePaginator, { createPaginationState @@ -19,7 +20,6 @@ import { TypedSaleTranslations, TypedVoucherTranslations } from "../queries"; -import { AttributeTranslationFragment } from "../types/AttributeTranslationFragment"; import { languageEntitiesUrl, LanguageEntitiesUrlQueryParams, diff --git a/src/types.ts b/src/types.ts index 0937e2d9b..c9dd80a14 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,9 +1,9 @@ import { MutationResult } from "react-apollo"; -import { User_userPermissions } from "./auth/types/User"; import { ConfirmButtonTransitionState } from "./components/ConfirmButton"; import { IFilter } from "./components/Filter"; import { MultiAutocompleteChoiceType } from "./components/MultiAutocompleteSelectField"; +import { User_userPermissions } from "./fragments/types/User"; export interface UserError { field: string | null; diff --git a/src/utils/credentialsManagement.ts b/src/utils/credentialsManagement.ts index bd451c50a..e87aa9679 100644 --- a/src/utils/credentialsManagement.ts +++ b/src/utils/credentialsManagement.ts @@ -1,4 +1,4 @@ -import { User } from "@saleor/auth/types/User"; +import { User } from "@saleor/fragments/types/User"; export const isSupported = navigator.credentials && navigator.credentials.preventSilentAccess; diff --git a/src/utils/errors/account.ts b/src/utils/errors/account.ts index 165d57cc0..cfc514f29 100644 --- a/src/utils/errors/account.ts +++ b/src/utils/errors/account.ts @@ -1,4 +1,4 @@ -import { AccountErrorFragment } from "@saleor/customers/types/AccountErrorFragment"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import { commonMessages } from "@saleor/intl"; import { AccountErrorCode } from "@saleor/types/globalTypes"; import { defineMessages, IntlShape } from "react-intl"; diff --git a/src/utils/errors/discounts.ts b/src/utils/errors/discounts.ts index a12638311..b947f759a 100644 --- a/src/utils/errors/discounts.ts +++ b/src/utils/errors/discounts.ts @@ -1,4 +1,4 @@ -import { DiscountErrorFragment } from "@saleor/discounts/types/DiscountErrorFragment"; +import { DiscountErrorFragment } from "@saleor/fragments/types/DiscountErrorFragment"; import { commonMessages } from "@saleor/intl"; import { DiscountErrorCode } from "@saleor/types/globalTypes"; import { defineMessages, IntlShape } from "react-intl"; diff --git a/src/utils/errors/menu.ts b/src/utils/errors/menu.ts index 2203c420c..af2748755 100644 --- a/src/utils/errors/menu.ts +++ b/src/utils/errors/menu.ts @@ -1,5 +1,5 @@ +import { MenuErrorFragment } from "@saleor/fragments/types/MenuErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { MenuErrorFragment } from "@saleor/navigation/types/MenuErrorFragment"; import { MenuErrorCode } from "@saleor/types/globalTypes"; import { IntlShape } from "react-intl"; diff --git a/src/utils/errors/order.ts b/src/utils/errors/order.ts index 4eb52efca..e2421203f 100644 --- a/src/utils/errors/order.ts +++ b/src/utils/errors/order.ts @@ -1,5 +1,5 @@ +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { OrderErrorFragment } from "@saleor/orders/types/OrderErrorFragment"; import { OrderErrorCode } from "@saleor/types/globalTypes"; import { defineMessages, IntlShape } from "react-intl"; diff --git a/src/utils/errors/page.ts b/src/utils/errors/page.ts index 68d1ba019..500c9e60e 100644 --- a/src/utils/errors/page.ts +++ b/src/utils/errors/page.ts @@ -1,5 +1,5 @@ +import { PageErrorFragment } from "@saleor/fragments/types/PageErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { PageErrorFragment } from "@saleor/pages/types/PageErrorFragment"; import { PageErrorCode } from "@saleor/types/globalTypes"; import { IntlShape } from "react-intl"; diff --git a/src/utils/errors/permissionGroups.ts b/src/utils/errors/permissionGroups.ts index 6e70a13b6..7a3ee7ee7 100644 --- a/src/utils/errors/permissionGroups.ts +++ b/src/utils/errors/permissionGroups.ts @@ -1,5 +1,5 @@ +import { PermissionGroupErrorFragment } from "@saleor/fragments/types/PermissionGroupErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { PermissionGroupErrorFragment } from "@saleor/permissionGroups/types/PermissionGroupErrorFragment"; import { PermissionGroupErrorCode } from "@saleor/types/globalTypes"; import { defineMessages, IntlShape } from "react-intl"; diff --git a/src/utils/errors/product.ts b/src/utils/errors/product.ts index 30ccfdedc..215db391b 100644 --- a/src/utils/errors/product.ts +++ b/src/utils/errors/product.ts @@ -1,6 +1,6 @@ -import { ProductErrorFragment } from "@saleor/attributes/types/ProductErrorFragment"; +import { BulkProductErrorFragment } from "@saleor/fragments/types/BulkProductErrorFragment"; +import { ProductErrorFragment } from "@saleor/fragments/types/ProductErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { BulkProductErrorFragment } from "@saleor/products/types/BulkProductErrorFragment"; import { ProductErrorCode } from "@saleor/types/globalTypes"; import { defineMessages, IntlShape } from "react-intl"; diff --git a/src/utils/errors/shipping.ts b/src/utils/errors/shipping.ts index 4cdb1b8de..b12215f6b 100644 --- a/src/utils/errors/shipping.ts +++ b/src/utils/errors/shipping.ts @@ -1,5 +1,5 @@ +import { ShippingErrorFragment } from "@saleor/fragments/types/ShippingErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { ShippingErrorFragment } from "@saleor/shipping/types/ShippingErrorFragment"; import { ShippingErrorCode } from "@saleor/types/globalTypes"; import { defineMessages, IntlShape } from "react-intl"; diff --git a/src/utils/errors/shop.ts b/src/utils/errors/shop.ts index 7bb9efd99..485659907 100644 --- a/src/utils/errors/shop.ts +++ b/src/utils/errors/shop.ts @@ -1,5 +1,5 @@ +import { ShopErrorFragment } from "@saleor/fragments/types/ShopErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { ShopErrorFragment } from "@saleor/siteSettings/types/ShopErrorFragment"; import { ShopErrorCode } from "@saleor/types/globalTypes"; import { defineMessages, IntlShape } from "react-intl"; diff --git a/src/utils/errors/staff.ts b/src/utils/errors/staff.ts index cd529e758..0c82fde56 100644 --- a/src/utils/errors/staff.ts +++ b/src/utils/errors/staff.ts @@ -1,4 +1,4 @@ -import { StaffErrorFragment } from "@saleor/staff/types/StaffErrorFragment"; +import { StaffErrorFragment } from "@saleor/fragments/types/StaffErrorFragment"; import { IntlShape } from "react-intl"; import getAccountErrorMessage from "./account"; diff --git a/src/utils/errors/stock.ts b/src/utils/errors/stock.ts index 6307630d0..bf9f2eec1 100644 --- a/src/utils/errors/stock.ts +++ b/src/utils/errors/stock.ts @@ -1,6 +1,6 @@ +import { BulkStockErrorFragment } from "@saleor/fragments/types/BulkStockErrorFragment"; +import { StockErrorFragment } from "@saleor/fragments/types/StockErrorFragment"; import { commonMessages } from "@saleor/intl"; -import { BulkStockErrorFragment } from "@saleor/products/types/BulkStockErrorFragment"; -import { StockErrorFragment } from "@saleor/products/types/StockErrorFragment"; import { StockErrorCode } from "@saleor/types/globalTypes"; import { defineMessages, IntlShape } from "react-intl"; diff --git a/src/utils/errors/warehouse.ts b/src/utils/errors/warehouse.ts index 828c0d132..cc4b4c3be 100644 --- a/src/utils/errors/warehouse.ts +++ b/src/utils/errors/warehouse.ts @@ -1,6 +1,6 @@ +import { WarehouseErrorFragment } from "@saleor/fragments/types/WarehouseErrorFragment"; import { commonMessages } from "@saleor/intl"; import { WarehouseErrorCode } from "@saleor/types/globalTypes"; -import { WarehouseErrorFragment } from "@saleor/warehouses/types/WarehouseErrorFragment"; import { defineMessages, IntlShape } from "react-intl"; import commonErrorMessages from "./common"; diff --git a/src/utils/errors/webhooks.ts b/src/utils/errors/webhooks.ts index faacbce18..de82e0b86 100644 --- a/src/utils/errors/webhooks.ts +++ b/src/utils/errors/webhooks.ts @@ -1,6 +1,6 @@ +import { WebhookErrorFragment } from "@saleor/fragments/types/WebhookErrorFragment"; import { commonMessages } from "@saleor/intl"; import { WebhookErrorCode } from "@saleor/types/globalTypes"; -import { WebhookErrorFragment } from "@saleor/webhooks/types/WebhookErrorFragment"; import { IntlShape } from "react-intl"; import commonErrorMessages from "./common"; diff --git a/src/warehouses/components/WarehouseCreatePage/WarehouseCreatePage.tsx b/src/warehouses/components/WarehouseCreatePage/WarehouseCreatePage.tsx index 605032785..8f2b61748 100644 --- a/src/warehouses/components/WarehouseCreatePage/WarehouseCreatePage.tsx +++ b/src/warehouses/components/WarehouseCreatePage/WarehouseCreatePage.tsx @@ -9,12 +9,12 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo"; import { AddressTypeInput } from "@saleor/customers/types"; +import { WarehouseErrorFragment } from "@saleor/fragments/types/WarehouseErrorFragment"; import useAddressValidation from "@saleor/hooks/useAddressValidation"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { sectionNames } from "@saleor/intl"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; import { mapCountriesToChoices } from "@saleor/utils/maps"; -import { WarehouseErrorFragment } from "@saleor/warehouses/types/WarehouseErrorFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.tsx b/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.tsx index 47173d474..066857d24 100644 --- a/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.tsx +++ b/src/warehouses/components/WarehouseDetailsPage/WarehouseDetailsPage.tsx @@ -9,6 +9,7 @@ import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo"; import { AddressTypeInput } from "@saleor/customers/types"; +import { WarehouseErrorFragment } from "@saleor/fragments/types/WarehouseErrorFragment"; import useAddressValidation from "@saleor/hooks/useAddressValidation"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { sectionNames } from "@saleor/intl"; @@ -16,7 +17,6 @@ import { findValueInEnum, maybe } from "@saleor/misc"; import { CountryCode } from "@saleor/types/globalTypes"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; import { mapCountriesToChoices } from "@saleor/utils/maps"; -import { WarehouseErrorFragment } from "@saleor/warehouses/types/WarehouseErrorFragment"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/warehouses/components/WarehouseInfo/WarehouseInfo.tsx b/src/warehouses/components/WarehouseInfo/WarehouseInfo.tsx index 779411183..67643b451 100644 --- a/src/warehouses/components/WarehouseInfo/WarehouseInfo.tsx +++ b/src/warehouses/components/WarehouseInfo/WarehouseInfo.tsx @@ -2,11 +2,11 @@ import Card from "@material-ui/core/Card"; import CardContent from "@material-ui/core/CardContent"; import TextField from "@material-ui/core/TextField"; import CardTitle from "@saleor/components/CardTitle"; +import { WarehouseErrorFragment } from "@saleor/fragments/types/WarehouseErrorFragment"; import { FormChange } from "@saleor/hooks/useForm"; import { commonMessages } from "@saleor/intl"; import { getFormErrors } from "@saleor/utils/errors"; import getWarehouseErrorMessage from "@saleor/utils/errors/warehouse"; -import { WarehouseErrorFragment } from "@saleor/warehouses/types/WarehouseErrorFragment"; import React from "react"; import { useIntl } from "react-intl"; diff --git a/src/warehouses/components/WarehouseList/WarehouseList.tsx b/src/warehouses/components/WarehouseList/WarehouseList.tsx index e3099311d..4a28f3557 100644 --- a/src/warehouses/components/WarehouseList/WarehouseList.tsx +++ b/src/warehouses/components/WarehouseList/WarehouseList.tsx @@ -11,10 +11,10 @@ import ResponsiveTable from "@saleor/components/ResponsiveTable"; import Skeleton from "@saleor/components/Skeleton"; import TableCellHeader from "@saleor/components/TableCellHeader"; import TablePagination from "@saleor/components/TablePagination"; +import { WarehouseWithShippingFragment } from "@saleor/fragments/types/WarehouseWithShippingFragment"; import { maybe, renderCollection, stopPropagation } from "@saleor/misc"; import { ListProps, SortPage } from "@saleor/types"; import { getArrowDirection } from "@saleor/utils/sort"; -import { WarehouseWithShippingFragment } from "@saleor/warehouses/types/WarehouseWithShippingFragment"; import { WarehouseListUrlSortField } from "@saleor/warehouses/urls"; import React from "react"; import { FormattedMessage } from "react-intl"; diff --git a/src/warehouses/components/WarehouseListPage/WarehouseListPage.tsx b/src/warehouses/components/WarehouseListPage/WarehouseListPage.tsx index f81ea5455..6439c353f 100644 --- a/src/warehouses/components/WarehouseListPage/WarehouseListPage.tsx +++ b/src/warehouses/components/WarehouseListPage/WarehouseListPage.tsx @@ -4,6 +4,7 @@ import AppHeader from "@saleor/components/AppHeader"; import Container from "@saleor/components/Container"; import PageHeader from "@saleor/components/PageHeader"; import SearchBar from "@saleor/components/SearchBar"; +import { WarehouseWithShippingFragment } from "@saleor/fragments/types/WarehouseWithShippingFragment"; import { sectionNames } from "@saleor/intl"; import { PageListProps, @@ -11,7 +12,6 @@ import { SortPage, TabPageProps } from "@saleor/types"; -import { WarehouseWithShippingFragment } from "@saleor/warehouses/types/WarehouseWithShippingFragment"; import { WarehouseListUrlSortField } from "@saleor/warehouses/urls"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; diff --git a/src/warehouses/mutations.ts b/src/warehouses/mutations.ts index b41cd413d..57c9b962a 100644 --- a/src/warehouses/mutations.ts +++ b/src/warehouses/mutations.ts @@ -1,7 +1,8 @@ +import { warehouseErrorFragment } from "@saleor/fragments/errors"; +import { warehouseDetailsFragment } from "@saleor/fragments/warehouses"; import makeMutation from "@saleor/hooks/makeMutation"; import gql from "graphql-tag"; -import { warehouseDetailsFragment } from "./queries"; import { WarehouseCreate, WarehouseCreateVariables @@ -15,13 +16,6 @@ import { WarehouseUpdateVariables } from "./types/WarehouseUpdate"; -export const warehouseErrorFragment = gql` - fragment WarehouseErrorFragment on WarehouseError { - code - field - } -`; - const deleteWarehouse = gql` ${warehouseErrorFragment} mutation WarehouseDelete($id: ID!) { diff --git a/src/warehouses/queries.ts b/src/warehouses/queries.ts index 3f4ee4ff6..e93974635 100644 --- a/src/warehouses/queries.ts +++ b/src/warehouses/queries.ts @@ -1,6 +1,9 @@ +import { pageInfoFragment } from "@saleor/fragments/pageInfo"; +import { + warehouseDetailsFragment, + warehouseWithShippingFragment +} from "@saleor/fragments/warehouses"; import makeQuery from "@saleor/hooks/makeQuery"; -import { fragmentAddress } from "@saleor/orders/queries"; -import { pageInfoFragment } from "@saleor/queries"; import gql from "graphql-tag"; import { @@ -9,38 +12,6 @@ import { } from "./types/WarehouseDetails"; import { WarehouseList, WarehouseListVariables } from "./types/WarehouseList"; -export const warehouseFragment = gql` - fragment WarehouseFragment on Warehouse { - id - name - } -`; -export const warehouseWithShippingFragment = gql` - ${warehouseFragment} - fragment WarehouseWithShippingFragment on Warehouse { - ...WarehouseFragment - shippingZones(first: 100) { - edges { - node { - id - name - } - } - } - } -`; - -export const warehouseDetailsFragment = gql` - ${fragmentAddress} - ${warehouseWithShippingFragment} - fragment WarehouseDetailsFragment on Warehouse { - ...WarehouseWithShippingFragment - address { - ...AddressFragment - } - } -`; - const warehouseList = gql` ${warehouseWithShippingFragment} ${pageInfoFragment} diff --git a/src/webhooks/components/WebhookCreatePage/WebhookCreatePage.tsx b/src/webhooks/components/WebhookCreatePage/WebhookCreatePage.tsx index 7cd407acd..9eb616764 100644 --- a/src/webhooks/components/WebhookCreatePage/WebhookCreatePage.tsx +++ b/src/webhooks/components/WebhookCreatePage/WebhookCreatePage.tsx @@ -6,6 +6,7 @@ import FormSpacer from "@saleor/components/FormSpacer"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; +import { WebhookErrorFragment } from "@saleor/fragments/types/WebhookErrorFragment"; import { sectionNames } from "@saleor/intl"; import { SearchServiceAccount_search_edges_node } from "@saleor/searches/types/SearchServiceAccount"; import { WebhookEventTypeEnum } from "@saleor/types/globalTypes"; @@ -13,7 +14,6 @@ import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/single import WebhookEvents from "@saleor/webhooks/components/WebhookEvents"; import WebhookInfo from "@saleor/webhooks/components/WebhookInfo"; import WebhookStatus from "@saleor/webhooks/components/WebhookStatus"; -import { WebhookErrorFragment } from "@saleor/webhooks/types/WebhookErrorFragment"; import React from "react"; import { useIntl } from "react-intl"; diff --git a/src/webhooks/components/WebhookInfo/WebhookInfo.tsx b/src/webhooks/components/WebhookInfo/WebhookInfo.tsx index 0b3f0975b..e68b56e65 100644 --- a/src/webhooks/components/WebhookInfo/WebhookInfo.tsx +++ b/src/webhooks/components/WebhookInfo/WebhookInfo.tsx @@ -9,11 +9,11 @@ import Hr from "@saleor/components/Hr"; import SingleAutocompleteSelectField, { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; +import { WebhookErrorFragment } from "@saleor/fragments/types/WebhookErrorFragment"; import { ChangeEvent } from "@saleor/hooks/useForm"; import { commonMessages } from "@saleor/intl"; import { getFormErrors } from "@saleor/utils/errors"; import getWebhookErrorMessage from "@saleor/utils/errors/webhooks"; -import { WebhookErrorFragment } from "@saleor/webhooks/types/WebhookErrorFragment"; import React from "react"; import { useIntl } from "react-intl"; diff --git a/src/webhooks/components/WebhooksDetailsPage/WebhooksDetailsPage.tsx b/src/webhooks/components/WebhooksDetailsPage/WebhooksDetailsPage.tsx index c2d7c7ebb..3c378d5c2 100644 --- a/src/webhooks/components/WebhooksDetailsPage/WebhooksDetailsPage.tsx +++ b/src/webhooks/components/WebhooksDetailsPage/WebhooksDetailsPage.tsx @@ -6,6 +6,7 @@ import FormSpacer from "@saleor/components/FormSpacer"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; +import { WebhookErrorFragment } from "@saleor/fragments/types/WebhookErrorFragment"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { sectionNames } from "@saleor/intl"; import { getStringOrPlaceholder, maybe } from "@saleor/misc"; @@ -16,7 +17,6 @@ import WebhookEvents from "@saleor/webhooks/components/WebhookEvents"; import WebhookInfo from "@saleor/webhooks/components/WebhookInfo"; import WebhookStatus from "@saleor/webhooks/components/WebhookStatus"; import { WebhookDetails_webhook } from "@saleor/webhooks/types/WebhookDetails"; -import { WebhookErrorFragment } from "@saleor/webhooks/types/WebhookErrorFragment"; import { isUnnamed } from "@saleor/webhooks/utils"; import React from "react"; import { useIntl } from "react-intl"; diff --git a/src/webhooks/mutations.ts b/src/webhooks/mutations.ts index a6ec3f631..6e678b209 100644 --- a/src/webhooks/mutations.ts +++ b/src/webhooks/mutations.ts @@ -1,18 +1,12 @@ +import { webhookErrorFragment } from "@saleor/fragments/errors"; +import { webhooksDetailsFragment } from "@saleor/fragments/webhooks"; import gql from "graphql-tag"; import { TypedMutation } from "../mutations"; -import { webhooksDetailsFragment } from "./queries"; import { WebhookCreate, WebhookCreateVariables } from "./types/WebhookCreate"; import { WebhookDelete, WebhookDeleteVariables } from "./types/WebhookDelete"; import { WebhookUpdate, WebhookUpdateVariables } from "./types/WebhookUpdate"; -const webhookErrorFragment = gql` - fragment WebhookErrorFragment on WebhookError { - code - field - } -`; - const webhookCreate = gql` ${webhooksDetailsFragment} ${webhookErrorFragment} diff --git a/src/webhooks/queries.ts b/src/webhooks/queries.ts index 59333a398..419e8b6c9 100644 --- a/src/webhooks/queries.ts +++ b/src/webhooks/queries.ts @@ -1,3 +1,4 @@ +import { webhooksFragment } from "@saleor/fragments/webhooks"; import makeQuery from "@saleor/hooks/makeQuery"; import gql from "graphql-tag"; @@ -8,25 +9,6 @@ import { } from "./types/WebhookDetails"; import { Webhooks, WebhooksVariables } from "./types/Webhooks"; -export const webhooksFragment = gql` - fragment WebhookFragment on Webhook { - id - name - isActive - serviceAccount { - id - name - } - } -`; - -export const webhooksDetailsFragment = gql` - ${webhooksFragment} - fragment WebhooksDetailsFragment on Webhook { - ...WebhookFragment - } -`; - const webhooksList = gql` ${webhooksFragment} query Webhooks( diff --git a/src/webhooks/utils.ts b/src/webhooks/utils.ts index 4d056555c..fb4360a4b 100644 --- a/src/webhooks/utils.ts +++ b/src/webhooks/utils.ts @@ -1,4 +1,4 @@ -import { WebhookFragment } from "./types/WebhookFragment"; +import { WebhookFragment } from "@saleor/fragments/types/WebhookFragment"; export function isUnnamed(webhook: WebhookFragment): boolean { return ["", null].includes(webhook?.name);