Skip to content

Commit 7f313c0

Browse files
committed
Example updates
1 parent 85c667e commit 7f313c0

File tree

8 files changed

+274
-28
lines changed

8 files changed

+274
-28
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @graphql-ts/schema graphql-yoga example
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @graphql-ts/schema graphql-yoga example
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { defineConfig } from "drizzle-kit";
2+
23
export default defineConfig({
34
dialect: "sqlite",
45
schema: "./src/db-schema.ts",
56
dbCredentials: {
6-
url: "./dev.db",
7+
url: process.env.DATABASE_URL ?? "file:./dev.db",
78
},
89
});

examples/drizzle-graphql-yoga/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
"type": "module",
55
"dependencies": {
66
"@graphql-ts/schema": "^1.0.1",
7-
"better-sqlite3": "^11.8.1",
7+
"@libsql/client": "^0.14.0",
88
"drizzle-orm": "^0.40.0",
99
"graphql": "^16.3.0",
1010
"graphql-yoga": "^5.13.1"
1111
},
1212
"devDependencies": {
13-
"@types/better-sqlite3": "^7.6.12",
1413
"@types/node": "^22.13.10",
1514
"drizzle-kit": "^0.30.5",
1615
"tsx": "^4.19.3",
1716
"typescript": "^5.8.2"
1817
},
1918
"scripts": {
20-
"dev": "drizzle-kit push && tsx src/server.ts",
19+
"dev": "cp -n template.db dev.db || tsx src/server.ts",
20+
"db:push": "drizzle-kit db",
21+
"db:push:template": "rm -f template.db && DATABASE_URL=file:./template.db drizzle-kit push",
2122
"types": "tsc"
2223
},
2324
"repository": "https://github.com/Thinkmill/graphql-ts/tree/main/examples/drizzle-graphql-yoga"

examples/drizzle-graphql-yoga/src/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { drizzle } from "drizzle-orm/better-sqlite3";
1+
import { drizzle } from "drizzle-orm/libsql";
22
import * as dbSchema from "./db-schema.js";
33

44
export type DB = ReturnType<typeof createDb>;

examples/drizzle-graphql-yoga/src/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { schema } from "./schema.js";
44
import type { Context } from "./g.js";
55
import { createDb } from "./db.js";
66

7+
const db = createDb("file:./dev.db");
8+
79
const yoga = createYoga({
810
schema,
9-
context: (): Context => ({ db: createDb("./dev.db") }),
11+
context: (): Context => ({ db }),
1012
});
1113

1214
const server = createServer(yoga);
12 KB
Binary file not shown.

0 commit comments

Comments
 (0)