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): Fix missing fragment definition #21081

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/gatsby/src/query/query-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,9 @@ const determineUsedFragmentsForDefinition = (
) => {
const { def, name, isFragment, filePath } = definition
const cachedUsedFragments = fragmentsUsedByFragment.get(name)
if (cachedUsedFragments) {

// `cachedUsedFragments` could be a Set with size 0 which happens to be truthy
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that Set with 0 size can be correct (i.e. when fragment doesn't actually use other fragments).

The problem here is sometimes it's 0 when it shouldn't be

So this adds additional works sometimes, but it's easiest hot fix we can come up without diving too much into this code, which will require @vladar expertise most likely

if (cachedUsedFragments?.size) {
return { usedFragments: cachedUsedFragments, missingFragments: [] }
} else {
const usedFragments = new Set()
Expand Down