GraphQL Schema Introspection
Use GraphQL schema introspection to inspect GraphQL types, type details, and runtime directives.
Starting in 23.26.3, you can use GraphQL introspection fields with the GRAPHQL() table function.
List GraphQL Types
The following example lists the available GraphQL types for the current schema:
SELECT JSON_SERIALIZE(data PRETTY) AS data FROM GRAPHQL('
query getGraphQLTypes {
__schema {
types {
name
kind
description
}
}
}
');
The following output excerpt shows part of the returned type list:
DATA
--------------------------------------------------------------------------------
{
"types" :
[
{
"name" : "STRING",
"kind" : "SCALAR",
"description" : "A character sequence."
},
{
"name" : "INT",
"kind" : "SCALAR",
"description" : "A signed 32-bit integer"
},
...
{
"name" : "TEAM",
"kind" : "OBJECT",
"description" : null
},
{
"name" : "DRIVER",
"kind" : "OBJECT",
"description" : null
},
...
]
}
1 row selected.
Inspect a GraphQL Type
The following example inspects one type in detail:
SELECT JSON_SERIALIZE(data PRETTY) AS data FROM GRAPHQL('
query getTeamTypeDetails {
__type(name: "TEAM") {
name
kind
description
fields {
name
description
type {
name
kind
description
ofType {
name
kind
description
}
}
}
}
}
');
The following output excerpt shows part of the returned type details:
DATA
--------------------------------------------------------------------------------
{
"name" : "TEAM",
"kind" : "OBJECT",
"description" : null,
"fields" :
[
{
"name" : "TEAM_ID",
"description" : null,
"type" :
{
"name" : null,
"kind" : "NON_NULL",
"description" : null,
"ofType" :
{
"name" : "INT",
"kind" : "SCALAR",
"description" : "A signed 32-bit integer"
}
}
},
{
"name" : "NAME",
"description" : "Official team name",
"type" :
{
"name" : null,
"kind" : "NON_NULL",
"description" : null,
"ofType" :
{
"name" : "STRING",
"kind" : "SCALAR",
"description" : "A character sequence."
}
}
},
...
{
"name" : "DRIVER",
"description" : null,
"type" :
{
"name" : null,
"kind" : "LIST",
"description" : null,
"ofType" :
{
"name" : "DRIVER",
"kind" : "OBJECT",
"description" : null
}
}
}
]
}
1 row selected.
Inspect Runtime Directives
The following example inspects the directives supported by Oracle GraphQL at runtime:
SELECT data FROM GRAPHQL('
query getGraphQLDirectives {
__schema {
directives {
name
description
args {
name
description
type {
name
kind
description
ofType {
name
kind
description
}
}
}
}
}
}
');
The following output excerpt shows part of the returned directive list:
DATA
--------------------------------------------------------------------------------
{
"directives" :
[
{
"name" : "WHERE",
"description" : "The @WHERE directive is used to filter the query results. It has only one argument SQL, in which we can specify the predicate for the base table.",
"args" :
[
{
"name" : "SQL",
"description" : "SQL expression for where clause",
"type" :
{
"name" : null,
"kind" : "NON_NULL",
"description" : null,
"ofType" :
{
"name" : "STRING",
"kind" : "SCALAR",
"description" : "A character sequence."
}
}
}
]
},
{
"name" : "ORDERBY",
"description" : "The @ORDERBY directive is used to order the objects in a field returning JSON array of objects. It has only one arguments SQL, in which we can specify the SQL expression for ordering.",
"args" :
[
{
"name" : "SQL",
"description" : "SQL expression for orderby clause",
"type" :
{
"name" : null,
"kind" : "NON_NULL",
"description" : null,
"ofType" :
{
"name" : "STRING",
"kind" : "SCALAR",
"description" : "A character sequence."
}
}
}
]
},
...
]
}
1 row selected.