Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

Commit

Permalink
Add channel parameter to the collection queries (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofwolski authored Nov 20, 2020
1 parent 1c17431 commit e663cc3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/views/Collection/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { prodListHeaderCommonMsg } from "@temp/intl";
import { IFilters } from "@types";
import { StringParam, useQueryParam } from "use-query-params";
import { Loader, OfflinePlaceholder } from "@components/atoms";
import { channelSlug } from "@temp/constants";
import { MetaWrapper, NotFound } from "../../components";
import NetworkStatus from "../../components/NetworkStatus";
import { PRODUCTS_PER_PAGE } from "../../core/config";
Expand Down Expand Up @@ -99,6 +100,7 @@ export const View: React.FC<ViewProps> = ({ match }) => {
: {},
id: getGraphqlIdFromDBId(match.params.id, "Collection"),
sortBy: convertSortByFromString(filters.sortBy),
channel: channelSlug,
};

const sortOptions = [
Expand Down
1 change: 1 addition & 0 deletions src/views/Collection/gqlTypes/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ export interface Collection {

export interface CollectionVariables {
id: string;
channel: string;
}
1 change: 1 addition & 0 deletions src/views/Collection/gqlTypes/CollectionProducts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,5 @@ export interface CollectionProductsVariables {
sortBy?: ProductOrder | null;
priceLte?: number | null;
priceGte?: number | null;
channel: string;
}
14 changes: 10 additions & 4 deletions src/views/Collection/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
} from "./gqlTypes/CollectionProducts";

export const collectionProductsDataQuery = gql`
query Collection($id: ID!) {
collection(id: $id) {
query Collection($id: ID!, $channel: String!) {
collection(id: $id, channel: $channel) {
id
slug
name
Expand All @@ -24,7 +24,11 @@ export const collectionProductsDataQuery = gql`
}
}
attributes(
filter: { inCollection: $id, filterableInStorefront: true }
filter: {
channel: $channel
inCollection: $id
filterableInStorefront: true
}
first: 100
) {
edges {
Expand Down Expand Up @@ -59,14 +63,16 @@ export const collectionProductsQuery = gql`
$sortBy: ProductOrder
$priceLte: Float
$priceGte: Float
$channel: String!
) {
collection(id: $id) {
collection(id: $id, channel: $channel) {
id
products(
after: $after
first: $pageSize
sortBy: $sortBy
filter: {
channel: $channel
attributes: $attributes
minimalPrice: { gte: $priceGte, lte: $priceLte }
}
Expand Down

0 comments on commit e663cc3

Please sign in to comment.