# Query

```julia
using Diana

client = GraphQLClient("https://api.graph.cool/simple/v1/movies")
client.serverAuth("Bearer my-jwt-token")
client.headers(Dict("header"=>"value"))

or

client = GraphQLClient("https://api.graph.cool/simple/v1/movies"
                      ,auth="Bearer my-jwt-token"
                      ,headers=Dict("header"=>"value") 
         )
```

```julia
query = """
        {
          Movie(title: "Inception"){
            actors{
              name
            }
          }
        }
        """

r = client.Query(query)
r.Info.status == 200 && println(r.Data)
```

result:

```
{
  "data":{
    "Movie":{
      "actors":[
        {
          "name":"Leonardo DiCaprio"
        },
        {
          "name":"Ellen Page"
        },
        {
          "name":"Tom Hardy"
        },
        {
          "name":"Joseph Gordon-Levitt"
        },
        {
          "name":"Marion Cotillard"
        }
      ]
    }
  }
}
```

```
query = """
        query getMovie(\$title: String!) {
          Movie(title:\$title) {
            releaseDate
            actors {
              name
            }
          }
        }
        """
r = client.Query(query, vars= Dict("title" => "Inception"))

println(r.Data)
```

```
query = """
        query consulta {
          Movie(title: "Inception") {
            actors{
              name
            }
          }
        }
        query hola {
          Movie(title: "Inception") {
            actors{
              name
            }
          }
        }
        """
r = client.Query(query, operationName = "consulta")
r.Info.status == 200 && println(r.Data)
```

result:

```
{"data":{"Movie":{"actors":[{"name":"Leonardo DiCaprio"},{"name":"Ellen Page"},{"name":"Tom Hardy"},{"name":"Joseph Gordon-Levitt"},{"name":"Marion Cotillard"}]}}}
```

```
using Diana
github_endpoint = "https://api.github.com/graphql"
github_user = # GitHub handle
github_token = # GitHub personal token
github_header = Dict("User-Agent" => github_user)
client = GraphQLClient(github_endpoint,
                       auth = "bearer $github_token",
                       headers = github_header)
query = """
        query A{
          rateLimit {
            cost
            remaining
            resetAt
          }
          repository(owner: "JuliaLang", name: "Julia") {
            id
          }
        }"""

r = client.Query(query, operationName = "A")
r.Info.status == 200 && println(r.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://neomatrixcode.gitbook.io/diana/client/query.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.
