From the course: Migrating from REST to GraphQL

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

What are aliases and usage

What are aliases and usage

- [Instructor] Okay, so now let's explore aliases. What are aliases? They are basically a way to get multiple queries in one pass with different patterns or different things that you want for specific people or a list of people. So let me give you an example. So right here, I have getOneContact, right? So the way it would work is, for example, you do the one query, but for each of these you can actually label them anything you want. It could be for example, one, and as you can see, there's no more errors. And then what you could do is do two and then do a second one. So let's go ahead and do the second, getContacts, and let's do the ID that we have here, just for the sake of the example. And then what you need to ask. In this case, let's go and ask for example, last name and the ID, like so. And we need to do getOneContact, that's the error. So in this case, we would get one query that would return for this contact, the first name of the company, and this other query that would return…

Contents