Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
a2649a2
feat(drizzle): adapt Drizzle Relational API v2
xcfox Apr 6, 2025
88551af
chore(dependencies): update mysql2 to version 3.14.0 and adjust packa…
xcfox Apr 6, 2025
bfd502d
refactor(tests): rename user and post references to plural forms acro…
xcfox Apr 6, 2025
bb824b2
refactor(drizzle): enhance filter extraction in DrizzleResolverFactory
xcfox Apr 6, 2025
ffba6c6
refactor(drizzle): update filter structure in DrizzleInputFactory
xcfox Apr 6, 2025
38e9eaa
refactor(drizzle): enhance filter capabilities in DrizzleResolverFactory
xcfox Apr 6, 2025
a3fd243
refactor(drizzle): remove OR operator handling from DrizzleResolverFa…
xcfox Apr 6, 2025
faee338
refactor(drizzle): enhance logical operator support in DrizzleResolve…
xcfox Apr 6, 2025
945c8d5
refactor(drizzle): improve relation error handling in DrizzleResolver…
xcfox Apr 6, 2025
dec48b0
refactor(drizzle): update filter structure in DrizzleInputFactory
xcfox Apr 6, 2025
c9ef6a3
Merge branch 'main' into drizzle-rqbv2
xcfox Apr 8, 2025
8aa3a01
feat(website): update dependencies and refactor user service integra…
xcfox Apr 8, 2025
8aff1e2
docs(getting-started): update database schema and remove user service
xcfox Apr 9, 2025
1f4f77a
docs(getting-started): remove mention of 'services' directory
xcfox Apr 9, 2025
5b769cb
build(drizzle): Bump package version to 0.9.0-beta.1
xcfox Apr 9, 2025
de0eeda
Merge branch 'main' into drizzle-rqbv2
xcfox Apr 15, 2025
22a9de7
Merge branch 'main' into drizzle-rqbv2
xcfox Apr 21, 2025
abb59e7
refactor(drizzle): deprecate `tableName` in favor of `table` in resol…
xcfox Apr 21, 2025
f947cf3
chore(drizzle): bump version to 0.9.0-beta.3
xcfox Apr 21, 2025
905b155
refactor(drizzle): enhance resolver factory to support multiple datab…
xcfox Apr 22, 2025
9f2b4c5
chore(drizzle): bump version to 0.9.0-beta.4
xcfox Apr 22, 2025
c6454f2
Merge branch 'main' into drizzle-rqbv2
xcfox Apr 28, 2025
3d6f620
chore(drizzle): bump version to 0.9.0-beta.5
xcfox Apr 28, 2025
01d153a
chore(cattery-valibot): update dependencies and enhance GraphQL schema
xcfox Apr 28, 2025
5003403
Merge branch 'main' into drizzle-rqbv2
xcfox Apr 28, 2025
a50e533
feat(drizzle): add matchQueryBuilder function to enhance query handling
xcfox Apr 28, 2025
3432401
chore(drizzle): bump version to 0.9.0-beta.7
xcfox Apr 28, 2025
df6e308
feat(drizzle): update tablesFilter in database configurations
xcfox Apr 29, 2025
40b589a
Merge branch 'main' into drizzle-rqbv2
xcfox Apr 29, 2025
4f55e4e
Merge branch 'main' into drizzle-rqbv2
xcfox May 1, 2025
76158ed
chore(dependencies): update pnpm-lock.yaml to resolve version conflic…
xcfox May 1, 2025
a5295b9
Merge branch 'main' into drizzle-rqbv2
xcfox May 6, 2025
7cae1ff
refactor(resolver): update type handling for select queries in Drizzl…
xcfox May 6, 2025
fd2b4f8
test(resolver): enhance logging and query assertions in DrizzleResolv…
xcfox May 6, 2025
b18ba10
fix(tests): remove redundant SQL query assertions in DrizzleResolverF…
xcfox May 6, 2025
7dda665
test(resolver): refactor DrizzleResolverFactory tests to use executor…
xcfox May 6, 2025
5a8c4fe
refactor(tests): simplify imports in resolver-factory tests
xcfox May 6, 2025
782f41d
refactor(resolver): clean up type imports in resolver factory
xcfox May 6, 2025
558e8f5
Merge branch 'main' into drizzle-rqbv2
xcfox May 11, 2025
6a41051
chore(drizzle): bump version to 0.10.0-beta.1 in package.json
xcfox May 11, 2025
ea91745
Merge branch 'main' into drizzle-rqbv2
xcfox May 11, 2025
c5bcf99
refactor(core): clean up documentation in use-resolving-fields.ts
xcfox May 11, 2025
e4afcf5
Merge branch 'main' into drizzle-rqbv2
xcfox May 11, 2025
4ffaa23
chore(drizzle): update CHANGELOG and bump version to 0.10.0-beta.3
xcfox May 13, 2025
0f10463
Merge branch 'main' into drizzle-rqbv2
xcfox May 13, 2025
74c5859
Merge branch 'main' into drizzle-rqbv2
xcfox May 17, 2025
426b284
Merge branch 'main' into drizzle-rqbv2
xcfox May 17, 2025
387b205
feat(docs): add schema definitions for users and posts in dataloader …
xcfox May 17, 2025
8287a3b
Merge branch 'main' into drizzle-rqbv2
xcfox May 17, 2025
9149822
Merge branch 'main' into drizzle-rqbv2
xcfox May 17, 2025
cf84898
chore: bump version of @gqloom/drizzle to 0.10.0-beta.4
xcfox May 17, 2025
89101c7
Merge branch 'main' into drizzle-rqbv2
xcfox May 31, 2025
0a487a9
Merge pull request #34 from xcfox/drizzle-rqbv2
xcfox Jun 9, 2025
1dd369d
feat(helper): add getQueriedColumns function to retrieve queried colu…
xcfox Jun 9, 2025
35a6087
feat(helper): add paramsAsKey function for serializing parameters int…
xcfox Jun 9, 2025
88b21c9
Merge branch 'main' into drizzle-rqbv2-relationField
xcfox Jun 9, 2025
18cbff0
Merge branch 'main' into drizzle-rqbv2-relationField
xcfox Jun 9, 2025
cdb5382
feat(relations): implement relation field loading with support for on…
xcfox Jun 10, 2025
246c46d
feat(relations): add reviewerId and reviewedPosts to Post schema and …
xcfox Jun 10, 2025
835a451
feat(tests): implement tests for limit, offset, and orderBy in to-man…
xcfox Jun 10, 2025
3d95459
refactor(tests): clean up post deletion and insertion comments in res…
xcfox Jun 10, 2025
7b40766
feat(helper): enhance paramsAsKey to handle functions and circular re…
xcfox Jun 10, 2025
7ece35a
feat(relations): enhance QueryToOneFieldOptions and QueryToManyFieldO…
xcfox Jun 10, 2025
8f81269
feat(helper): add getPrimaryColumns function to retrieve primary keys…
xcfox Jun 10, 2025
4427d91
refactor(RelationFieldLoader): remove unused fields for cleaner code
xcfox Jun 10, 2025
ca50849
feat(helper, relation-field-loader, tests): enhance relation field lo…
xcfox Jun 11, 2025
d0debcc
Merge branch 'main' into drizzle-rqbv2-relationField
xcfox Jun 11, 2025
c5b6b91
refactor(helper, relation-field-loader, resolver): streamline functio…
xcfox Jun 11, 2025
01dde82
Merge pull request #82 from xcfox/drizzle-rqbv2-relationField
xcfox Jun 11, 2025
10aee8c
refactor(resolver): unify input argument types for mutations and enha…
xcfox Jun 11, 2025
848d806
Merge branch 'drizzle-rqbv2' into drizzle-input
xcfox Jun 12, 2025
e398c15
refactor(types, helper, factory): update column behavior configuratio…
xcfox Jun 12, 2025
443c1a6
feat(transform): add validation for insert values and enhance column …
xcfox Jun 12, 2025
e82c7ed
feat(transform): enhance DrizzleArgsTransformer with async validation…
xcfox Jun 12, 2025
b36e2d9
feat(factory): implement dynamic column input type retrieval for inse…
xcfox Jun 12, 2025
4b3cbc0
feat(tests): add email validation for user mutations in MySQL, Postgr…
xcfox Jun 12, 2025
9499041
Merge pull request #85 from xcfox/drizzle-input
xcfox Jun 12, 2025
6651422
Merge branch 'main' into drizzle-rqbv2
xcfox Jun 12, 2025
094f457
chore: update peer dependency for @gqloom/core to version 0.10.0
xcfox Jun 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/cattery-valibot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"description": "",
"devDependencies": {
"@types/node": "^22.13.4",
"drizzle-kit": "^0.30.1",
"drizzle-kit": "1.0.0-beta.1-7946562",
"drizzle-orm": "1.0.0-beta.1-7946562",
"tsx": "^4.7.2",
"typescript": "^5.7.3"
},
Expand All @@ -21,8 +22,8 @@
"@gqloom/valibot": "latest",
"@libsql/client": "^0.14.0",
"dotenv": "^16.4.7",
"drizzle-orm": "^0.39.3",
"graphql": "^16.8.1",
"graphql-scalars": "^1.24.1",
"graphql-yoga": "^5.6.0",
"valibot": "1.0.0-rc.1"
}
Expand Down
124 changes: 80 additions & 44 deletions examples/cattery-valibot/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ type UsersItem {
type CatsItem {
id: Int!
name: String!
birthday: String!
birthday: DateTime!
ownerId: Int!
age(currentYear: Int): Float!
owner: UsersItem
}

"""
A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.
"""
scalar DateTime

type Query {
hello(name: String): String!
mine: UsersItem!
Expand All @@ -22,7 +27,7 @@ type Query {
cats(
offset: Int
limit: Int
orderBy: [CatsOrderBy!]
orderBy: CatsOrderBy
where: CatsFilters
): [CatsItem!]!
}
Expand All @@ -44,7 +49,9 @@ input CatsFilters {
name: SQLiteTextFilters
birthday: SQLiteTimestampFilters
ownerId: SQLiteIntegerFilters
OR: [CatsFiltersOr!]
OR: [CatsFiltersNested!]
AND: [CatsFiltersNested!]
NOT: CatsFiltersNested
}

input SQLiteIntegerFilters {
Expand All @@ -54,22 +61,24 @@ input SQLiteIntegerFilters {
lte: Int
gt: Int
gte: Int
inArray: [Int!]
notInArray: [Int!]
in: [Int!]
notIn: [Int!]
isNull: Boolean
isNotNull: Boolean
OR: [SQLiteIntegerFiltersOr!]
OR: [SQLiteIntegerFiltersNested!]
AND: [SQLiteIntegerFiltersNested!]
NOT: SQLiteIntegerFiltersNested
}

input SQLiteIntegerFiltersOr {
input SQLiteIntegerFiltersNested {
eq: Int
ne: Int
lt: Int
lte: Int
gt: Int
gte: Int
inArray: [Int!]
notInArray: [Int!]
in: [Int!]
notIn: [Int!]
isNull: Boolean
isNotNull: Boolean
}
Expand All @@ -85,14 +94,16 @@ input SQLiteTextFilters {
notLike: String
ilike: String
notIlike: String
inArray: [String!]
notInArray: [String!]
in: [String!]
notIn: [String!]
isNull: Boolean
isNotNull: Boolean
OR: [SQLiteTextFiltersOr!]
OR: [SQLiteTextFiltersNested!]
AND: [SQLiteTextFiltersNested!]
NOT: SQLiteTextFiltersNested
}

input SQLiteTextFiltersOr {
input SQLiteTextFiltersNested {
eq: String
ne: String
lt: String
Expand All @@ -103,48 +114,42 @@ input SQLiteTextFiltersOr {
notLike: String
ilike: String
notIlike: String
inArray: [String!]
notInArray: [String!]
in: [String!]
notIn: [String!]
isNull: Boolean
isNotNull: Boolean
}

input SQLiteTimestampFilters {
eq: String
ne: String
lt: String
lte: String
gt: String
gte: String
like: String
notLike: String
ilike: String
notIlike: String
inArray: [String!]
notInArray: [String!]
eq: DateTime
ne: DateTime
lt: DateTime
lte: DateTime
gt: DateTime
gte: DateTime
in: [DateTime!]
notIn: [DateTime!]
isNull: Boolean
isNotNull: Boolean
OR: [SQLiteTimestampFiltersOr!]
OR: [SQLiteTimestampFiltersNested!]
AND: [SQLiteTimestampFiltersNested!]
NOT: SQLiteTimestampFiltersNested
}

input SQLiteTimestampFiltersOr {
eq: String
ne: String
lt: String
lte: String
gt: String
gte: String
like: String
notLike: String
ilike: String
notIlike: String
inArray: [String!]
notInArray: [String!]
input SQLiteTimestampFiltersNested {
eq: DateTime
ne: DateTime
lt: DateTime
lte: DateTime
gt: DateTime
gte: DateTime
in: [DateTime!]
notIn: [DateTime!]
isNull: Boolean
isNotNull: Boolean
}

input CatsFiltersOr {
input CatsFiltersNested {
id: SQLiteIntegerFilters
name: SQLiteTextFilters
birthday: SQLiteTimestampFilters
Expand All @@ -153,15 +158,46 @@ input CatsFiltersOr {

type Mutation {
createUser(data: CreateUserDataInput!): UsersItem!
createCats(values: [CreateCatsValuesInput!]!): [CatsItem!]!
insertCats(
values: [CatsInsertInput!]!
onConflictDoUpdate: CatsInsertOnConflictDoUpdateInput
onConflictDoNothing: CatsInsertOnConflictDoNothingInput
): [CatsItem!]!
createManyCats(values: [CreateManyCatsValuesInput!]!): [CatsItem!]!
}

input CreateUserDataInput {
name: String!
phone: String!
}

input CreateCatsValuesInput {
input CatsInsertInput {
id: Int
name: String!
birthday: DateTime!
ownerId: Int!
}

input CatsInsertOnConflictDoUpdateInput {
target: [CatsTableColumn!]!
set: CatsInsertInput
targetWhere: CatsFilters
setWhere: CatsFilters
}

enum CatsTableColumn {
id
name
birthday
ownerId
}

input CatsInsertOnConflictDoNothingInput {
target: [CatsTableColumn!]
where: CatsFilters
}

input CreateManyCatsValuesInput {
name: String!
birthday: String!
}
4 changes: 1 addition & 3 deletions examples/cattery-valibot/src/contexts/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { createMemoization, useContext } from "@gqloom/core/context"
import { eq } from "drizzle-orm"
import { GraphQLError } from "graphql"
import type { YogaInitialContext } from "graphql-yoga"
import { db } from "../providers"
import { users } from "../schema"

export const useCurrentUser = createMemoization(async () => {
const phone =
useContext<YogaInitialContext>().request.headers.get("authorization")
if (phone == null) throw new GraphQLError("Unauthorized")

const user = await db.query.users.findFirst({ where: eq(users.phone, phone) })
const user = await db.query.users.findFirst({ where: { phone } })
if (user == null) throw new GraphQLError("Unauthorized")
return user
})
38 changes: 34 additions & 4 deletions examples/cattery-valibot/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
import { createServer } from "node:http"
import { weave } from "@gqloom/core"
import { type Middleware, weave } from "@gqloom/core"
import { asyncContextProvider } from "@gqloom/core/context"
import { ValibotWeaver } from "@gqloom/valibot"
import { GraphQLDateTime, GraphQLJSONObject } from "graphql-scalars"
import { createYoga } from "graphql-yoga"
import { resolvers } from "./resolvers"

const schema = weave(asyncContextProvider, ValibotWeaver, ...resolvers)
const exceptionFilter: Middleware = async (next) => {
try {
return await next()
} catch (error) {
// biome-ignore lint/suspicious/noConsole: log error
console.error(error)
if (error instanceof Error) {
throw new GraphQLError(error.message)
}
throw new GraphQLError("There has been something wrong...")
}
}

const schema = weave(
asyncContextProvider,
ValibotWeaver,
...resolvers,
exceptionFilter,
DrizzleWeaver.config({
presetGraphQLType(column) {
if (column.dataType === "date") {
return GraphQLDateTime
}
if (column.dataType === "json") {
return GraphQLJSONObject
}
},
})
)

const yoga = createYoga({ schema })
createServer(yoga).listen(4000, () => {
Expand All @@ -13,8 +43,8 @@ createServer(yoga).listen(4000, () => {

import * as fs from "fs"
import * as path from "path"
import { asyncContextProvider } from "@gqloom/core/context"
import { printSchema } from "graphql"
import { DrizzleWeaver } from "@gqloom/drizzle"
import { GraphQLError, printSchema } from "graphql"
if (process.env.NODE_ENV !== "production") {
fs.writeFileSync(
path.resolve(__dirname, "../schema.graphql"),
Expand Down
4 changes: 2 additions & 2 deletions examples/cattery-valibot/src/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { drizzle } from "drizzle-orm/libsql"
import * as schema from "../schema"
import { relations } from "../schema/relations"

export const db = drizzle(process.env.DB_FILE_NAME ?? "file:local.db", {
schema,
relations,
})
6 changes: 4 additions & 2 deletions examples/cattery-valibot/src/resolvers/cat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useCurrentUser } from "../contexts"
import { db } from "../providers"
import { cats } from "../schema"

const catResolverFactory = drizzleResolverFactory(db, "cats")
const catResolverFactory = drizzleResolverFactory(db, cats)

export const catResolver = resolver.of(cats, {
cats: catResolverFactory.selectArrayQuery(),
Expand All @@ -23,7 +23,9 @@ export const catResolver = resolver.of(cats, {

owner: catResolverFactory.relationField("owner"),

createCats: catResolverFactory.insertArrayMutation({
insertCats: catResolverFactory.insertArrayMutation(),

createManyCats: catResolverFactory.insertArrayMutation({
input: v.pipeAsync(
v.objectAsync({
values: v.arrayAsync(
Expand Down
15 changes: 3 additions & 12 deletions examples/cattery-valibot/src/resolvers/user.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { mutation, query, resolver } from "@gqloom/core"
import { drizzleResolverFactory } from "@gqloom/drizzle"
import { eq } from "drizzle-orm"
import * as v from "valibot"
import { useCurrentUser } from "../contexts"
import { db } from "../providers"
import { users } from "../schema"

const userResolverFactory = drizzleResolverFactory(db, "users")
const userResolverFactory = drizzleResolverFactory(db, users)

export const userResolver = resolver.of(users, {
cats: userResolverFactory.relationField("cats"),
Expand All @@ -15,19 +14,11 @@ export const userResolver = resolver.of(users, {

usersByName: query(users.$list())
.input({ name: v.string() })
.resolve(({ name }) => {
return db.query.users.findMany({
where: eq(users.name, name),
})
}),
.resolve(({ name }) => db.query.users.findMany({ where: { name } })),

userByPhone: query(users.$nullable())
.input({ phone: v.string() })
.resolve(({ phone }) => {
return db.query.users.findFirst({
where: eq(users.phone, phone),
})
}),
.resolve(({ phone }) => db.query.users.findFirst({ where: { phone } })),

createUser: mutation(users)
.input({
Expand Down
12 changes: 0 additions & 12 deletions examples/cattery-valibot/src/schema/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { drizzleSilk } from "@gqloom/drizzle"
import { relations } from "drizzle-orm"
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"

export const users = drizzleSilk(
Expand All @@ -10,10 +9,6 @@ export const users = drizzleSilk(
})
)

export const usersRelations = relations(users, ({ many }) => ({
cats: many(cats),
}))

export const cats = drizzleSilk(
sqliteTable("cats", {
id: integer().primaryKey({ autoIncrement: true }),
Expand All @@ -24,10 +19,3 @@ export const cats = drizzleSilk(
.references(() => users.id),
})
)

export const catsRelations = relations(cats, ({ one }) => ({
owner: one(users, {
fields: [cats.ownerId],
references: [users.id],
}),
}))
Loading