Merge pull request #249 from mirumee/fix/subcategories-pagination

Fix subcategories pagination
This commit is contained in:
Marcin Gębala 2019-11-12 16:37:37 +01:00 committed by GitHub
commit 09295a5d16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 14 deletions

View file

@ -6,6 +6,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Fix minor bugs - #244 by @dominik-zeglen
- Fix tax settings updating - #243 by @dominik-zeglen
- Fix subcategories pagination - #249 by @dominik-zeglen
## 2.0.0

View file

@ -93,7 +93,14 @@ export const category: (
},
children: {
__typename: "CategoryCountableConnection",
edges: []
edges: [],
pageInfo: {
__typename: "PageInfo",
endCursor: "YXJyYXljb25uZWN0aW9uOjk=",
hasNextPage: false,
hasPreviousPage: false,
startCursor: "YXJyYXljb25uZWN0aW9uOjA="
}
},
descriptionJson: JSON.stringify(content),
id: "Q2F0ZWdvcnk6NA==",

View file

@ -1,6 +1,6 @@
import gql from "graphql-tag";
import { TypedQuery } from "../queries";
import { pageInfoFragment, TypedQuery } from "../queries";
import {
CategoryDetails,
CategoryDetailsVariables
@ -38,6 +38,7 @@ export const categoryDetailsFragment = gql`
export const rootCategories = gql`
${categoryFragment}
${pageInfoFragment}
query RootCategories(
$first: Int
$after: String
@ -59,10 +60,7 @@ export const rootCategories = gql`
}
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
...PageInfoFragment
}
}
}
@ -74,6 +72,7 @@ export const TypedRootCategoriesQuery = TypedQuery<RootCategories, {}>(
export const categoryDetails = gql`
${categoryFragment}
${categoryDetailsFragment}
${pageInfoFragment}
query CategoryDetails(
$id: ID!
$first: Int
@ -83,19 +82,19 @@ export const categoryDetails = gql`
) {
category(id: $id) {
...CategoryDetailsFragment
children(first: 20) {
children(first: $first, after: $after, last: $last, before: $before) {
edges {
node {
...CategoryFragment
}
}
pageInfo {
...PageInfoFragment
}
}
products(first: $first, after: $after, last: $last, before: $before) {
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
...PageInfoFragment
}
edges {
cursor

View file

@ -40,9 +40,18 @@ export interface CategoryDetails_category_children_edges {
node: CategoryDetails_category_children_edges_node;
}
export interface CategoryDetails_category_children_pageInfo {
__typename: "PageInfo";
endCursor: string | null;
hasNextPage: boolean;
hasPreviousPage: boolean;
startCursor: string | null;
}
export interface CategoryDetails_category_children {
__typename: "CategoryCountableConnection";
edges: CategoryDetails_category_children_edges[];
pageInfo: CategoryDetails_category_children_pageInfo;
}
export interface CategoryDetails_category_products_pageInfo {

View file

@ -162,7 +162,9 @@ export const CategoryDetails: React.FC<CategoryDetailsProps> = ({
};
const { loadNextPage, loadPreviousPage, pageInfo } = paginate(
maybe(() => data.category.products.pageInfo),
params.activeTab === CategoryPageTab.categories
? maybe(() => data.category.children.pageInfo)
: maybe(() => data.category.products.pageInfo),
paginationState,
params
);

View file

@ -2,7 +2,12 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { SiteDomainInput, ShopSettingsInput, AddressInput, AuthorizationKeyType } from "./../../types/globalTypes";
import {
SiteDomainInput,
ShopSettingsInput,
AddressInput,
AuthorizationKeyType
} from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: ShopSettingsUpdate
@ -143,5 +148,5 @@ export interface ShopSettingsUpdate {
export interface ShopSettingsUpdateVariables {
shopDomainInput: SiteDomainInput;
shopSettingsInput: ShopSettingsInput;
addressInput: AddressInput;
addressInput?: AddressInput | null;
}