Open TPXP opened 2 months ago
Hi @TPXP, Thank you for reaching out about this! We are in the course of improving our docs, and any feedback or help is very appreciated!
If you're willing to make a PR for this, I'm more in favor of making using the ESM standard. It's supposed to be the way to go for new project, so let's push this instead of pushing back to CJS syntax.
I think we are too TS minded in our docs, we should be more careful when we write JS snippets, because imports are slightly different than we are used to.
The "Quick start" page of the docs is confusing when starting a project from scratch. I was trying to experiment quickly with Yoga so I started a new project, installed
graphql-yoga
andgraphql
and createdschema.js
andindex.js
with the code from the snippets on the page.Running this did not work as expected
Sure, I can add
type: "module"
to mypackage.json
, but then I get an error about it not findingschema
:Patching the schema import line to
import { schema } from './schema.js'
works, and the server is able to start. 🎉A Carefully crafted "Getting started" page makes a good first impression. While these issues can be common, I think the page could be updated to mention these tricks and make the first contact more pleasant.
I see two ways to fix this:
require()
syntax."type":"module"
in thepackage.json
file, and fix theschema.js
path.I'll happily submit a PR going whichever way you prefer, thanks!