graphql / graphql/graphql.github.io

Modernise JS examples in the documentation

Open
#1,821 7 comments 0 reactions 0 assignees View on GitHub
📌 Help wanted
Dominant language
TypeScript
Stars
889
Forks
1.5k
Avg merge
4d 12h
Merged PRs (30d)
21

Description

### 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:

```js
async function Query_human(obj, args, context, info) {
const userData = await context.db.loadHumanByID(args.id)
return new Human(userData)
}
```

### 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](https://github.com/graphql/graphql.github.io/pull/1804#discussion_r1832488076) @mandiwise's overhaul of the documentation.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.