Provide a type guard to distinguish between ResolveTree and FieldsByTypeName

Aperta
#849 2 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

  • #858 di @Nargonath — chiusa senza merge

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
graphql, typescript

Direzione di ricerca

Inizia leggendo i tipi restituiti da parseResolveInfo e l’entry point simplifyParsedResolveInfoFragmentWithType indicato nell’issue. Traccia dove sono definiti ResolveTree e FieldsByTypeName, poi aggiungi il type guard e un test che copra le due forme. Il lavoro è concluso quando i consumer TypeScript possono distinguere la union prima di chiamare il simplifier.

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

Descrizione

enhancement
Feature description

parseResolveInfo return type is ResolveTree | FieldsByTypeName | null | undefined. You can get rid of null | undefined with an if condition but you're left with ResolveTree | FieldsByTypeName. The problem is that simplifyParsedResolveInfoFragmentWithType expects a ResolveTree as its first argument. We need a way to tell them apart. Right now I'm using this:

function isResolveTree(
  value: ResolveTree | FieldsByTypeName,
): value is ResolveTree {
  return typeof value.name === "string" && Boolean(value.fieldsByTypeName);
}
Motivating example

It's hard to use simplifyParsedResolveInfoFragmentWithType when using TypeScript without this type guard, unless I'm doing something wrong here.

Supporting development

I [tick all that apply]:

  • am interested in building this feature myself
  • am interested in collaborating on building this feature
  • am willing to help testing this feature before it's released
  • am willing to write a test-driven test suite for this feature (before it exists)
  • am a Graphile sponsor ❤️
  • have an active support or consultancy contract with Graphile
Lingua principale
JavaScript
Stelle
764
Fork
128
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di graphile/graphile-engine

Tutte le issue di graphile/graphile-engine

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.