-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat(demo): update shopify driver usage in demo #3457
base: develop
Are you sure you want to change the base?
Conversation
: reqInfo.utils.createResponse$(() => ({ | ||
status: STATUS.NOT_FOUND, | ||
statusText: `Backend ${reqInfo.collectionName} not found or does not support the ${method} request method`, | ||
})); | ||
: undefined; |
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.
What is the motivation for this change?
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.
I think I accidentally deleted this line when I was experimenting with some things in an attempt to debug an issue I was having a while ago. Sorry.
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.
To clarify, I didn't mean to make this change and will undo it.
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.
@griest024 @leozhang14 this change is necessary in order to use the Shopify driver with the in-memory backend enabled.
Without it, the passThru
feature of the in-memory backend doesn't work as expected.
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.
hmm can you repro the use case in an integration test in a separate PR? I don't follow.
Run the tests in a browser and check your console for errors. I suspect its because the flushed data doesn't conform to your new |
@leozhang14 has any code in this PR been generated by AI tools? |
This was the issue, thanks. I'll look into the "testing package" for magento more. Just to confirm, it would be more appropriate to make this change in a separate PR, correct? |
Just these lines below were generated with AI, to perform the check in getByUrl to see if any product in the list of products had a matching URL. const matchedProduct = products.find((edge) => edge.node.onlineStoreUrl === url)?.node; Apologies if this was an issue—I wasn’t sure if using AI tools was against guidelines. Could you clarify if this is acceptable? Sorry in advance if I misunderstood. |
its allowed but our contribution rules state that you must openly disclose it in the description of your PR. It's not a big deal and we really don't make that notice very prominent but its good for reviewers to know so we can pay extra close attention. Also, in my personal opinion, while I think AI can be a powerful and potentially valuable tool in programming, its important to make sure you always understand the code that you end up using (whether generated by AI or copied from SO, etc.). AI should be a labor-saving tool not a skill crutch. Overall, whatever results in the best final product is fine by me. |
Generally, the factories for a model should be introduced in the same PR that the models themselves are. I would be okay with adding them to this PR but if you wanted to extract the model + factory change to its own PR, that's fine too. |
I will try to add the model + factory changes to this PR as well. Thanks for the advice. |
…discount + modify url transform to match DaffLocatable definition
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.
I'm liking the changes so far!
export interface ShopifyMoneyV2 { | ||
amount: number; | ||
currencyCode: 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.
This model (and the associated factory) should be in @daffodil/driver/shopify
as it is a generic model and doesn't have anything to do with products specifically. I really like how you are breaking up the types!
@griest024 @leozhang14 instead of manually defining the types, as we have, what if instead we use graphql-codegen to only gen the types our queries use. This does mean that factories may break if we modify the outgoing query, but it will make the maintenance devx a bit nicer. |
Re: #3457 (comment) (IDK why Github wont let me comment in line) I'd vote for |
I like this idea. Anything to relieve maintenance burden |
…later to accomodate graphql-codegen changes
Will we implement this using the Shopify CLI? Also, should this change be in this PR, or another one? |
Id say do what works, I have no strong opinion |
…fy as it is not specific to product
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 need to use child factories where appropriate. Factories should only mock out the fields that their corresponding type declares. So ShopifyProductGraph
only has one field: nodes
, MockShopifyProductGraph
should only mock out nodes
at the top level and rely on the child factory mock to handle its internal fields.
{ | ||
id: `gid://shopify/ProductImage/${faker.datatype.number({ min: 10000000000 })}`, | ||
url: faker.image.imageUrl(), | ||
altText: faker.random.words(5), | ||
}, |
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.
Same here, use the child factory
nodes: [ | ||
{ | ||
id: `gid://shopify/ProductImage/${faker.datatype.number({ min: 10000000000 })}`, | ||
url: faker.image.imageUrl(), | ||
altText: faker.random.words(5), | ||
}, | ||
], |
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.
Use ShopifyProductImagesFactory.createMany
to generate these. See DaffCategoryFactory
for an example of how to use child factories.
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.
I like this change!
libs/driver/shopify/ng-package.json
Outdated
@@ -0,0 +1,6 @@ | |||
{ | |||
"$schema": "../../node_modules/ng-packagr/ng-entrypoint.schema.json", |
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.
I think this needs three ../
, make sure this path resolves.
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.
Remove this empty file
… files + delete empty shopify-module.ts file
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Implementation of the Shopify product driver.
What is the current behavior?
Old code that does not work. Uses shop to query (not supported in Shopify Storefront 2025/01).
Fixes: N/A
What is the new behavior?
get (url), getAll, getByURL, and getBestSellers should all function properly.
Does this PR introduce a breaking change?
Has effects on the demo app, as well as the product library since the shopify driver service files have been modified.
Other information
IMPORTANT:
I don't know how to test the get and getByURL methods as they return observables. I will have to look into this more. I am also running into an issue with the testing for getAll and get, although the daffodil demo seems to work?
Chrome 131.0.0.0 (Mac OS 10.15.7) Driver | Shopify | Product | ProductService getAll | getting a list of products should should return an observable array of 20 products by default FAILED
Error: Expected 0 to equal 20.
Chrome 131.0.0.0 (Mac OS 10.15.7) Driver | Shopify | Product | ProductService get | getting a single product should return an observable single product FAILED
Error: Expected undefined to equal 'bd0de172-3fbd-4e17-8e61-f6d73ff876c3'