説明
GraphQLの優れた機能の1つは、スキーマ内のデータを検出可能にすることです。Relayレゾルバは、この構造をクライアントデータにもたらします。レゾルバに説明を追加することで、クライアント状態スキーマも自己文書化することができます。
説明は、RelayのVSCode拡張機能で、自動補完とホバー表示されます。
docblockタグにフリーテキストを追加することで、型に説明を追加できます。
情報
GraphQLの説明は、マークダウンで記述されることが期待されています。Relayレゾルバは、これらの説明をVSCode拡張機能でマークダウンとしてレンダリングします。
型
/**
* @RelayResolver Author
*
* An author in our **amazing** CMS. Authors can
* write posts but not necessarily change their permissions.
*/
export function Author(id: DataID): AuthorModel {
return AuthorService.getById(id);
}
フィールド
/**
* @RelayResolver Author.fullName: String
*
* The author's first and last name. Does not include
* any [honorifics](https://en.wikipedia.org/wiki/Honorific).
*/
export function fullName(author: AuthorModel): string {
return `${author.firstName} ${author.lastName}`;
}