Skip to content

Commit 7c9d82b

Browse files
committed
fix: update withTag query for breaking API param changes
Signed-off-by: Eric Dobbertin <[email protected]>
1 parent 8a5f7c2 commit 7c9d82b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/containers/tags/tag.gql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#import "./tagFragment.gql"
22

3-
query tagQuery($slugOrId: String) {
4-
tag(slugOrId: $slugOrId) {
3+
query tagQuery($shopId: ID!, $slugOrId: String!) {
4+
tag(shopId: $shopId, slugOrId: $slugOrId) {
55
...TagInfo
66
}
77
}

src/containers/tags/withTag.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import tagQuery from "./tag.gql";
1212
* @returns {React.Component} - Component with `tag` prop
1313
*/
1414
export default function withTag(Component) {
15-
@inject("routingStore")
15+
@inject("primaryShopId", "routingStore")
1616
@observer
1717
class WithTag extends React.Component {
1818
static propTypes = {
19+
primaryShopId: PropTypes.string.isRequired,
1920
/**
2021
* slug used to obtain tag info
2122
*/
@@ -27,14 +28,19 @@ export default function withTag(Component) {
2728

2829
render() {
2930
const {
31+
primaryShopId,
3032
router: { query: { slug: slugFromQueryParam } },
3133
routingStore: { tagId }
3234
} = this.props;
3335

3436
const slugOrId = slugFromQueryParam || tagId;
3537

38+
if (!primaryShopId || !slugOrId) {
39+
return <Component {...this.props} />;
40+
}
41+
3642
return (
37-
<Query query={tagQuery} variables={{ slugOrId }}>
43+
<Query query={tagQuery} variables={{ shopId: primaryShopId, slugOrId }}>
3844
{({ error, data }) => {
3945
if (error) {
4046
console.error("WithTag query error:", error); // eslint-disable-line no-console

0 commit comments

Comments
 (0)