Provide a type guard to distinguish between ResolveTree and FieldsByTypeName

Abierto
#849 2 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

  • #858 de @Nargonath — cerrado sin fusionar

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
45/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
graphql, typescript

Línea de trabajo

Empieza leyendo los tipos de retorno de parseResolveInfo y el punto de entrada simplifyParsedResolveInfoFragmentWithType mencionado en el issue. Rastrea dónde están definidos ResolveTree y FieldsByTypeName, y después añade el type guard y una prueba que cubra las dos formas. El trabajo estará terminado cuando los consumidores de TypeScript puedan distinguir la unión antes de llamar al simplifier.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
JavaScript
Estrellas
764
Forks
128
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de graphile/graphile-engine

Todos los issues de graphile/graphile-engine

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.