Open benjie opened 6 days ago
This is not the only issue. Some examples ain't working at all. Take for instance this one: https://github.com/graphql/graphql.github.io/blob/source/src/pages/graphql-js/running-an-express-graphql-server.mdx
And the way that you should use graphql-http
per their doc is like this:
import express from 'express'; // yarn add express
import { createHandler } from 'graphql-http/lib/use/express';
import { schema } from './previous-step';
// Create an express instance serving all methods on `/graphql`
// where the GraphQL over HTTP express request handler is
const app = express();
app.all('/graphql', createHandler({ schema }));
app.listen({ port: 4000 });
console.log('Listening to port 4000');
Note that the current doc is broken and cannot be run without issue.
BTW to just communicate it clearly. Now I am questioning whether I should read your doc or not. I mean usually I tend to read docs all the time when I start something new. But at this rate I feel what I'll learn from your doc will be something that someone back in 2018 would have learned. Not to mention the NodeJS now is at version 22. While in your doc it is talking about examples being compatible with version 6. I am not sure except some old code bases if anybody else uses Node V6.
Description
Much of the code in the "learn" docs uses promise-based APIs:
https://github.com/graphql/graphql.github.io/blob/b1215cedbeb3a7d1565072af06ab875da15eece2/src/pages/learn/execution.mdx?plain=1#L61-L65
This would be much easier to read in the more modern async/await code:
Motivation
async/await has been around long enough now that this should be the norm, and is much easier to read and reason about. This will also help reduce the need to explain about promises in the documentation (though we will still need to note alternative techniques in other languages).
Collaboration
I do not currently have sufficient bandwidth to make these changes; but if they're not done in a year definitely ping me!
Additional Context
Inspired by @mandiwise's overhaul of the documentation.