# GraphQL API

* **Single Endpoint**: A GraphQL API typically has a single endpoint through which all data is fetched.
* **Client-Driven Queries**: The client specifies exactly what data it needs, which minimizes over-fetching (getting more data than needed) and under-fetching (not getting enough data).
* **Structured Responses**: The response matches the request, allowing clients to shape the structure of the response to their needs.
* **Nested Queries**: It supports complex nested data structures in a single request, which is useful for related data (e.g., querying a user and their posts).
* **No Versioning**: GraphQL doesn’t require versioning because clients can request only the fields they need. As a result, new features can be added to an existing schema without breaking existing clients.
* **Error Reporting**: GraphQL returns data and errors in the same response structure, so clients can still receive partial data when a non-fatal error occurs.
* **Strongly Typed Schema**: GraphQL uses a type system to define the schema, so clients know what data and types are available. This can improve the development experience by enabling better tooling and validation.

**Single Endpoint**: `/graphql`

```graphql
query {
  user(id: 1) {
    id
    name
    email
    posts {
      postId
      title
      content
    }
  }
}
```

Response:

```graphql
{
  "data": {
    "user": {
      "id": 1,
      "name": "John Doe",
      "email": "john.doe@example.com",
      "posts": [
        {
          "postId": 101,
          "title": "My first post",
          "content": "This is the content of my first post."
        },
        {
          "postId": 102,
          "title": "Another day, another post",
          "content": "Here's some more content."
        }
      ]
    }
  }
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.anandisheladiya.com/skills-and-experience/api/graphql-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
