Skip to content

polish(ast): prefer undefined over empty arrays#4206

Merged
yaacovCR merged 2 commits into
graphql:mainfrom
yaacovCR:suggestion-from-alternative
Oct 14, 2024
Merged

polish(ast): prefer undefined over empty arrays#4206
yaacovCR merged 2 commits into
graphql:mainfrom
yaacovCR:suggestion-from-alternative

Conversation

@yaacovCR

@yaacovCR yaacovCR commented Sep 27, 2024

Copy link
Copy Markdown
Contributor

see: #2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays; this change simply updates the parser to more closely follow the manual approach. This is therefore not technically a breaking change, but considering that there may be tools not aware of this, we have labelled it a BREAKING_CHANGE to highlight it for consumers.

This closes #2203 as our tests now cover the undefined case by default whenever there is an empty array.

@yaacovCR
yaacovCR requested a review from a team as a code owner September 27, 2024 08:10
@yaacovCR yaacovCR added the PR: polish 💅 PR doesn't change public API or any observed behaviour label Sep 27, 2024
@netlify

netlify Bot commented Sep 27, 2024

Copy link
Copy Markdown

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit 125c2b7
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/670cf48b36880d0008726e05
😎 Deploy Preview https://deploy-preview-4206--compassionate-pike-271cb3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions

Copy link
Copy Markdown

Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

@yaacovCR
yaacovCR marked this pull request as draft September 27, 2024 08:49
@yaacovCR yaacovCR closed this Sep 27, 2024
@yaacovCR yaacovCR reopened this Sep 28, 2024
@yaacovCR
yaacovCR force-pushed the suggestion-from-alternative branch 2 times, most recently from 60e7d7f to aee3bb9 Compare September 28, 2024 21:04
@yaacovCR

Copy link
Copy Markdown
Contributor Author

Well, it works!

It would seem that it's more accurate to use undefined when an optionalMany(...) is skipped entirely and an empty array when it is found, but has an empty list. So, it would seem that this PR is technically more correct.

Peeking around at https://astexplorer.net/ it seems that TS parser has some empty arrays, some undefined, while for Babel I didn't on a very cursory look see any undefined.

But still not 100% sure this is too compelling, with the status quo being somewhat compelling! Comments welcome!

@yaacovCR
yaacovCR marked this pull request as ready for review September 28, 2024 21:09
@yaacovCR
yaacovCR marked this pull request as draft October 1, 2024 10:31
@yaacovCR yaacovCR added PR: breaking change 💥 implementation requires increase of "major" version number and removed PR: polish 💅 PR doesn't change public API or any observed behaviour labels Oct 14, 2024
@yaacovCR
yaacovCR requested a review from JoviDeCroock October 14, 2024 08:51
@yaacovCR
yaacovCR marked this pull request as ready for review October 14, 2024 08:52
@yaacovCR

Copy link
Copy Markdown
Contributor Author

Merging this PR allows us to close #2203, improving robustness of our test coverage. Presumably our downstream users were also affected by #2203 and had to account for manually created AST nodes, so they should be robust to this change, but I upgraded it to a breaking change anyway just to call it out.

@JoviDeCroock

Copy link
Copy Markdown
Contributor

Probably needs a rebase

@yaacovCR
yaacovCR force-pushed the suggestion-from-alternative branch from bdde1db to 125c2b7 Compare October 14, 2024 10:38
@yaacovCR
yaacovCR requested a review from JoviDeCroock October 14, 2024 10:39
@yaacovCR
yaacovCR merged commit bb8e574 into graphql:main Oct 14, 2024
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
see:
graphql#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes graphql#2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 16, 2025
see:
graphql#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes graphql#2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
see:
graphql#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes graphql#2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 17, 2025
see:
graphql#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes graphql#2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 19, 2025
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 19, 2025
see:
graphql#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes graphql#2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 22, 2025
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Dec 22, 2025
see:
graphql#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes graphql#2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit that referenced this pull request Dec 22, 2025
see:
#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes #2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit that referenced this pull request Dec 22, 2025
see:
#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes #2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jan 27, 2026
yaacovCR added a commit to yaacovCR/graphql-js that referenced this pull request Jan 27, 2026
see:
graphql#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes graphql#2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit that referenced this pull request Feb 22, 2026
see:
#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes #2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit that referenced this pull request Feb 23, 2026
see:
#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes #2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit that referenced this pull request Feb 24, 2026
see:
#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes #2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit that referenced this pull request Feb 24, 2026
see:
#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes #2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit that referenced this pull request Feb 24, 2026
see:
#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes #2203 as our tests now cover the undefined case by default
whenever there is an empty array.
yaacovCR added a commit that referenced this pull request Feb 24, 2026
see:
#2405 (comment)

Manually created ASTs always allowed undefined in place of empty arrays;
this change simply updates the parser to more closely follow the manual
approach. This is therefore not technically a breaking change, but
considering that there may be tools not aware of this, we have labelled
it a BREAKING_CHANGE to highlight it for consumers.

This closes #2203 as our tests now cover the undefined case by default
whenever there is an empty array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: breaking change 💥 implementation requires increase of "major" version number

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants