@ALIAS Directive
The directive @alias provides an alternative name to the
table on which the field is specified.
This directive has one argument: AS in which you can provide the
alternative name for the field.
SELECT JSON_SERIALIZE(data PRETTY) AS data FROM GRAPHQL('
driver @alias(as: drv) {
id: driver_id
name
drv.points
teamName @generated(sql: "select name from team where team.team_id = drv.team_id")
}
');
The example provides an alternative name to the driver field as
drv using the @alias directive. So in this
example, drv.team_id would produce identical results as using
driver.team_id without using the @alias
directive:
DATA
--------------------------------------------------------------------------------
{
"id" : 101,
"name" : "Lando Norris",
"points" : 282,
"teamName" : "McLaren Mercedes"
}
{
"id" : 102,
"name" : "Oscar Piastri",
"points" : 384,
"teamName" : "McLaren Mercedes"
}
{
"id" : 103,
"name" : "Charles Leclerc",
"points" : 312,
"teamName" : "Ferrari"
}
..............
..............
20 rows selected.