You have to create an UDF + Type + Query, eg:
CreateFunction({
name: 'fetch_qql_meta',
body:
Query(
Lambda(
['ref_name'],
Map(
Select(["data", "gql", "meta", "fields"], Get(Collection(Var('ref_name')))),
r => ToObject({
'name': Select('name', r),
'type': If(Contains(['type', 'NotNull', 'Named'], r),
Select(['type', 'NotNull', 'Named'], r),
Select(['type', 'Named'], r)),
'nullable': Not(Contains(['type', 'NotNull'], r))
})
)
)
)
})
the result will be something like:
Call('fetch_qql_meta', ['Stock'])
[
{
name: "ticker",
type: "String",
nullable: true
},
{
name: "name",
type: "String",
nullable: false
},
{
name: "market",
type: "String",
nullable: false
},
{
name: "lastPrice",
type: "Float",
nullable: false
}
]
then, the graphql DDL:
type GQLMeta @embedded {
name: String!
type: String!
nullable: Boolean!
}
type Query {
fetchGQLMeta(ref_name: String): [GQLMeta!] @resolver(name: "fetch_qql_meta")
}
graphql command from Playground:
# Write your query or mutation here
query GetStockMata {
fetchGQLMeta(ref_name: "Stock") {
name
nullable
type
}
}
returns:
{
"data": {
"fetchGQLMeta": [
{
"name": "ticker",
"nullable": true,
"type": "String"
},
{
"name": "name",
"nullable": false,
"type": "String"
},
{
"name": "market",
"nullable": false,
"type": "String"
},
{
"name": "lastPrice",
"nullable": false,
"type": "Float"
}
]
}
}
You can get more details here https://docs.fauna.com/fauna/current/api/graphql/functions