Provide a type guard to distinguish between ResolveTree and FieldsByTypeName

オープン
#849 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

  • #858 @Nargonath による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
graphql, typescript

調査の方向性

まず parseResolveInfo の戻り値の型と、issue で示されているエントリポイント simplifyParsedResolveInfoFragmentWithType を読みます。ResolveTree と FieldsByTypeName がどこで定義されているかを追跡し、その後、type guard と 2 つの形をカバーするテストを追加します。TypeScript の利用側が simplifier を呼び出す前に union を区別できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
JavaScript
スター
764
フォーク
128
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

graphile/graphile-engine のほかの issue

graphile/graphile-engine の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。