> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pylon.mortgage/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction to GraphQL

> Learn the basics of GraphQL and how to use it with the Pylon API

GraphQL is a query language for APIs that allows you to request exactly the data you need. Unlike REST APIs, GraphQL gives you the flexibility to fetch multiple resources in a single request.

## What is GraphQL?

GraphQL is a query language and runtime for executing queries against your data. It provides:

* **Single endpoint** - All queries and mutations go through one endpoint
* **Flexible queries** - Request only the fields you need
* **Strong typing** - Schema defines all available data and operations
* **Introspection** - Explore the API schema directly

## Basic concepts

### Queries

Queries are used to fetch data. They are read-only operations:

```graphql theme={null}
query GetDeal {
  deal(id: "123") {
    id
    friendlyId
    borrowers {
      edges {
        node {
          id
          personalInformation {
            firstName
            lastName
          }
        }
      }
    }
  }
}
```

### Mutations

Mutations are used to modify data (create, update, delete):

```graphql theme={null}
mutation CreateBorrower {
  borrower {
    create(
      input: {
        dealId: "123"
        personalInformation: {
          firstName: "John"
          lastName: "Doe"
          email: "john.doe@example.com"
        }
      }
    ) {
      id
    }
  }
}
```

### Fields

Fields represent the data you want to retrieve. You can request nested fields:

```graphql theme={null}
query {
  deal(id: "123") {
    id
    borrowers {
      edges {
        node {
          id
          personalInformation {
            firstName
            lastName
          }
          incomes {
            edges {
              node {
                statedMonthlyAmount
              }
            }
          }
        }
      }
    }
  }
}
```

## GraphQL vs REST

| Feature        | REST               | GraphQL          |
| -------------- | ------------------ | ---------------- |
| Endpoints      | Multiple endpoints | Single endpoint  |
| Data fetching  | Fixed structure    | Flexible queries |
| Over-fetching  | Common             | Avoided          |
| Under-fetching | Common             | Avoided          |
| Versioning     | URL-based          | Schema-based     |

## Next steps

* Learn about [forming calls with GraphQL](/playground/forming-calls)
* Explore [variables and fragments](/playground/variables-fragments)
* Understand [pagination](/playground/pagination)
* See [using GraphQL clients](/playground/using-clients)
