@vantreeseba/drizzle-graphql 9.1.1 → 10.0.1
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.
- package/README.md +22 -1
- package/dist/index.cjs +502 -251
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -2
- package/dist/index.d.ts +50 -2
- package/dist/index.js +494 -244
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Automatically create GraphQL schema or customizable schema config fields from Dr
|
|
|
51
51
|
// Create a custom one
|
|
52
52
|
customUsers: {
|
|
53
53
|
// You can reuse and customize types from original schema
|
|
54
|
-
type: new GraphQLList(new GraphQLNonNull(entities.types.
|
|
54
|
+
type: new GraphQLList(new GraphQLNonNull(entities.types.Users)),
|
|
55
55
|
args: {
|
|
56
56
|
// You can reuse inputs as well
|
|
57
57
|
where: {
|
|
@@ -79,12 +79,20 @@ Automatically create GraphQL schema or customizable schema config fields from Dr
|
|
|
79
79
|
const yoga = createYoga({
|
|
80
80
|
schema
|
|
81
81
|
})
|
|
82
|
+
const server = createServer(yoga)
|
|
82
83
|
|
|
83
84
|
server.listen(4000, () => {
|
|
84
85
|
console.info('Server is running on http://localhost:4000/graphql')
|
|
85
86
|
})
|
|
86
87
|
```
|
|
87
88
|
|
|
89
|
+
The keys on `entities` follow the naming rules below: with the defaults, table `users`
|
|
90
|
+
gives type `entities.types.Users`, inputs `entities.inputs.UsersFilters` /
|
|
91
|
+
`UsersOrderBy` / `CreateUsersInput` / `UpdateUsersInput`, queries
|
|
92
|
+
`entities.queries.users` / `usersSingle`, and mutations
|
|
93
|
+
`entities.mutations.createUsers` / `updateUsers` / `deleteUsers`. A `typeNameMapper`
|
|
94
|
+
changes these keys too, so a composed schema has to use the mapped names.
|
|
95
|
+
|
|
88
96
|
## Naming the generated types and fields
|
|
89
97
|
|
|
90
98
|
By default every name comes from the table's key in the Drizzle schema: `tasks` gives type
|
|
@@ -1831,6 +1839,19 @@ image, a stored value the scalar transporting it cannot represent, is
|
|
|
1831
1839
|
`DRIZZLE_UNREPRESENTABLE_VALUE`; it says the data is out of range, not that the request was
|
|
1832
1840
|
wrong.
|
|
1833
1841
|
|
|
1842
|
+
An `update`'s `set` giving a `NOT NULL` column an explicit `null` is `DRIZZLE_NOT_NULL`, and the
|
|
1843
|
+
error names the column. Every field of an update input is nullable — that is what makes a partial
|
|
1844
|
+
`set` possible — so the nullability says nothing about the column, and an update has no default to
|
|
1845
|
+
fall back on: `null` there can only mean "write null". Nothing is written, including the rest of
|
|
1846
|
+
the `set`. To leave a column alone, omit it.
|
|
1847
|
+
|
|
1848
|
+
An **insert** reads the same `null` the other way, and is unchanged. A `NOT NULL` column's field
|
|
1849
|
+
on a create input is non-null unless the database, drizzle, or a nested `create` can fill it in,
|
|
1850
|
+
so the only nulls that reach a resolver are ones the schema offered as "I am not supplying this" —
|
|
1851
|
+
and they let the default apply, which is what makes `id: $id` with a null variable insert a new
|
|
1852
|
+
row. A `NOT NULL` column with nothing to fill it is rejected while GraphQL coerces the request.
|
|
1853
|
+
Upserts take the create input, so they follow the insert rule.
|
|
1854
|
+
|
|
1834
1855
|
The `drizzle` block is only on errors raised from inside a field. An argument rejected while
|
|
1835
1856
|
GraphQL coerces the request — a `BigInt` variable that is not an integer, say — is rejected
|
|
1836
1857
|
before any resolver runs, so it carries its `code` but no `drizzle` and no `path`.
|