-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PWA-1101] Add support for Configurable Product Image Setting #2909
Closed
Closed
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a3571bd
PWA-1101: Add support for Configurable Product Image Setting
eug123 9dd3440
Merge remote-tracking branch 'mainline/develop' into PWA-1101
eug123 e3473b3
Merge remote-tracking branch 'mainline/develop' into PWA-1101
eug123 62c5f31
Merge remote-tracking branch 'mainline/develop' into PWA-1101
eug123 9761eec
PWA-1101: Add support for Configurable Product Image Setting
eug123 c177fdf
PWA-1101: Add support for Configurable Product Image Setting
eug123 a13ee69
PWA-1101: Add support for Configurable Product Image Setting
eug123 9ed01f9
PWA-1101: Add support for Configurable Product Image Setting
eug123 df03d74
Merge remote-tracking branch 'mainline/develop' into PWA-1101-alt
eug123 3e4a315
PWA-1101: Add support for Configurable Product Image Setting
eug123 e5d0883
Merge remote-tracking branch 'mainline/develop' into PWA-1101-alt
eug123 2e47d29
PWA-1101: Add support for Configurable Product Image Setting
eug123 4832fec
PWA-1101: Add support for Configurable Product Image Setting
eug123 4f42be9
Merge remote-tracking branch 'mainline/develop' into PWA-1101-alt
eug123 fbde172
PWA-1101: Add support for Configurable Product Image Setting
eug123 c87f224
PWA-1101: Add support for Configurable Product Image Setting
eug123 54690fb
Merge remote-tracking branch 'mainline/develop' into PWA-1101-alt
eug123 684e775
PWA-1101: Add support for Configurable Product Image Setting
eug123 94ed636
Merge remote-tracking branch 'mainline/develop' into PWA-1101-alt
eug123 d86361c
PWA-1101: Add support for Configurable Product Image Setting
eug123 2fa663a
Merge branch 'develop' into PWA-1101-alt
dpatil-magento 6da2ab0
Merge branch 'develop' into PWA-1101-alt
dpatil-magento File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Custom type policies that allow us to have more granular control | ||
* over how ApolloClient reads from and writes to the cache. | ||
* | ||
* https://www.apollographql.com/docs/react/caching/cache-configuration/#typepolicy-fields | ||
* https://www.apollographql.com/docs/react/caching/cache-field-behavior/ | ||
*/ | ||
const temporaryTypePolicies = { | ||
StoreConfig: { | ||
fields: { | ||
// This field is available in Magento 2.4.2 we need to support older versions, so env var is used here | ||
configurable_thumbnail_source: { | ||
read() { | ||
return process.env.CONFIGURABLE_THUMBNAIL_SOURCE; | ||
} | ||
} | ||
} | ||
}, | ||
ConfigurableCartItem: { | ||
fields: { | ||
// This field is proposed in the https://github.com/magento/magento2/pull/30817 | ||
configured_variant: { | ||
read(_, { readField, toReference }) { | ||
const product = readField('product'); | ||
const optionUids = readField('configurable_options') | ||
.map(option => { | ||
const id = readField( | ||
'id', | ||
toReference(option.__ref) | ||
); | ||
const value_id = readField( | ||
'value_id', | ||
toReference(option.__ref) | ||
); | ||
return new Buffer( | ||
`configurable/${id}/${value_id}` | ||
).toString('base64'); | ||
}) | ||
.sort() | ||
.toString(); | ||
|
||
return readField('variants', product) | ||
.map(variant => { | ||
const variantUids = variant.attributes | ||
.map(attribute => attribute.uid) | ||
.sort() | ||
.toString(); | ||
return ( | ||
variantUids === optionUids && variant.product | ||
); | ||
}) | ||
.filter(Boolean)[0]; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
export default temporaryTypePolicies; |
18 changes: 18 additions & 0 deletions
18
packages/peregrine/lib/talons/CartPage/ProductListing/product.gql.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
// We disable linting for local fields because there is no way to add them to | ||
// the fetched schema. | ||
// https://github.com/apollographql/eslint-plugin-graphql/issues/99 | ||
/* eslint-disable graphql/template-strings */ | ||
export const GET_CONFIGURABLE_THUMBNAIL_SOURCE = gql` | ||
query getConfigurableThumbnailSource { | ||
storeConfig { | ||
id | ||
configurable_thumbnail_source @client | ||
} | ||
} | ||
`; | ||
|
||
export default { | ||
getConfigurableThumbnailSource: GET_CONFIGURABLE_THUMBNAIL_SOURCE | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
// We disable linting for local fields because there is no way to add them to | ||
// the fetched schema. | ||
// https://github.com/apollographql/eslint-plugin-graphql/issues/99 | ||
/* eslint-disable graphql/template-strings */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here re: re-enabling this lint rule, although you may be able to just remove |
||
export const GET_CONFIGURABLE_THUMBNAIL_SOURCE = gql` | ||
query getConfigurableThumbnailSource { | ||
storeConfig { | ||
id | ||
configurable_thumbnail_source @client | ||
} | ||
} | ||
`; | ||
|
||
export default { | ||
getConfigurableThumbnailSource: GET_CONFIGURABLE_THUMBNAIL_SOURCE | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we support
n
now, instead ofn-1
, do we need to mock this? By the time this code is released in PWA Studio, 2.4.2 should be released so I think this is fine to remove.