GraphQL Schema Conventions in Oracle AI Database

The schema consists of two JSON arrays, namely “types” and “quoted”.

A typical GraphQL schema has the following structure where each relational table is represented by a GraphQL type, the columns of the tables are represented as fields of the GraphQL types. The “quoted” array contains the names of the tables that are quoted.

Example 2-2 JSON Schema for GraphQL Schema Representation

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "types": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": { "type": "string" },
          "nullable": { "type": "boolean" },
          "quoted": { "type": "boolean" },
          "description": { "type": "string" },
          "annotations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": { "type": "string" },
                "value": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "quoted": {
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "required": ["types"]
}

The following figure displays a sample mapping between a relational schema and the corresponding GraphQL schema. The relational schema specified here is defined in Setting up the Car Racing Dataset. The GraphQL schema is obtained using the [GET_GRAPHQL_SCHEMA](get_graphql_schema.html#GUID-51719531-16C6-44F8-8017-E4DD34F3120B) API.

Figure 1: Relational Schema to GraphQL Schema Mapping

Description of image follows

Note:

The GraphQL standard allows only alphanumeric ASCII characters and the underscore () for naming types, fields, directives and arguments, with all the names being case-sensitive. While names can start with an underscore (), the only exception is that the names starting with double underscore (_) are disallowed. In RDBMS the unquoted names are not case-sensitive and all alphanumeric characters are allowed in addition to special chars (, $, #). The quoted names are case-sensitive with double quotes (“) and null is not allowed in quoted names.

Relaxations in GraphQL schema for the Oracle DB relational schema:

Quoted names which begin with an alphabet and contain only upper case alphabets, digits or symbols (#, $, _) are treated as unquoted names.