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

fix(gatsby-plugin-graphql): Fix warnings and incremental builds #889

Merged
merged 1 commit into from
Aug 12, 2021

Conversation

tlgimenes
Copy link
Contributor

@tlgimenes tlgimenes commented Aug 12, 2021

What's the purpose of this pull request?

When using this plugin, we get the warnings:

success Rewriting compilation hashes - 0.019s
success Writing page-data.json files to public directory - 0.391s - 419/419 1070.34/s
warn Skipping query HomePageQuery since it was already defined. If this wasn't the intended
behavior please change your query operation name
warn Skipping query BrowserProductPageQuery since it was already defined. If this wasn't the
 intended behavior please change your query operation name
warn Skipping query BrowserSearchPageQuery since it was already defined. If this wasn't the
intended behavior please change your query operation name
warn Skipping query ServerSearchPageQuery since it was already defined. If this wasn't the
intended behavior please change your query operation name
warn Skipping query CollectionPageQuery since it was already defined. If this wasn't the
intended behavior please change your query operation name
warn Skipping query ServerProductPageQuery since it was already defined. If this wasn't the
intended behavior please change your query operation name
warn Skipping query BrowserCollectionPageQuery since it was already defined. If this wasn't
the intended behavior please change your query operation name

These warnings are there to prevent adding two different queries with the same name. When building the same query, this warning is fires by mistake. This PR fixes this issue by tracking the filename of the query and only warning when two queries of the same name in different files are created.

Another fix this PR brings is related to incremental builds. When building incrementally, not all files will go through babel and some queries/fragments may be missing, causing a "Missing Query" error. To fix this error, we serialize the plugin's state into te file system and hydrate the plugin when building incrementally. This should fix all errors.

How to test it?

Make sure the warnings went away and incremental builds work just fine: Also, make sure queries are still generated correctly

https://github.com/vtex-sites/storecomponents.store/pull/1109
https://github.com/vtex-sites/btglobal.store/pull/785
https://github.com/vtex-sites/marinbrasil.store/pull/601

@netlify
Copy link

netlify bot commented Aug 12, 2021

✔️ Deploy Preview for storeui ready!

🔨 Explore the source changes: 476433a

🔍 Inspect the deploy log: https://app.netlify.com/sites/storeui/deploys/61151f1e5b862c0007a91fb0

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 12, 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 476433a:

Sandbox Source
Store UI Typescript Configuration

@tlgimenes tlgimenes marked this pull request as ready for review August 12, 2021 12:13
@tlgimenes tlgimenes requested a review from a team as a code owner August 12, 2021 12:13
@tlgimenes tlgimenes force-pushed the fix/plugin-graphql-warnings branch from 22d9bc5 to 476433a Compare August 12, 2021 13:16
@tlgimenes tlgimenes merged commit a1a256b into master Aug 12, 2021
@tlgimenes tlgimenes deleted the fix/plugin-graphql-warnings branch August 12, 2021 14:16
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