Oracle Supported GraphQL Arguments for Duality View Creation

GraphQL arguments in Oracle AI Database serve a purpose similar to the WHERE clause in SQL, allowing you to filter or select records that meet specified conditions.

For simple equality predicates on table columns, arguments can be used as an alternative to the @WHERE directive. The syntax for defining arguments involves specifying one or more comma-separated field-value pairs, where each field name is paired with the corresponding value to be filtered in the output. The following example uses team (name: "Ferrari") argument syntax to filter the document only specific to the team named "Ferrari".

Example 9-12 Using GraphQL Arguments with Duality View Creation Syntax

CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW team_ferrari_dv AS
team (name: "Ferrari") @insert @update @delete {
    _id: team_id
    name: name
    points: points
    driver: driver @insert @update {
        driverId: driver_id
        name: name
        points: points
    }
};
 
SELECT JSON_SERIALIZE(data PRETTY) AS data FROM team_ferrari_dv;
The SQL equivalent of the above GraphQL query is provided below to illustrate how arguments in GraphQL simplify the process of expressing equality conditions.

CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW team_dv_check_disabled AS 
SELECT JSON {
    '_id': team_id,
    'name': name,
    'points': points,
    'driver': (SELECT JSON_ARRAYAGG (
        JSON {
            'driverId': driver_id,
            'name': name,
            'points': points 
        }
    ) FROM driver d WITH (INSERT, UPDATE) WHERE d.team_id = t.team_id)
} FROM team t WITH (INSERT, UPDATE, DELETE)
WHERE t.name = 'Ferrari' WITH CHECK OPTION;