dotansimha / graphql-yoga

🧘 Rewrite of a fully-featured GraphQL Server with focus on easy setup, performance & great developer experience. The core of Yoga implements WHATWG Fetch API and can run/deploy on any JS environment.
https://the-guild.dev/graphql/yoga-server
MIT License
8.25k stars 574 forks source link

docs(typo): remove unintended semicolon #3358

Closed joshxfi closed 4 months ago

joshxfi commented 4 months ago

https://the-guild.dev/graphql/yoga-server/docs/integrations/integration-with-nextjs#example-1

- ;(async () => {
+ (async () => {
changeset-bot[bot] commented 4 months ago

⚠️ No Changeset found

Latest commit: 3860e35fedf3a14f93130fe53b6cab2b8cd84bc4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

EmrysMyrddin commented 4 months ago

Hi! Thank you for taking the time to contribute here 🙂

This is not an unintended semicolon, removing it actually breaks the code. This is because of JS auto-semicolon feature. We are not manually putting semicolon at the end of our lines here, so JS adds them for us. But sometimes, it doesn't understand where the end of the statement is. It is the case here: if you remove the semicolon, the function returned by createYoga will be executed with the following anonymous function as a parameter.

But I agree this is not very readable. But I would suggest to either not have an IIF, or add all semicolons, which would resolve the ambiguity.

joshxfi commented 4 months ago

I see, I noticed that no semicolons are used as a convention so I thought it was unintended. But yes, you're correct, not including the semicolon may cause an error with the IIFE. I'll close this pr, thanks for your time!