LakeQL registers three custom scalar types on the shared builder. These extend the standard GraphQL scalars to handle common data types from Trino.
Date #
A date-only scalar (no time component). Uses DateResolver from graphql-scalars.
-
Input:
ISO 8601 date string (e.g.,
"2024-01-15") -
Output:
JavaScript
Dateobject
DateTime #
A full timestamp scalar with timezone support. Uses DateTimeResolver from graphql-scalars.
-
Input:
ISO 8601 datetime string (e.g.,
"2024-01-15T10:30:00Z") -
Output:
JavaScript
Dateobject
File #
An input-only scalar for file uploads. Attempting to serialize (output) a File scalar throws an error.
-
Input:
Fileobject (from multipart form data) -
Output:
Not supported (throws
"Uploads can only be used as input types")
Source code #
1
2
3
4
5
6
7
8
9
10
11
12
import { DateResolver, DateTimeResolver } from "graphql-scalars"
import { builder } from "@lakeql/api/builder"
builder.addScalarType("Date", DateResolver, {})
builder.addScalarType("DateTime", DateTimeResolver, {})
builder.scalarType("File", {
serialize: () => {
throw new Error("Uploads can only be used as input types")
},
})
Usage in custom schemas #
Reference these scalars by name when defining fields:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { builder } from "@lakeql/api/builder"
const EventType = builder
.objectRef<{
id: string
name: string
createdAt: Date
occurredOn: Date
}>("Event")
.implement({
fields: (t) => ({
id: t.exposeID("id"),
name: t.exposeString("name"),
createdAt: t.expose("createdAt", { type: "DateTime" }),
occurredOn: t.expose("occurredOn", { type: "Date" }),
}),
})