-
-
Notifications
You must be signed in to change notification settings - Fork 75
Shopify category driver #3578
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
base: develop
Are you sure you want to change the base?
Shopify category driver #3578
Conversation
griest024
left a comment
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.
Nice work! Just a couple of minor things to change.
| handle | ||
| id | ||
| title | ||
| description | ||
| onlineStoreUrl | ||
| image { | ||
| altText | ||
| id | ||
| url | ||
| } | ||
| products(first: 10, reverse: $reverse, sortKey: $sortKey, filters: $filters) { | ||
| nodes { | ||
| handle | ||
| onlineStoreUrl | ||
| availableForSale | ||
| priceRange { | ||
| maxVariantPrice { | ||
| amount | ||
| currencyCode | ||
| } | ||
| minVariantPrice { | ||
| amount | ||
| currencyCode | ||
| } | ||
| } | ||
| id | ||
| title | ||
| description | ||
| images(first: 1) { | ||
| nodes { | ||
| id | ||
| url | ||
| altText | ||
| } | ||
| } |
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.
This type should be broken down into a few fragments. I'd say you should make Collection, Image, Product, and Price fragments.
| * @param sortkey - string | ||
| * @returns ShopifyProductCollectionSortKeys | ||
| */ | ||
| export const shopifyProductCollectionSortKeyValidator = (sortkey: string): ShopifyProductCollectionSortKeys => { |
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.
This doesn't feel like a validator to me. IMO, a validator does not change the response, only ensures that it meets a spec, and if not, throws an error. I think this function is valuable, but its more of a coercion than a validator. Its definitely a minor issue but still important for maintaining proper separation of concerns. Its possible that there are other validators in the codebase that do change the response, and they're wrong to do so, IMO.
@damienwebdev As an aside, I feel like there's an opportunity to define what a validator is in the context of a driver. I think its a function that takes the response and returns void. Any influence it has should only be with throwing errors. i.e.:
export type DaffDriverGraphqlValidator<T> = (response: ApolloQueryResult<T>) => void| * @param node - ShopifyImageNode | ||
| * @param type - 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.
Its unnecessary to annotate params with the type in TS, the type will be pulled from the function signature. If you want to add descriptions, that's a good place. For example
/**
* Transforms the magento CartPayment from the magento cart query into a DaffCartPaymentMethod.
*
* @param responsePayment - the response from a magento cart query.
*/
transform(responsePayment: MagentoCartPaymentMethod): DaffCartPaymentMethod| import { ShopifyImageNode } from '@daffodil/driver/shopify'; | ||
|
|
||
| class MockShopifyImageNode implements ShopifyImageNode { | ||
| id = ''; |
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.
Faker should have a uuid generator that you can use here.
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 string is meant to be empty. If you follow the logic, the id is supposed to be empty, and is filled out later based on what kind of ImageNode is meant to be created (e.g. ProductImage, CollectionImage, etc.). I don't think Shopify uses uuid anyways.
Here are some examples of a Shopify id:
gid://shopify/Product/7807187157028
gid://shopify/Collection/463004860452
gid://shopify/ProductImage/34216320925732
… driver + improvements to shopify libs/driver package
…uestTransformer by refactoring conditional statements
09e1e15 to
1e1ba56
Compare
|
As the PR most likely won't be fully merged by the time my internship ends, I just wanted to leave a few notes. Some of these are not specific to category, but relevant to Shopify in general. The shopify category driver is complete and implements all required functionality. However, there are a few considerations. DaffFilterRequest Structure Or vs And Filters in Shopify
Schema + codegen workflow
Download the latest Storefront schema: Generate TS types & operations: CodeClimate Errors PR Breakdown: Shopify driver – extra transforms, shared fragments, general reorganization of the driver (split into commits) Shopify Category service – new queries, category-specific transforms, etc. Product query – modify existing product query and category service spec to accommodate the fragment changes |

PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Shopify category driver has not been implemented at all.
Fixes: N/A
What is the new behavior?
Shopify category driver has been implemented fully. Most of the functionality is complete with a few missing parts (potentially blocked by missing product/driver features - todo): specifically breadcrumbs, pagination, and some product filtering options (todo). These issues should not affect the the functionality of the category driver.
Does this PR introduce a breaking change?
Other information