graphql / graphql/graphql.github.io

Modernise JS examples in the documentation

Offen
#1,821 7 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
📌 Help wanted
Vorherrschende Sprache
TypeScript
Sterne
889
Forks
1.5k
Ø Merge
4 T. 12 Std.
Gemergte PRs (30 T.)
21

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit src/pages/learn/execution.mdx beim verlinkten Beispiel und durchsuche anschließend die Learn-Dokumentation nach ähnlichen promise-basierten JavaScript-APIs. Aktualisiere die relevanten Beispiele so, dass sie async/await verwenden, und bewahre dabei ihre Bedeutung. Bestätige, dass die Dokumentation weiterhin korrekt und konsistent ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
graphql, javascript
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.