diff --git a/api-playground/graphql-setup.mdx b/api-playground/graphql-setup.mdx new file mode 100644 index 000000000..b27b54275 --- /dev/null +++ b/api-playground/graphql-setup.mdx @@ -0,0 +1,103 @@ +--- +title: "GraphQL setup" +description: "Generate reference pages for your GraphQL API from a schema definition file, with linked types and example queries, mutations, and responses." +keywords: ["graphql", "schema", "sdl"] +--- + +## Add a GraphQL schema + +To create pages for your GraphQL API, you need a valid GraphQL schema in SDL (Schema Definition Language) format. Store the schema in your documentation repository or host it at an HTTPS URL that Mintlify can fetch. + +```graphql schema.graphql +"An object with a stable identifier." +interface Node { + id: ID! +} + +type Organization implements Node { + id: ID! + name: String! +} + +type Query { + organization(id: ID!): Organization +} +``` + +## Auto-populate GraphQL pages + +To automatically generate pages for every query, mutation, and type in your schema, add a `graphql` property to a tab in your `docs.json`. Mintlify parses the schema and creates a page for each operation and named type. + + + +```json Local file +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": "schema.graphql" + } + ] +} +``` + +```json Remote URL +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": "https://example.com/schema.graphql" + } + ] +} +``` + +```json Custom directory +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": { + "source": "schema.graphql", + "directory": "api/graphql" + } + } + ] +} +``` + + + +The `graphql` property accepts either a string (a local path or HTTPS URL) or an object with the following fields. + + + You must declare `graphql` on a [tab](/organize/navigation#tabs). A tab with `graphql` may include `groups`, but no other navigation structures, such as `pages`, `versions`, or `languages`. It also cannot include an `openapi` or `asyncapi` property. + + + + A local path to an SDL file in your documentation repository or an HTTPS URL to a hosted SDL file. Does not accept HTTP URLs. + + + + The directory to store generated pages. Defaults to `graphql-reference`. + + +## Generated pages + +Mintlify organizes generated pages into three sections under the tab you configured: + +- **Queries**: One page per field on your `Query` root type. +- **Mutations**: One page per field on your `Mutation` root type. +- **Types**: One page per named object, input, enum, interface, union, or scalar type. + +Each operation page shows the field description, arguments, return type, and links to any referenced types. Query and mutation pages also include a generated example operation, the required variables, and a sample JSON response. + +Type pages render the schema definition read-only, with linked field types so readers can navigate the graph. + +## Deprecations + +Fields and arguments that you mark with `@deprecated` in your schema display as deprecated on the generated pages. If you provide a deprecation reason, it appears next to the field. + +## Update your documentation + +Mintlify regenerates GraphQL reference pages when you run `mint dev` or when you push changes to your documentation repository. If your schema is hosted at an HTTPS URL, updates to the schema regenerate on the next build. diff --git a/docs.json b/docs.json index 0da21a45b..9f07a0e7b 100644 --- a/docs.json +++ b/docs.json @@ -177,6 +177,7 @@ "api-playground/multiple-responses", "api-playground/mdx-setup", "api-playground/asyncapi-setup", + "api-playground/graphql-setup", "api-playground/troubleshooting" ] }, diff --git a/es.json b/es.json index a3b5b4b12..6639bd92b 100644 --- a/es.json +++ b/es.json @@ -156,6 +156,7 @@ "es/api-playground/multiple-responses", "es/api-playground/mdx-setup", "es/api-playground/asyncapi-setup", + "es/api-playground/graphql-setup", "es/api-playground/troubleshooting" ] }, diff --git a/es/api-playground/graphql-setup.mdx b/es/api-playground/graphql-setup.mdx new file mode 100644 index 000000000..337a69b76 --- /dev/null +++ b/es/api-playground/graphql-setup.mdx @@ -0,0 +1,113 @@ +--- +title: "Configuración de GraphQL" +description: "Genera páginas de referencia para tu API de GraphQL a partir de un archivo de definición de esquema, con tipos enlazados y ejemplos de consultas, mutaciones y respuestas." +keywords: ["graphql", "schema", "sdl"] +--- + +
+ ## Agrega un esquema de GraphQL +
+ +Para crear páginas para tu API de GraphQL, necesitas un esquema de GraphQL válido en formato SDL (Schema Definition Language). Almacena el esquema en tu repositorio de documentación o alójalo en una URL HTTPS que Mintlify pueda obtener. + +```graphql schema.graphql +"An object with a stable identifier." +interface Node { + id: ID! +} + +type Organization implements Node { + id: ID! + name: String! +} + +type Query { + organization(id: ID!): Organization +} +``` + +
+ ## Generar automáticamente páginas de GraphQL +
+ +Para generar automáticamente páginas para cada consulta, mutación y tipo de tu esquema, agrega una propiedad `graphql` a una pestaña en tu `docs.json`. Mintlify analiza el esquema y crea una página para cada operación y tipo con nombre. + + + +```json Local file +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": "schema.graphql" + } + ] +} +``` + +```json Remote URL +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": "https://example.com/schema.graphql" + } + ] +} +``` + +```json Custom directory +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": { + "source": "schema.graphql", + "directory": "api/graphql" + } + } + ] +} +``` + + + +La propiedad `graphql` acepta ya sea una cadena (una ruta local o una URL HTTPS) o un objeto con los siguientes campos: + + + Una ruta local a un archivo SDL en tu repositorio de documentación o una URL HTTPS a un archivo SDL alojado. No se aceptan URL HTTP. + + + + El directorio donde se colocan las páginas generadas. El valor predeterminado es `graphql-reference`. + + + + Las fuentes de GraphQL solo se admiten en pestañas. Una pestaña que declara `graphql` no puede declarar también `openapi` o `asyncapi`. + + +
+ ## Páginas generadas +
+ +Mintlify organiza las páginas generadas en tres secciones dentro de la pestaña que configuraste: + +- **Queries** — una página por cada campo de tu tipo raíz `Query`. +- **Mutations** — una página por cada campo de tu tipo raíz `Mutation`. +- **Types** — una página por cada tipo con nombre: object, input, enum, interface, union o scalar. + +Cada página de operación muestra la descripción del campo, los argumentos, el tipo de retorno y enlaces a cualquier tipo referenciado. Las páginas de consultas y mutaciones también incluyen una operación de ejemplo generada, las variables requeridas y una respuesta JSON de muestra en el panel lateral (o en línea en dispositivos móviles). + +Las páginas de tipos renderizan la definición del esquema en modo solo lectura, con los tipos de campo enlazados para que las personas que leen puedan navegar por el grafo. + +
+ ## Deprecaciones +
+ +Los campos y argumentos marcados con `@deprecated` en tu esquema se señalan como obsoletos en las páginas generadas. El motivo de la deprecación, cuando se proporciona, aparece junto al campo. + +
+ ## Actualiza tu documentación +
+ +Mintlify regenera las páginas de referencia de GraphQL cuando ejecutas `mint dev` o cuando envías cambios a tu repositorio de documentación. Si tu esquema está alojado en una URL HTTPS, las actualizaciones del esquema se incorporan en la siguiente compilación. diff --git a/fr.json b/fr.json index b94b4c31c..48cc2e79a 100644 --- a/fr.json +++ b/fr.json @@ -156,6 +156,7 @@ "fr/api-playground/multiple-responses", "fr/api-playground/mdx-setup", "fr/api-playground/asyncapi-setup", + "fr/api-playground/graphql-setup", "fr/api-playground/troubleshooting" ] }, diff --git a/fr/api-playground/graphql-setup.mdx b/fr/api-playground/graphql-setup.mdx new file mode 100644 index 000000000..1eab2f2a1 --- /dev/null +++ b/fr/api-playground/graphql-setup.mdx @@ -0,0 +1,113 @@ +--- +title: "Configuration de GraphQL" +description: "Générez des pages de référence pour votre API GraphQL à partir d’un fichier de définition de schéma, avec des types liés et des exemples de requêtes, mutations et réponses." +keywords: ["graphql", "schema", "sdl"] +--- + +
+ ## Ajouter un schéma GraphQL +
+ +Pour créer des pages pour votre API GraphQL, vous avez besoin d’un schéma GraphQL valide au format SDL (Schema Definition Language). Stockez le schéma dans votre dépôt de documentation ou hébergez-le à une URL HTTPS que Mintlify peut récupérer. + +```graphql schema.graphql +"An object with a stable identifier." +interface Node { + id: ID! +} + +type Organization implements Node { + id: ID! + name: String! +} + +type Query { + organization(id: ID!): Organization +} +``` + +
+ ## Remplir automatiquement les pages GraphQL +
+ +Pour générer automatiquement des pages pour chaque requête, mutation et type de votre schéma, ajoutez une propriété `graphql` à un onglet dans votre `docs.json`. Mintlify analyse le schéma et crée une page pour chaque opération et chaque type nommé. + + + +```json Local file +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": "schema.graphql" + } + ] +} +``` + +```json Remote URL +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": "https://example.com/schema.graphql" + } + ] +} +``` + +```json Custom directory +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": { + "source": "schema.graphql", + "directory": "api/graphql" + } + } + ] +} +``` + + + +La propriété `graphql` accepte soit une chaîne (un chemin local ou une URL HTTPS), soit un objet avec les champs suivants : + + + Un chemin local vers un fichier SDL dans votre dépôt de documentation ou une URL HTTPS vers un fichier SDL hébergé. Les URL HTTP ne sont pas acceptées. + + + + Le répertoire dans lequel les pages générées sont placées. Par défaut, `graphql-reference`. + + + + Les sources GraphQL ne sont prises en charge que sur les onglets. Un onglet qui déclare `graphql` ne peut pas également déclarer `openapi` ou `asyncapi`. + + +
+ ## Pages générées +
+ +Mintlify organise les pages générées en trois sections sous l’onglet que vous avez configuré : + +- **Queries** — une page par champ de votre type racine `Query`. +- **Mutations** — une page par champ de votre type racine `Mutation`. +- **Types** — une page par type nommé (object, input, enum, interface, union ou scalar). + +Chaque page d’opération affiche la description du champ, les arguments, le type de retour et des liens vers tous les types référencés. Les pages de requêtes et de mutations comprennent également un exemple d’opération généré, les variables requises et un exemple de réponse JSON dans le panneau latéral (ou en ligne sur mobile). + +Les pages de types affichent la définition du schéma en lecture seule, avec des types de champs liés afin que les lecteurs puissent naviguer dans le graphe. + +
+ ## Dépréciations +
+ +Les champs et les arguments marqués avec `@deprecated` dans votre schéma sont signalés comme dépréciés sur les pages générées. La raison de la dépréciation, lorsqu’elle est fournie, apparaît à côté du champ. + +
+ ## Mettre à jour votre documentation +
+ +Mintlify régénère les pages de référence GraphQL lorsque vous exécutez `mint dev` ou lorsque vous poussez des modifications vers votre dépôt de documentation. Si votre schéma est hébergé à une URL HTTPS, les mises à jour du schéma sont prises en compte lors de la prochaine build. diff --git a/zh.json b/zh.json index 1535c6b9e..260c9629f 100644 --- a/zh.json +++ b/zh.json @@ -153,6 +153,7 @@ "zh/api-playground/multiple-responses", "zh/api-playground/mdx-setup", "zh/api-playground/asyncapi-setup", + "zh/api-playground/graphql-setup", "zh/api-playground/troubleshooting" ] }, diff --git a/zh/api-playground/graphql-setup.mdx b/zh/api-playground/graphql-setup.mdx new file mode 100644 index 000000000..7ad6e1b80 --- /dev/null +++ b/zh/api-playground/graphql-setup.mdx @@ -0,0 +1,113 @@ +--- +title: "GraphQL 设置" +description: "从 schema 定义文件为你的 GraphQL API 生成参考页面,包含相互链接的类型以及示例 query、mutation 和响应。" +keywords: ["graphql", "schema", "sdl"] +--- + +
+ ## 添加 GraphQL schema +
+ +要为你的 GraphQL API 创建页面,你需要一个采用 SDL (Schema Definition Language) 格式的有效 GraphQL schema。将 schema 存储在你的文档仓库中,或托管在 Mintlify 可访问的 HTTPS URL 上。 + +```graphql schema.graphql +"An object with a stable identifier." +interface Node { + id: ID! +} + +type Organization implements Node { + id: ID! + name: String! +} + +type Query { + organization(id: ID!): Organization +} +``` + +
+ ## 自动填充 GraphQL 页面 +
+ +要为 schema 中的每个 query、mutation 和 type 自动生成页面,请在 `docs.json` 中的某个 tab 添加 `graphql` 属性。Mintlify 会解析 schema,并为每个操作和命名类型创建一个页面。 + + + +```json Local file +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": "schema.graphql" + } + ] +} +``` + +```json Remote URL +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": "https://example.com/schema.graphql" + } + ] +} +``` + +```json Custom directory +"navigation": { + "tabs": [ + { + "tab": "GraphQL API", + "graphql": { + "source": "schema.graphql", + "directory": "api/graphql" + } + } + ] +} +``` + + + +`graphql` 属性可接受字符串 (本地路径或 HTTPS URL) ,或包含以下字段的对象: + + + 指向文档仓库中 SDL 文件的本地路径,或指向已托管 SDL 文件的 HTTPS URL。不接受 HTTP URL。 + + + + 生成页面所存放的目录。默认值为 `graphql-reference`。 + + + + GraphQL 源仅在 tab 上受支持。声明了 `graphql` 的 tab 不能同时声明 `openapi` 或 `asyncapi`。 + + +
+ ## 生成的页面 +
+ +Mintlify 会将生成的页面组织到你所配置的 tab 下的三个部分中: + +- **Queries** — 为 `Query` 根类型的每个字段生成一个页面。 +- **Mutations** — 为 `Mutation` 根类型的每个字段生成一个页面。 +- **Types** — 为每个命名的 object、input、enum、interface、union 或 scalar 类型生成一个页面。 + +每个操作页面会显示字段描述、参数、返回类型以及指向所引用类型的链接。Query 和 mutation 页面还会在侧边面板中 (在移动端则内联显示) 包含自动生成的示例操作、所需变量以及示例 JSON 响应。 + +Type 页面以只读方式渲染 schema 定义,并为字段类型提供链接,方便读者浏览整个 graph。 + +
+ ## 弃用 +
+ +在你的 schema 中被标记为 `@deprecated` 的字段和参数,会在生成的页面上被标记为已弃用。如果提供了弃用原因,将显示在该字段旁边。 + +
+ ## 更新你的文档 +
+ +当你运行 `mint dev` 或将更改推送到文档仓库时,Mintlify 会重新生成 GraphQL 参考页面。如果你的 schema 托管在 HTTPS URL 上,schema 的更新会在下一次构建时被采纳。