# How to Write GraphQL API Documentation Using Apidog

GraphQL is a query language and server-side runtime for APIs that enables clients to request exactly the data they need, no more, no less . Unlike traditional REST APIs, GraphQL allows developers to declare nested data requirements in a single request, improving efficiency and flexibility. It uses a type system to define data structures and supports real-time updates, making it ideal for modern applications.

## Writing GraphQL Documentation in Apidog

Apidog simplifies GraphQL documentation through its intuitive Markdown-based workflow. Here's how to get started:

1. **Create a New GraphQL Request**:
   Navigate to your project in Apidog, click "New Markdown" to create a GraphQL doc.

2. **Document Using Markdown**:
   Write your GraphQL schema, queries, and mutations directly in Markdown. For example:
   ```graphql
   # Fetch User Data
   query GetUser($id: ID!) {
     user(id: $id) {
       name
       email
     }
   }
   ```
3. **Add Descriptions and Examples**:
   Use comments to explain fields, parameters, and response structures. This ensures clarity for developers consuming the API.

You can see some examples from Github GraphQL API.
- [Introduction to GraphQL](https://apidocs.apidog.io/introduction-to-graphql-892358m0.md)
- [Queries](https://apidocs.apidog.io/queries-892356m0.md)
- [Public schema](https://apidocs.apidog.io/public-schema-892363m0.md)

## Testing GraphQL APIs with Apidog

### 1. Creating a New GraphQL Request

To create a new GraphQL request in a project, click on "Body" → "GraphQL" in sequence.
<Background>
![](https://assets.apidog.com/uploads/help/2024/05/31/36967607d601fbf4e50882ac32bbd276.png)
</Background>
### 2. Requesting GraphQL

Enter your query in the Query box on the "Run" tab. You can also click the manual `Fetch Schema` button in the input box to enable the "code completion" feature for Query expressions, assisting in entering Query statements.
<Background>
![](https://assets.apidog.com/uploads/help/2024/05/31/544fb2e4aa8ba78fa243f8933d9b6aa3.png)
</Background>
Query statements support using GraphQL variables for requesting. For specific usage, please refer to the [GraphQL syntax](https://graphql.org/learn/queries/#using-variables-inside-fragments).
<Background>
![](https://assets.apidog.com/uploads/help/2024/05/31/23db61c1960df793ee8687bee901caa3.png)
</Background>

Apidog visualizes the response data and supports dynamic variables for environment-specific testing. You can also mock responses based on your schema to simulate edge cases.

