-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[chore]: Move .graphql files from queries/ directory to the component directory where they are used #1928
Comments
Just chiming in from the Apollo caching perspective: I think this is fine, but we will want to use and share A good example is the Category page requesting details about a Product. To render its UI, the Category page only really needs a subset of that data (like We can create a "ProductDetails" fragment ProductDetails on ProductInterface {
media_gallery_entries
name
price
small_image
} and then we can re-use it in the Category and Product queries: products {
... ProductDetails
} The Category page will technically be overfetching data, but it'll make it so the PDP can serve data from the cache instead of having to make another request. All that said, I opened an issue (magento/graphql-ce#1027) because it seems like support for |
Yea, so |
Caveat: improves learning + onboarding new devs. It was super nice having all queries in the same folder so I could easily compare their structure, naming, etc. Also, I never would have noticed #1913 if the files were spread out in components. |
Happy to take this on. Seems like a good one to get familiar with the project. Thanks! |
@tjwiebell to fill in detail on expected pattern to follow for this issue. Also provide an example via a branch to provide a starting place. |
Given the scope of this, we're going to pull this internal as we work out the final resting place of queries and fragments. |
Goal
.graphql
from/queries
directory into the directory where they are used. For example,queries/createAccount.graphql
is used by theCreateAccount
component so we should move the graphql file tovenia-ui/lib/components/CreateAccount/
.queries/
and if so, it needs to be updated to check all locations for.graphql
instead.Expected Structure
<componentName>.gql.js
- for ease of use, the default export of this file should be an object ofqueries
andmutations
. Example here.It is expected that since multiple components imported these
.graphql
files, this will result in multiple components having identical operations; this is okay. Our current patterns outline that GraphQL reuse is driven by fragments, not operations, which is not a requirement in this scope. If you would like to tackle breaking response shapes into fragments, you can follow the patterns in some newer components on CartPage.<componentName>Fragments.gql.js
See here for more context.
The text was updated successfully, but these errors were encountered: