Skip to content
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

Support customer account API in hydrogen-codegen #1569

Merged
merged 7 commits into from
Dec 14, 2023

Conversation

frandiox
Copy link
Contributor

This PR only adds default values for Customer Account API in hydrogen-codegen just like we have for Storefront API.

Usage in codegen.ts:

import {pluckConfig, preset, getSchema} from '@shopify/hydrogen-codegen';

export default {
  overwrite: true,
  pluckConfig,
  generates: {
    ['storefrontapi.generated.d.ts']: {
       preset,
       schema: getSchema('storefront'),
       documents: [...],
     },
    ['customerapi.generated.d.ts']: {
       preset,
       schema: getSchema('customer'),
       documents: [...],
     },
  },
}

@frandiox frandiox requested a review from a team December 13, 2023 13:11

This comment has been minimized.

Copy link
Contributor

@michenly michenly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I prefer explicit setting over options thats abstracted away. Curious just for my context where else we are using @shopify/hydrogen-codegen. So far I only found one usage in cli.

Also, dont forget changelog!

Co-authored-by: Michelle Chen <michelle.chen@shopify.com>
@frandiox
Copy link
Contributor Author

Curious just for my context where else we are using @shopify/hydrogen-codegen. So far I only found one usage in cli.

Other teams are using it for Admin API and other stuff.

Plus, it can be used by users directly if they want to add extra configuration for 3p APIs (e.g. a CMS). They can just have their own <root>/codegen.ts where they add codegen for other APIs, and import from @shopify/hydrogen-codegen to use ours.
That's why we currently rely on default values, because otherwise the user would need to pass kind of complex options to make the preset work for SFAPI (and now for CAAPI).

@michenly
Copy link
Contributor

Thank you for the explanation @frandiox ! If possible, I think a README in the hydrogen-codegen package explaining to end user on how they can use this package would be really really helpful. 🙏

@frandiox
Copy link
Contributor Author

If possible, I think a README in the hydrogen-codegen package explaining to end user on how they can use this package would be really really helpful.

Yeah, pending task before we release v1 and write proper docs! For that, I'm waiting for dotansimha/graphql-code-generator#9709 to be released first so that we can stop patching depenendcies.

I guess we can add the example of this PR to the readme for now 🤔

@frandiox frandiox merged commit 3f3b8db into main Dec 14, 2023
9 checks passed
@frandiox frandiox deleted the fd-codegen-default-options branch December 14, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants