跳至主要內容
版本:v18.0.0

說明

GraphQL 的一個主要優勢是它可以讓您的 schema 中的資料可被發現。Relay Resolvers 將此結構帶到您的客戶端資料。通過在您的 resolver 中添加說明,您也可以使您的客戶端狀態 schema 具有自我說明的功能。

這些說明會通過 Relay 的 VSCode 擴充套件 在自動完成和懸停時顯示。

您可以通過在 docblock 標籤中添加自由文本來為類型添加說明

資訊

GraphQL 說明預期以 markdown 格式撰寫。Relay Resolvers 將在 VSCode 擴充套件中將這些說明呈現為 markdown。

類型

/**
* @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}`;
}