-
Notifications
You must be signed in to change notification settings - Fork 248
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add codegen to demo-store #937
Conversation
totalTaxV2 { | ||
...Money | ||
} | ||
totalPrice { | ||
totalPriceV2 { | ||
...Money | ||
} | ||
subtotalPrice { | ||
subtotalPriceV2 { |
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 accessing xyzV2
in code but not requesting it here... 馃く
...CustomerDetails | ||
} | ||
} | ||
|
||
fragment CustomerDetails on Customer { |
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.
Extracting this as a fragment so that we can import the CustomerDetailsFragment
generated type.
const policies = Object.values( | ||
data.shop as NonNullableFields<typeof data.shop>, | ||
).filter(Boolean); |
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 NonNullableFields
utility is just representing what the filter(Boolean)
is doing, removing null
from the array.
This comment has been minimized.
This comment has been minimized.
featuredData: any; // @todo: help please | ||
featuredData: Promise<{ | ||
featuredProducts: ProductCardFragment[]; | ||
featuredCollections: FeaturedCollectionDetailsFragment[]; | ||
}>; |
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.
@juanpprieto 馃槵
If there's an |
Not necessarily. Someone could query collections() {
edges {
cursor
}
} hypothetically. https://shopify.dev/docs/api/storefront/2023-01/objects/CollectionEdge 馃し |
Can you point me to an example of where this issue is? Thanks! |
Sure, right here:
There are a few Perhaps related to using |
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.
LGTM, also pulled the branch and tried to regression test the whole demo-store.
I'm not sure how to version the demostore. What is a breaking change when anything we add requires the merchant to update their store if they want the applied changes? I'd be fine with leaving it as minor, unless someone else has a strong opinion |
|
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.
@juanpprieto This is what I meant yesterday in our sync. A component can also export a GQL fragment that can be imported in parent queries that use this component. This way the component decides what it needs, and it can use the generated xyzFragment
type as props.
Thoughts?
Related #887
Closes #939
This PR adds generated types to most of the files of the the demo-store. There are still 2 or 3 remaining that require heavier changes.
I've fixed some bugs while doing this, mostly due to missing fields in queries that were supposed to be used later for SEO or related.
Questions:
demo-store@2.0.0
?flattenConnection
has a problem with some of the generated types. Some times, the generated type has{edges: {node: Array<Stuff>}}
but flattenConnection expects{edges: {node?: Array<Stuff>}}
, with that optional?
. @frehner any idea how to fix this? 馃