@ARRAY Directive

The @array directive can be used to explicitly shape the nested object as an array.

The directive @array takes no arguments.

SELECT JSON_SERIALIZE(data PRETTY) AS data FROM GRAPHQL('
    driver {
        driverId: driver_id
        driverName: name
        driverPoints: points
        teamDetails: team @array {
            teamId: team_id
            teamName: name
            teamPoints: points
        }
    }
');
The above example explicitly defines that the fields teamID, teamName and teamPoints must be part of an array in the output:
DATA                                                                           
--------------------------------------------------------------------------------
{                                                                              
  "driverId" : 101,                                                            
  "driverName" : "Lando Norris",                                               
  "driverPoints" : 282,                                                        
  "teamDetails" :                                                              
  [                                                                            
    {                                                                          
      "teamId" : 301,                                                          
      "teamName" : "McLaren Mercedes",                                         
      "teamPoints" : 666                                                       
    }                                                                          
  ]                                                                            
}                                                                              
                                                                                 
{                                                                              
  "driverId" : 102,                                                            
  "driverName" : "Oscar Piastri",                                              
  "driverPoints" : 384,                                                        
  "teamDetails" :                                                              
  [                                                                            
    {                                                                          
      "teamId" : 301,                                                          
      "teamName" : "McLaren Mercedes",                                         
      "teamPoints" : 666                                                       
    }                                                                          
  ]                                                                            
}               
.................................
.................................
20 rows selected.
As an alternative to @array directive, you can also use square brackets to enclose the fields which must be part of an array. So the following example would still produce the same output as using the @array directive:
SELECT JSON_SERIALIZE(data PRETTY) AS data FROM GRAPHQL('
    driver {
        driverId: driver_id
        driverName: name
        driverPoints: points
        teamDetails: team
        [
            {
                teamId: team_id
                teamName: name
                teamPoints: points
            }
        ]
    }
');