File tree Expand file tree Collapse file tree 8 files changed +274
-28
lines changed
Expand file tree Collapse file tree 8 files changed +274
-28
lines changed Original file line number Diff line number Diff line change 1+ # @graphql-ts/schema graphql-yoga example
Original file line number Diff line number Diff line change 1+ # @graphql-ts/schema graphql-yoga example
Original file line number Diff line number Diff line change 11import { defineConfig } from "drizzle-kit" ;
2+
23export 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} ) ;
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change 1- import { drizzle } from "drizzle-orm/better-sqlite3 " ;
1+ import { drizzle } from "drizzle-orm/libsql " ;
22import * as dbSchema from "./db-schema.js" ;
33
44export type DB = ReturnType < typeof createDb > ;
Original file line number Diff line number Diff line change @@ -4,9 +4,11 @@ import { schema } from "./schema.js";
44import type { Context } from "./g.js" ;
55import { createDb } from "./db.js" ;
66
7+ const db = createDb ( "file:./dev.db" ) ;
8+
79const yoga = createYoga ( {
810 schema,
9- context : ( ) : Context => ( { db : createDb ( "./dev.db" ) } ) ,
11+ context : ( ) : Context => ( { db } ) ,
1012} ) ;
1113
1214const server = createServer ( yoga ) ;
You can’t perform that action at this time.
0 commit comments