# Introduction to GraphQL

## Query language

[GraphQL](https://www.graphql.org/) is a query language for API's. It's query language can pull multiple objects of different types, with less queries that would be needed using REST.

Where else is GraphQL used? Facebook, GitHub

#### What does GraphQL do?

REST API's follow a concept of [architectural constraints](https://en.wikipedia.org/wiki/Representational_state_transfer#Architectural_constraints). The classic API is multiple endpoints for various resources alongside `GET`, `POST,` `PUT` and `DELETE`.

GraphQL on the other hand usually has *one* endpoint, always `GET` or `POST`. The magic is in the query passed in the post data.

Assume the following:

```graphql
{
    institution {
        name
    }
}
```

Response:

```javascript
{
  "data": {
    "institution": {
      "name": "Happy University"
    }
  }
}
```

A couple things:

* The query to a single endpoint, via `GET` (`?query=...`) or `POST` (via `POST` data)
* The response is JSON
* The response structure matches the query

What's more is, GraphQL schemas enforce a structured, typed API, and provides instrumentation. This can best be put into example by seeing GraphiQL - a client for graphql - with the query above:

![](/files/-MRzwnCjnc1JBGbXtl1R)

## Core concepts

#### Queries and Mutations:

* Query: Usually reading
* Mutation: Usually create, updating or deleting

#### Basics

* [Fields](https://graphql.org/learn/queries/#fields)
* [Type system](https://graphql.org/learn/schema/#object-types-and-fields):
  * [Object types](https://graphql.org/learn/schema/#object-types-and-fields)
  * [Enums](https://graphql.org/learn/schema/#the-query-and-mutation-types)
  * [Lists](https://graphql.org/learn/schema/#lists-and-non-null)
  * [Interfaces](https://graphql.org/learn/schema/#interfaces)

#### Advanced

* [Variables](https://graphql.org/learn/queries/#variables): Optional parametrization
* [Fragments](https://graphql.org/learn/queries/#fragments): Repeatable pieces of query
* [Pagination](https://graphql.org/learn/pagination/): Traverse through lists of data


---

# 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://docs.eduflow.com/graphql/graphql.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.
