-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from modevol-com/drizzle
- Loading branch information
Showing
40 changed files
with
5,815 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: '3.8' | ||
|
||
services: | ||
mysql: | ||
image: mysql:9.1 | ||
container_name: gqloom_mysql | ||
restart: unless-stopped | ||
environment: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: 1 | ||
ports: | ||
- "3306:3306" | ||
volumes: | ||
- mysql_data:/var/lib/mysql | ||
|
||
postgres: | ||
image: postgres:17.2 | ||
container_name: gqloom_postgres | ||
restart: unless-stopped | ||
environment: | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
|
||
volumes: | ||
mysql_data: | ||
postgres_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
test/**/*.db* | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineConfig } from "drizzle-kit" | ||
import { config } from "./env.config" | ||
|
||
export default defineConfig({ | ||
dialect: "mysql", | ||
schema: "./test/schema/mysql.ts", | ||
dbCredentials: { | ||
url: config.mysqlUrl, | ||
}, | ||
tablesFilter: ["drizzle_*"], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import "dotenv/config" | ||
import { defineConfig } from "drizzle-kit" | ||
import { config } from "./env.config" | ||
|
||
export default defineConfig({ | ||
dialect: "postgresql", | ||
schema: "./test/schema/postgres.ts", | ||
dbCredentials: { | ||
url: config.postgresUrl, | ||
}, | ||
tablesFilter: ["drizzle_*"], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from "drizzle-kit" | ||
|
||
export default defineConfig({ | ||
dialect: "sqlite", | ||
schema: "./test/schema/sqlite.ts", | ||
dbCredentials: { | ||
url: "file:./test/schema/sqlite-1.db", | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from "drizzle-kit" | ||
|
||
export default defineConfig({ | ||
dialect: "sqlite", | ||
schema: "./test/schema/sqlite.ts", | ||
dbCredentials: { | ||
url: "file:./test/schema/sqlite.db", | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import * as dotenv from "dotenv" | ||
|
||
dotenv.config({ path: new URL("./.env", import.meta.url) }) | ||
|
||
export const config = { | ||
mysqlUrl: process.env.MYSQL_URL ?? "mysql://root@localhost:3306/mysql", | ||
postgresUrl: | ||
process.env.POSTGRESQL_URL ?? "postgres://postgres@localhost:5432/postgres", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"name": "@gqloom/drizzle", | ||
"version": "0.6.0", | ||
"description": "GQLoom integration with Drizzle ORM", | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/index.d.cts", | ||
"default": "./dist/index.cjs" | ||
} | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"push": "drizzle-kit push --config=drizzle-mysql.config.ts && drizzle-kit push --config=drizzle-postgres.config.ts && drizzle-kit push --config=drizzle-sqlite.config.ts && drizzle-kit push --config=drizzle-sqlite-1.config.ts", | ||
"postinstall": "pnpm run push" | ||
}, | ||
"files": ["dist"], | ||
"keywords": [ | ||
"gqloom", | ||
"graphql", | ||
"schema", | ||
"typescript", | ||
"drizzle", | ||
"drizzle-orm" | ||
], | ||
"author": "xcfox", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@gqloom/core": ">= 0.6.0", | ||
"drizzle-orm": ">= 0.38.0", | ||
"graphql": ">= 16.8.0" | ||
}, | ||
"devDependencies": { | ||
"@gqloom/core": "workspace:*", | ||
"@libsql/client": "^0.14.0", | ||
"@types/pg": "^8.11.10", | ||
"dotenv": "^16.4.7", | ||
"drizzle-kit": "^0.30.1", | ||
"drizzle-orm": "^0.38.3", | ||
"graphql": "^16.8.1", | ||
"graphql-yoga": "^5.6.0", | ||
"mysql2": "^3.12.0", | ||
"pg": "^8.13.1", | ||
"tsx": "^4.7.2", | ||
"valibot": "1.0.0-beta.12" | ||
}, | ||
"homepage": "https://gqloom.dev/", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/modevol-com/gqloom.git", | ||
"directory": "packages/drizzle" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { Column, SQL } from "drizzle-orm" | ||
import { sql } from "drizzle-orm" | ||
|
||
/** | ||
* Creates an IN clause for multiple columns | ||
* Example: (col1, col2) IN ((val1, val2), (val3, val4)) | ||
*/ | ||
export function inArrayMultiple( | ||
columns: Column[], | ||
values: readonly unknown[][] | ||
): SQL<unknown> { | ||
// Early return for empty values | ||
if (values.length === 0) { | ||
return sql`FALSE` | ||
} | ||
// Create (col1, col2, ...) part | ||
const columnsPart = sql`(${sql.join( | ||
columns.map((c) => sql`${c}`), | ||
sql`, ` | ||
)})` | ||
|
||
// Create ((val1, val2), (val3, val4), ...) part | ||
const valueTuples = values.map( | ||
(tuple) => | ||
sql`(${sql.join( | ||
tuple.map((v) => sql`${v}`), | ||
sql`, ` | ||
)})` | ||
) | ||
const valuesPart = sql.join(valueTuples, sql`, `) | ||
|
||
// Combine into final IN clause | ||
return sql`${columnsPart} IN (${valuesPart})` | ||
} |
Oops, something went wrong.