-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Modernise JS examples in the documentation #1821
Comments
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 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. |
@kasir-barati wanna help us fix it? 😄 |
Love to if I get the chance. Since TBF I have already done part of it (link to repo). Or at least it is done in TS, but I can get rid of all typings and replace them with JSDoc. But I also need some inputs along the way. Here is my own doc compiled mainly from: https://graphql.org/graphql-js. |
Awesome - would be great to have your help! The graphql-js.org website is currently being rewritten - if you'd like to get involved in that I encourage you to talk with Jovi and Yaacov in #graphql-js on the GraphQL Discord or get involved with the graphql-js-wg: https://github.com/graphql/graphql-js-wg This issue specifically relates to the |
BTW @benjie I am also going through the |
If you can keep the changes small (but ensure that the surrounding text is correctly adjusted) please do go ahead :) AFAIK no-one else is scheduled to make these specific changes. |
Description
Much of the code in the "learn" docs uses promise-based APIs:
graphql.github.io/src/pages/learn/execution.mdx
Lines 61 to 65 in b1215ce
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.
The text was updated successfully, but these errors were encountered: