@drizzle-graphql-suite/schema 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +56 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,17 +1,41 @@
1
1
  # @drizzle-graphql-suite/schema
2
2
 
3
+ > Part of [`drizzle-graphql-suite`](https://github.com/annexare/drizzle-graphql-suite).
4
+ > See also: [`client`](https://github.com/annexare/drizzle-graphql-suite/tree/main/packages/client) | [`query`](https://github.com/annexare/drizzle-graphql-suite/tree/main/packages/query)
5
+
3
6
  Auto-generates a complete GraphQL schema with CRUD operations, relation-level filtering, and hooks from Drizzle PostgreSQL schemas.
4
7
 
8
+ ## Installation
9
+
10
+ ```bash
11
+ bun add @drizzle-graphql-suite/schema
12
+ ```
13
+
14
+ ```bash
15
+ npm install @drizzle-graphql-suite/schema
16
+ ```
17
+
18
+ Or install the full suite:
19
+
20
+ ```bash
21
+ bun add drizzle-graphql-suite
22
+ ```
23
+
24
+ ```bash
25
+ npm install drizzle-graphql-suite
26
+ ```
27
+
5
28
  ## Motivation
6
29
 
7
30
  Inspired by [`drizzle-graphql`](https://github.com/drizzle-team/drizzle-graphql), this package is a purpose-built replacement focused on PostgreSQL. Key improvements:
8
31
 
32
+ - **Small generated schema** — the generated schema stays compact even when supporting self-relations and deeply nested relations, thanks to configurable depth limiting (`limitRelationDepth`, `limitSelfRelationDepth`), per-relation pruning (`pruneRelations`), and per-table control (`tables.exclude`, per-table `queries`/`mutations` toggles) — up to 90% schema size reduction when tuned
33
+ - **Native PostgreSQL JSON/JSONB support** — `json` and `jsonb` columns map to a custom `JSON` GraphQL scalar, so structured data passes through without manual type wiring
9
34
  - **Relation-level filtering** with EXISTS subqueries (`some`/`every`/`none` quantifiers)
10
35
  - **Per-operation hooks system** (before/after/resolve) for auth, audit, and custom logic
11
36
  - **Count queries** with full filter support
12
37
  - **`buildEntities()`** for composable schema building (avoids redundant schema validation)
13
38
  - **Configurable query/mutation suffixes** for naming customization
14
- - **Per-table schema control** — exclude tables, disable queries/mutations per table (up to 90% schema size reduction)
15
39
  - **Self-relation depth limiting** — separate from general depth, prevents exponential type growth
16
40
  - **Relation pruning** — `false`, `'leaf'`, or `{ only: [...] }` per relation
17
41
  - **`buildSchemaFromDrizzle()`** — no database connection needed (for codegen/introspection)
@@ -38,6 +62,37 @@ const { schema, entities } = buildSchema(db, {
38
62
  const yoga = createYoga({ schema })
39
63
  ```
40
64
 
65
+ #### Framework Integration
66
+
67
+ **Next.js App Router**
68
+
69
+ ```ts
70
+ // app/api/graphql/route.ts
71
+ import { createYoga } from 'graphql-yoga'
72
+ import { schema } from '@/lib/schema' // from buildSchema() above
73
+
74
+ const { handleRequest } = createYoga({
75
+ schema,
76
+ graphqlEndpoint: '/api/graphql',
77
+ fetchAPI: { Response },
78
+ })
79
+
80
+ export { handleRequest as GET, handleRequest as POST }
81
+ ```
82
+
83
+ **ElysiaJS**
84
+
85
+ ```ts
86
+ // server.ts
87
+ import { Elysia } from 'elysia'
88
+ import { yoga } from '@elysiajs/graphql-yoga'
89
+ import { schema } from './schema' // from buildSchema() above
90
+
91
+ new Elysia()
92
+ .use(yoga({ schema }))
93
+ .listen(3000)
94
+ ```
95
+
41
96
  ### `buildEntities(db, config?)`
42
97
 
43
98
  Returns `GeneratedEntities` only — queries, mutations, inputs, and types — without constructing a `GraphQLSchema`. Use this when composing into a larger schema (e.g., Pothos) to avoid redundant schema validation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drizzle-graphql-suite/schema",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "GraphQL schema builder with CRUD operations, relation filtering, and hooks from Drizzle ORM",
5
5
  "license": "MIT",
6
6
  "author": "https://github.com/dmythro",