Using SQL Expressions in the Passing Clause
You can also pass a SQL expression in the passing clause of the GraphQL variables.
Example 3-24 Using SQL Expressions in the Passing Clause of a GraphQL Variable
SELECT JSON_SERIALIZE(data PRETTY) AS data FROM GRAPHQL('
query getTeamByName($teamName: String) {
team (name: $teamName) {
id: team_id
name
points
}
}
' passing (Initcap('haas') || ' ' || 'Ferrari') as "teamName");
In the preceding example, the expression Initcap('haas') || ' ' || 'Ferrari' is first executed and passed as the value to the teamName variable. The requested details from the team table corresponding to the teamName specified in the variable would be fetched in the result:
DATA
--------------------------------------------------------------------------------
{
"id" : 307,
"name" : "Haas Ferrari",
"points" : 58
}
1 row selected.