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

feat(store-api): Add codegen #960

Merged
merged 11 commits into from
Sep 16, 2021
Merged

feat(store-api): Add codegen #960

merged 11 commits into from
Sep 16, 2021

Conversation

tlgimenes
Copy link
Contributor

@tlgimenes tlgimenes commented Sep 15, 2021

What's the purpose of this pull request?

Adds graphql codegen for auto generating TypeScript typings after the graphql typeDefs for store-api.

This is important for the future once we start using these typings on our typescript code base

How it works?

Graphql codegen is a cli. This cli is hooked into the generate script of package.json. To generate types just:

yarn workspace @vtex/store-api run generate

To watch for file changes:

yarn workspace @vtex/store-api run generate -w

Also, the yarn build command nows does two things:

yarn run generate && tsdx build

@tlgimenes tlgimenes requested a review from a team as a code owner September 15, 2021 18:00
@netlify
Copy link

netlify bot commented Sep 15, 2021

✔️ Deploy Preview for storeui ready!

🔨 Explore the source changes: b8bfcfe

🔍 Inspect the deploy log: https://app.netlify.com/sites/storeui/deploys/61425ed9487717000857224c

😎 Browse the preview: https://deploy-preview-960--storeui.netlify.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 15, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit b8bfcfe:

Sandbox Source
Store UI Typescript Configuration

"test": "tsdx test",
"lint": "tsdx lint"
"lint": "tsdx lint",
"generate": "graphql-codegen --config codegen.yml"
Copy link
Member

Choose a reason for hiding this comment

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

How about adding a clean script here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for cleaning the dist folder you mean?

Copy link
Member

Choose a reason for hiding this comment

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

I was actually thinking about the generated types... but yeah! Hahahah the dist folder makes more sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, every time we generate the typings it actually clean the types, so it's kinda already built into the "generate" command

@tlgimenes tlgimenes requested a review from victorhmp September 15, 2021 19:41
Copy link
Contributor

@icazevedo icazevedo left a comment

Choose a reason for hiding this comment

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

LGTM, but I left a question below.

Comment on lines +23 to +25
"@graphql-tools/schema": "^8.2.0",
"graphql": "^15.5.3",
"isomorphic-unfetch": "^3.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why were these dependencies added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was already importing these on the code but it wasn't really defined in store-api's deps.

Copy link
Contributor

@icazevedo icazevedo Sep 16, 2021

Choose a reason for hiding this comment

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

Can we prevent that from happening? Like, scoping dependencies per package?

@tlgimenes tlgimenes merged commit 5231e6c into master Sep 16, 2021
@tlgimenes tlgimenes deleted the feat/typings branch September 16, 2021 13:25
rrbambokian pushed a commit that referenced this pull request Sep 30, 2021
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.

3 participants