-
Notifications
You must be signed in to change notification settings - Fork 686
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
Super basic implementation of category page using apollo client for data fetching #52
Conversation
@@ -13,7 +13,7 @@ | |||
"url": "https://github.com/magento-research/peregrine" | |||
}, | |||
"scripts": { | |||
"build": "babel src -d dist --ignore test.js", | |||
"build": "babel src -d dist --ignore '*.test.js,*.spec.js'", |
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.
No need to build the test files for distributing. But I also caught this generating built test artifacts, so jest would run all tests twice. Random tech debt from monorepo move
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.
We were using .spec.js
for most of initial development, IIRC. When did we start having .test.js
files, and why? Should change them.
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.
When did we start having .test.js files
October 31, 2017. We can change it in a separate PR
5f25e3a
to
5e005ff
Compare
[ | ||
1, | ||
{ | ||
id: 1, |
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.
The tests for List
and its child components have been updated as of #62, using almost the same sample data you've got here. You can probably delete these test changes.
Also, I think it's better to have id
be a string
instead of a number
. Is that something we can accomplish with our query?
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.
You can't cast in a GraphQL query, so we'd have to cast on the client anytime that data came in. That would be a PITA, because any query that takes id
as an arg would have to be cast back to a number.
gallery: PropTypes.string, | ||
root: PropTypes.string, | ||
title: PropTypes.string | ||
id: number, |
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.
Likewise, can id
be a string
?
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.
See #52 (comment)
currency: string.isRequired | ||
}).isRequired | ||
}).isRequired | ||
}).isRequired |
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.
If an item doesn't have a price, will this full shape be present anyway? Will it just be $0.00
all the way down?
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.
May just be something we have to find out. I'd expect it to always be present, but the schema doesn't have enough info to really tell me.
It's not marked as a non-nullable field in the schema, but I haven't seen that team make much use of non-nullable fields anywhere.
Pinging @eric-bohanon + @paliarush
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.
We are currently not using non-nullable fields in GraphQL schema, but it makes sense to consider this as an improvement. @DrewML feel free to create an issue in magento/graphql-ce project listing any fields that you believe should be made non-nullable.
Pull Request Test Coverage Report for Build 138
💛 - Coveralls |
@DrewML Ok, if you resolve conflicts (probably with the |
@jimbo updated. Luckily conflict was easy |
Basic implementation of a GraphQL query for product details. Builds on #52 by replicating the inline query declaration. Had to plumb out the child components for the new data shape; in doing so, I made a few reusable functions. - Added GraphQL query to `packages/venia-concept/src/RootComponents/Product.js`. - Resolves from URL by using the `url_key` in a GraphQL query. - Can also resolve by SKU. - Modified prop types and render method to accommodate live data shape. - Added `<Currency />` component whose signature matches the Magento GraphQl `Money` type. - Uses the `window.Intl` standard object to format. - Modified the `Gallery` and `ProductImageCarousel` components to use new data shape. - Moved shared constant data URIs to a single `src/shared` folder, to replicate placeholder logic. - Created a shared `propShapes.js` file containing commonly used prop type expressions. - Anticipating that `url_key` would be a common way to navigate, I made a `url_key` utility function. - Added a `makeProductMediaPath` utility function, for turning product image file paths from API responses into relative URLs. - Though [magento/graphql-ce/issues/88](magento/graphql-ce#88) is still a problem for production, I found that **when `magento-sample-data` is installed, it symlinks into the `pub/media` folder so you can use simpler URLs.** - You can see this for yourself with `ls -l <magento-root>/pub/media/catalog/product`. - So I added a `makePathPrepender` function, which we'll later use often, that can create functions like `makeProductMediaPath`. - I hardcoded `/media/catalog/products` in the code, but I also added an environment variable to `.env` and `webpack.config.js` for configuring that URL per instance. - Optimize queries with fragments - Centralize queries in query file to be preprocessed - Make link to product detail on category page - Resolve media URL issue - Test with image galleries Closes #87.
Basic implementation of a GraphQL query for product details. Builds on #52 by replicating the inline query declaration. Had to plumb out the child components for the new data shape; in doing so, I made a few reusable functions. - Added GraphQL query to `packages/venia-concept/src/RootComponents/Product.js`. - Resolves from URL by using the `url_key` in a GraphQL query. - Can also resolve by SKU. - Modified prop types and render method to accommodate live data shape. - Added `<Currency />` component whose signature matches the Magento GraphQl `Money` type. - Uses the `window.Intl` standard object to format. - Modified the `Gallery` and `ProductImageCarousel` components to use new data shape. - Moved shared constant data URIs to a single `src/shared` folder, to replicate placeholder logic. - Created a shared `propShapes.js` file containing commonly used prop type expressions. - Anticipating that `url_key` would be a common way to navigate, I made a `url_key` utility function. - Added a `makeProductMediaPath` utility function, for turning product image file paths from API responses into relative URLs. - Though [magento/graphql-ce/issues/88](magento/graphql-ce#88) is still a problem for production, I found that **when `magento-sample-data` is installed, it symlinks into the `pub/media` folder so you can use simpler URLs.** - You can see this for yourself with `ls -l <magento-root>/pub/media/catalog/product`. - So I added a `makePathPrepender` function, which we'll later use often, that can create functions like `makeProductMediaPath`. - I hardcoded `/media/catalog/products` in the code, but I also added an environment variable to `.env` and `webpack.config.js` for configuring that URL per instance. - Optimize queries with fragments - Centralize queries in query file to be preprocessed - Make link to product detail on category page - Resolve media URL issue - Test with image galleries Closes #87.
Basic implementation of a GraphQL query for product details. Builds on #52 by replicating the inline query declaration. Had to plumb out the child components for the new data shape; in doing so, I made a few reusable functions. - Added GraphQL query to `packages/venia-concept/src/RootComponents/Product.js`. - Resolves from URL by using the `url_key` in a GraphQL query. - Can also resolve by SKU. - Modified prop types and render method to accommodate live data shape. - Added `<Currency />` component whose signature matches the Magento GraphQl `Money` type. - Uses the `window.Intl` standard object to format. - Modified the `Gallery` and `ProductImageCarousel` components to use new data shape. - Moved shared constant data URIs to a single `src/shared` folder, to replicate placeholder logic. - Created a shared `propShapes.js` file containing commonly used prop type expressions. - Anticipating that `url_key` would be a common way to navigate, I made a `url_key` utility function. - Added a `makeProductMediaPath` utility function, for turning product image file paths from API responses into relative URLs. - Though [magento/graphql-ce/issues/88](magento/graphql-ce#88) is still a problem for production, I found that **when `magento-sample-data` is installed, it symlinks into the `pub/media` folder so you can use simpler URLs.** - You can see this for yourself with `ls -l <magento-root>/pub/media/catalog/product`. - So I added a `makePathPrepender` function, which we'll later use often, that can create functions like `makeProductMediaPath`. - I hardcoded `/media/catalog/products` in the code, but I also added an environment variable to `.env` and `webpack.config.js` for configuring that URL per instance. - Optimize queries with fragments - Centralize queries in query file to be preprocessed - Make link to product detail on category page - Resolve media URL issue - Test with image galleries Closes #87.
Basic implementation of a GraphQL query for product details. Builds on #52 by replicating the inline query declaration. Had to plumb out the child components for the new data shape; in doing so, I made a few reusable functions. - Added GraphQL query to `packages/venia-concept/src/RootComponents/Product.js`. - Resolves from URL by using the `url_key` in a GraphQL query. - Can also resolve by SKU. - Modified prop types and render method to accommodate live data shape. - Added `<Currency />` component whose signature matches the Magento GraphQl `Money` type. - Uses the `window.Intl` standard object to format. - Modified the `Gallery` and `ProductImageCarousel` components to use new data shape. - Moved shared constant data URIs to a single `src/shared` folder, to replicate placeholder logic. - Created a shared `propShapes.js` file containing commonly used prop type expressions. - Anticipating that `url_key` would be a common way to navigate, I made a `url_key` utility function. - Added a `makeProductMediaPath` utility function, for turning product image file paths from API responses into relative URLs. - Though [magento/graphql-ce/issues/88](magento/graphql-ce#88) is still a problem for production, I found that **when `magento-sample-data` is installed, it symlinks into the `pub/media` folder so you can use simpler URLs.** - You can see this for yourself with `ls -l <magento-root>/pub/media/catalog/product`. - So I added a `makePathPrepender` function, which we'll later use often, that can create functions like `makeProductMediaPath`. - I hardcoded `/media/catalog/products` in the code, but I also added an environment variable to `.env` and `webpack.config.js` for configuring that URL per instance. - Optimize queries with fragments - Centralize queries in query file to be preprocessed - Make link to product detail on category page - Resolve media URL issue - Test with image galleries Closes #87.
Basic implementation of a GraphQL query for product details. Builds on #52 by replicating the inline query declaration. Had to plumb out the child components for the new data shape; in doing so, I made a few reusable functions. - Added GraphQL query to `packages/venia-concept/src/RootComponents/Product.js`. - Resolves from URL by using the `url_key` in a GraphQL query. - Can also resolve by SKU. - Modified prop types and render method to accommodate live data shape. - Added `<Currency />` component whose signature matches the Magento GraphQl `Money` type. - Uses the `window.Intl` standard object to format. - Modified the `Gallery` and `ProductImageCarousel` components to use new data shape. - Moved shared constant data URIs to a single `src/shared` folder, to replicate placeholder logic. - Created a shared `propShapes.js` file containing commonly used prop type expressions. - Anticipating that `url_key` would be a common way to navigate, I made a `url_key` utility function. - Added a `makeProductMediaPath` utility function, for turning product image file paths from API responses into relative URLs. - Though [magento/graphql-ce/issues/88](magento/graphql-ce#88) is still a problem for production, I found that **when `magento-sample-data` is installed, it symlinks into the `pub/media` folder so you can use simpler URLs.** - You can see this for yourself with `ls -l <magento-root>/pub/media/catalog/product`. - So I added a `makePathPrepender` function, which we'll later use often, that can create functions like `makeProductMediaPath`. - I hardcoded `/media/catalog/products` in the code, but I also added an environment variable to `.env` and `webpack.config.js` for configuring that URL per instance. - Optimize queries with fragments - Centralize queries in query file to be preprocessed - Make link to product detail on category page - Resolve media URL issue - Test with image galleries Closes #87.
Note This branch surfaced an issue with the unit/integration test setup in the monorepo. Freezing work on this branch until I've completed #54.Closes #20
This PR is a:
[ ] New feature
[X] Enhancement/Optimization
[ ] Refactor
[ ] Bugfix
[ ] Test for existing code
[ ] Documentation
Summary
Same code from magento-research/venia-pwa-concept#89, now moved over and tests fixed.
Additional information