2018-09-11 14:11:24 +03:00
|
|
|
Multiple queries in a request
|
|
|
|
=============================
|
2018-12-03 15:12:24 +03:00
|
|
|
|
|
|
|
.. contents:: Table of contents
|
|
|
|
:backlinks: none
|
|
|
|
:depth: 1
|
|
|
|
:local:
|
|
|
|
|
2018-10-04 17:30:01 +03:00
|
|
|
If multiple queries are part of the same request, they are executed **parallelly**, the individual responses are
|
2018-09-11 14:11:24 +03:00
|
|
|
collated and returned. You can fetch objects of different unrelated types in the same query.
|
|
|
|
|
|
|
|
For example, fetch a list of ``authors`` and a list of ``articles``:
|
|
|
|
|
|
|
|
.. graphiql::
|
|
|
|
:view_only:
|
|
|
|
:query:
|
|
|
|
query {
|
|
|
|
author(limit: 2) {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
article(limit: 2) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
:response:
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"author": [
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"name": "Justin"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": 2,
|
|
|
|
"name": "Beltran"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"article": [
|
|
|
|
{
|
|
|
|
"id": 1,
|
|
|
|
"title": "sit amet"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"id": 2,
|
|
|
|
"title": "a nibh"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|