Check out a free preview of the full Introduction to GraphQL course:
The "Sending Multiple Queries" Lesson is part of the full, Introduction to GraphQL course featured in this preview video. Here's what you'd learn in this lesson:

Scott demonstrates how to use an alias to perform two requests on a GraphQL server at the same time.

Get Unlimited Access Now

Transcript from the "Sending Multiple Queries" Lesson

[00:00:00]
>> Scott Moss: One quick thing I wanted to show that we didn't get to is that when you do these queries like this, so if I have animals, like species. And the reason I needed to show this is cuz, we're not focusing on queries, we're focusing on server. But on the query side, as if we're doing clients, you can make another query, you can do multiple queries in one request.

[00:00:22] So if you wanted to say I'm gonna do another animals query, but you can't call it animals because that one's already taken,, so I'm gonna say species. Not only can you do another query inside of one request, I can alias this to be otherAnimal. Or I did it the other way around, I'm sorry.

[00:00:46] OtherAnimcal. So now I'm aliasing this animals query to be called otherAnimals, but they're both running to animals query. And I run two of them at the same time. So I send one request over two queries, so to execute two queries on my GraphQL server at the same time, and I'll get back two results.

[00:01:06] These are still working, so I'm not gonna hit play yet, obviously, it died. But you can run multiple queries at the same time. I can put a third one here if I want. I can run multiple mutations at the same time if I want to. So you can do that.

[00:01:17] The reason we talk about that, cuz again, this is on the query side of things from the client perspective, whereas we talked about the server side of things. Th query side of things, there's a lot of stuff there that it's a whole nother thing, that's just a whole nother course.

[00:01:31] But there's a lot of stuff you can do over here that we did not talked about. Named operations, all different kind of stuff, so,