How to use GraphQL aliases

David Mráz
Atheros

--

Also available at https://atheros.ai/blog/how-to-use-graphql-aliases without the paywall.

Introduction

To understand the concept of aliases in GraphQL we need to take a closer look at general query logic and identify what each part of a query is responsible for. All examples in this article can be found in this GitHub repository. If you also want to try these examples out in the GraphQL Playground tool, just clone the repository with

git clone git@github.com:atherosai/graphql-gateway-apollo-express.git

install dependencies with

npm i

and start the server in development with

npm run dev

To illustrate the aliases concept, let’s take this query for retrieving users from the database.

This query consists of different parts of:

  • operation type (query): the type of action we want to do with the query. In GraphQL specification we have three different operation types -query, mutation and subscription.

--

--

David Mráz
Atheros

Founder of https://atheros.ai | Artificial Intelligence | Machine Learning | JavaScript, Python, C++ | Business