graphql / graphql/graphql.github.io

Modernise JS examples in the documentation

Aperta
#1,821 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub
📌 Help wanted
Lingua principale
TypeScript
Stelle
889
Fork
1.5k
Merge medio
4g 12h
PR unite (30g)
21

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da src/pages/learn/execution.mdx nell’esempio collegato, quindi cerca nella documentazione learn API JavaScript simili basate sulle promise. Aggiorna gli esempi pertinenti in modo che usino async/await, preservandone il significato, e conferma che la documentazione rimanga accurata e coerente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
graphql, javascript
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.