Skip to content

Aliases

With aliases you can rename the output fields of a query. They are defined by a colon : after the field name (or after the arguments if they are present) and can be double quoted if they contain special characters or spaces.

To clarify, let’s see an example:

input.json
{
"id": "AI-Models",
"models": [
{
"name": "GPT-4o",
"score": 71.49
},
{
"name": "Claude",
"score": 93.2
},
{
"name": "LLAMA",
"score": 88.7
}
]
}

If we want to obtain the top scoring model names but renaming the field to topScores, we can use the following query:

query.gq
{
models(score>80.0).name: topScores
}
output.json
{
"topScores": [
"Claude",
"LLAMA"
]
}

Or if we want to name the output field using spaces, we can double-quote it:

query.gq
{
models.name: "model names"
}
output.json
{
"model names": [
"GPT-4O",
"Claude",
"LLAMA"
]
}