LakeQL
  • Overview
Server Setup
  • Create Server
  • Define Config
  • Yoga Configuration
  • createLakeQLApp
Authentication
  • Authorization Model
  • JWT Authentication
  • Permissions
  • Scope Authorization
  • Trino User Impersonation
  • Debugging Identity
Schema Builder
  • Builder Configuration
  • Scalar Types
  • Comparison Types
  • Pagination
  • Input Validation
Customization
  • Custom Queries & Mutations
  • Extending Core
  • CORS Configuration
  • Error Handling
  • API Reference
GitHub
LakeQL
  1. API
  2. Server Setup

Server Setup

Compose and start the LakeQL GraphQL server.

Most apps use createLakeQLApp, which collapses the standard wiring into one call: load the config, derive the auth resolver, build the runtime, compose the server, and register graceful shutdown.

1
2
3
4
5
6
7
8
9
10
11
12
import { createLakeQLApp } from "@lakeql/api/create-app"

import { tokenResolver } from "./auth"

const app = await createLakeQLApp({
  tokenResolver,
  baseDir: import.meta.dirname,
  schemaPath: "./schemas",
})

await app.start()

The wrapper stays fully ejectable. Under the hood it is explicit wiring: load the config, build the runtime, derive the auth resolver, then compose and start the API server around it. Your application owns the runtime lifecycle. The eject example is the expanded form of the standard call, built on defineApiConfig — the underlying primitive. The outline below is a teaser; see the full eject example for the copy-paste form with the empty-permissions warning and graceful shutdown.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39import { defineApiConfig } from "@lakeql/api/config"
import { createApiResolveAuth } from "@lakeql/api/resolve-auth"
import { createLakeQLRuntime, loadConfig } from "@lakeql/config"

import { tokenResolver } from "./auth"

const project = await loadConfig()

const resolveAuth = createApiResolveAuth({
  sources: Object.fromEntries(
    Object.entries(project.config.dataSources).map(([name, def]) => [
      name,
      {
        adapter: def.adapter,
        impersonationResolver: def.impersonationResolver,
      },
    ])
  ),
  globalImpersonationResolver: project.config.auth?.impersonationResolver,
})

const runtime = await createLakeQLRuntime({
  config: project.config,
  adapters: project.adapters,
  resolveAuth,
})

const server = defineApiConfig({
  runtime,
  tokenResolver,
  permissions: project.config.auth?.permissions ?? [],
  baseDir: import.meta.dirname,
  schemaPath: "./schemas",
  graphqlPath: "/graphql",
  healthCheckEndpoint: "/live",
})

await server.startServer()

The pages below walk through the createLakeQLApp wrapper, creating the server, defining the config, and configuring Yoga.

Create Server

Compose the server with defineApiConfig and start it.

Define Config

The options accepted by defineApiConfig.

Yoga Configuration

Override GraphQL Yoga options and add plugins.

createLakeQLApp

The near plug-and-play wrapper for a standard app entry file.

Previous page

API Reference

Next page

Create Server

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39