@smartive/graphql-magic 16.3.0 → 16.3.2

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.
@@ -12,7 +12,7 @@ jobs:
12
12
  - uses: actions/checkout@v3
13
13
  with:
14
14
  submodules: true
15
- - uses: actions/setup-node@v3
15
+ - uses: actions/setup-node@v4
16
16
  with:
17
17
  node-version: 20
18
18
  - run: npm ci
@@ -30,7 +30,7 @@ jobs:
30
30
  persist-credentials: false
31
31
 
32
32
  - name: Setup Node
33
- uses: actions/setup-node@v3
33
+ uses: actions/setup-node@v4
34
34
  with:
35
35
  node-version: '20'
36
36
  - name: Install and Build
package/CHANGELOG.md CHANGED
@@ -1,6 +1,7 @@
1
- # [16.3.0](https://github.com/smartive/graphql-magic/compare/v16.2.6...v16.3.0) (2025-02-03)
1
+ ## [16.3.2](https://github.com/smartive/graphql-magic/compare/v16.3.1...v16.3.2) (2025-02-25)
2
2
 
3
3
 
4
- ### Features
4
+ ### Bug Fixes
5
5
 
6
- * Support !== in staticEval ([d086e43](https://github.com/smartive/graphql-magic/commit/d086e43052f03187c7619eb12abbcdeb4108d235))
6
+ * **deps:** update dependency uuid to v11 ([#221](https://github.com/smartive/graphql-magic/issues/221)) ([c6fda4e](https://github.com/smartive/graphql-magic/commit/c6fda4e3f1ed08c57374ccfc8d0077af55a8fc26))
7
+ * Move deleted filters to where ([#240](https://github.com/smartive/graphql-magic/issues/240)) ([4bae9fc](https://github.com/smartive/graphql-magic/commit/4bae9fcf3581c26cafe10ac1a5250008a4e010e5))
package/README.md CHANGED
@@ -1,11 +1,28 @@
1
1
  # graphql-magic
2
2
 
3
- Welcome to graphql-magic!
3
+ Welcome to `graphql-magic`, a revolutionary library that transforms the way of working with GraphQL and databases in TypeScript projects. This library aims to streamline the development process, enhancing speed, efficiency, and type safety.
4
4
 
5
- See the incredibly up-to-date [docs](https://smartive.github.io/graphql-magic/).
5
+ ## Key Features
6
+
7
+ - **Model First**: Define your models and their relations directly in TypeScript. `graphql-magic` seamlessly integrates with your TypeScript projects, ensuring type safety and reducing the need for redundant code.
8
+
9
+ - **Automatic GraphQL Schema Generation**: Forget about manually writing your GraphQL schemas. With `graphql-magic`, your TypeScript model definitions are automatically transformed into fully functional GraphQL schemas.
10
+
11
+ - **Database Management Made Easy**: Leveraging the power of Knex for migrations, `graphql-magic` not only generates the necessary database schemas based on your models but also handles all database migrations for you. This means your database is always in sync with your application's models without any extra effort.
12
+
13
+ - **Speed and Efficiency**: Designed with performance in mind, `graphql-magic` ensures that your applications run swiftly and efficiently, handling complex queries and mutations with ease.
14
+
15
+
16
+ ## Why graphql-magic?
17
+
18
+ `graphql-magic` was developed by smartive, representing the culmination of years of experience in creating robust, scalable, and efficient web applications. Suitable for both small projects and large-scale enterprise applications, `graphql-magic` offers the necessary tools for success.
19
+
20
+ The magic of `graphql-magic` takes TypeScript projects to the next level. To get started, visit the [Documentation](https://smartive.github.io/graphql-magic/).
6
21
 
7
22
  ## Development
8
23
 
24
+ Start the required dependencies such as a Postgres database:
25
+
9
26
  ```
10
27
  npm run deps
11
28
  ```
@@ -14,10 +31,12 @@ npm run deps
14
31
  npm bootstrap
15
32
  ```
16
33
 
34
+ Bootstrap the application by generating all the models, migrations and graphql schema:
17
35
  ```
18
- npm test
36
+ npm run bootstrap
19
37
  ```
20
38
 
39
+ Run the tests to see if everything works properly:
21
40
  ```
22
- npm run build
41
+ npm test
23
42
  ```
@@ -2118,18 +2118,6 @@ var applyFilters = (node, query, joins) => {
2118
2118
  normalizedArguments.orderBy = [{ createdAt: "DESC" }];
2119
2119
  }
2120
2120
  }
2121
- if (node.model.deletable) {
2122
- if (!normalizedArguments.where) {
2123
- normalizedArguments.where = {};
2124
- }
2125
- if (normalizedArguments.where.deleted && (!Array.isArray(normalizedArguments.where.deleted) || normalizedArguments.where.deleted.some((v) => v))) {
2126
- if (node.ctx.user?.role !== "ADMIN") {
2127
- throw new ForbiddenError("You cannot access deleted entries.");
2128
- }
2129
- } else {
2130
- normalizedArguments.where.deleted = false;
2131
- }
2132
- }
2133
2121
  const { limit, offset, orderBy, where, search } = normalizedArguments;
2134
2122
  if (limit) {
2135
2123
  query.limit(limit);
@@ -2145,16 +2133,29 @@ var applyFilters = (node, query, joins) => {
2145
2133
  [getColumn(node, "type")]: node.model.name
2146
2134
  });
2147
2135
  }
2148
- if (where) {
2149
- const ops = [];
2150
- applyWhere2(node, where, ops, joins);
2151
- void apply(query, ops);
2152
- }
2136
+ const ops = [];
2137
+ applyWhere2(node, where, ops, joins);
2138
+ void apply(query, ops);
2153
2139
  if (search) {
2154
2140
  void applySearch(node, search, query);
2155
2141
  }
2156
2142
  };
2157
2143
  var applyWhere2 = (node, where, ops, joins) => {
2144
+ if (node.model.deletable) {
2145
+ if (!where) {
2146
+ where = {};
2147
+ }
2148
+ if (where.deleted && (!Array.isArray(where.deleted) || where.deleted.some((v) => v))) {
2149
+ if (node.ctx.user?.role !== "ADMIN") {
2150
+ throw new ForbiddenError("You cannot access deleted entries.");
2151
+ }
2152
+ } else {
2153
+ where.deleted = false;
2154
+ }
2155
+ }
2156
+ if (!where) {
2157
+ return;
2158
+ }
2158
2159
  const aliases = node.ctx.aliases;
2159
2160
  for (const key of Object.keys(where)) {
2160
2161
  const value2 = where[key];
@@ -17,20 +17,6 @@ export const applyFilters = (node, query, joins) => {
17
17
  normalizedArguments.orderBy = [{ createdAt: 'DESC' }];
18
18
  }
19
19
  }
20
- if (node.model.deletable) {
21
- if (!normalizedArguments.where) {
22
- normalizedArguments.where = {};
23
- }
24
- if (normalizedArguments.where.deleted &&
25
- (!Array.isArray(normalizedArguments.where.deleted) || normalizedArguments.where.deleted.some((v) => v))) {
26
- if (node.ctx.user?.role !== 'ADMIN') {
27
- throw new ForbiddenError('You cannot access deleted entries.');
28
- }
29
- }
30
- else {
31
- normalizedArguments.where.deleted = false;
32
- }
33
- }
34
20
  const { limit, offset, orderBy, where, search } = normalizedArguments;
35
21
  if (limit) {
36
22
  // eslint-disable-next-line @typescript-eslint/no-floating-promises -- we do not need to await knex here
@@ -48,16 +34,30 @@ export const applyFilters = (node, query, joins) => {
48
34
  [getColumn(node, 'type')]: node.model.name,
49
35
  });
50
36
  }
51
- if (where) {
52
- const ops = [];
53
- applyWhere(node, where, ops, joins);
54
- void apply(query, ops);
55
- }
37
+ const ops = [];
38
+ applyWhere(node, where, ops, joins);
39
+ void apply(query, ops);
56
40
  if (search) {
57
41
  void applySearch(node, search, query);
58
42
  }
59
43
  };
60
44
  const applyWhere = (node, where, ops, joins) => {
45
+ if (node.model.deletable) {
46
+ if (!where) {
47
+ where = {};
48
+ }
49
+ if (where.deleted && (!Array.isArray(where.deleted) || where.deleted.some((v) => v))) {
50
+ if (node.ctx.user?.role !== 'ADMIN') {
51
+ throw new ForbiddenError('You cannot access deleted entries.');
52
+ }
53
+ }
54
+ else {
55
+ where.deleted = false;
56
+ }
57
+ }
58
+ if (!where) {
59
+ return;
60
+ }
61
61
  const aliases = node.ctx.aliases;
62
62
  for (const key of Object.keys(where)) {
63
63
  const value = where[key];
@@ -1 +1 @@
1
- {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../src/resolvers/filters.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAkB,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAA0B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAE7F,MAAM,CAAC,MAAM,eAAe,GAA2B;IACrD,EAAE,EAAE,QAAQ;IACZ,GAAG,EAAE,SAAS;IACd,EAAE,EAAE,QAAQ;IACZ,GAAG,EAAE,SAAS;CACf,CAAC;AAWF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAuB,EAAE,KAAwB,EAAE,KAAY,EAAE,EAAE;IAC9F,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,IAA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AI,OAAO,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,cAAc,CAAC,yEAAyE,CAAC,CAAC;QACtG,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QAExB,eAAe;QACf,KAAK,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;AACH,CAAC,CAAC"}
@@ -35,7 +35,7 @@ These are the entity options:
35
35
 
36
36
  ### `description`
37
37
 
38
- Will appear as description in the graphql schema.
38
+ Will appear as description in the GraphQL schema.
39
39
 
40
40
  ### `plural`
41
41
 
@@ -43,7 +43,7 @@ Will appear as description in the graphql schema.
43
43
 
44
44
  ### `creatable`
45
45
 
46
- When `creatable` is `true`, the entity can be created using a dedicated graphql `create<ModelName>` mutation.
46
+ When `creatable` is `true`, the entity can be created using a dedicated GraphQL `create<ModelName>` mutation.
47
47
 
48
48
  For this to work, at least one entity field needs to be marked as `creatable`.
49
49
 
@@ -51,7 +51,7 @@ For this to work, at least one entity field needs to be marked as `creatable`.
51
51
 
52
52
  ### `updatable`
53
53
 
54
- When `updatable` is `true`, the entity can be created using a dedicated graphql `delete<ModelName>` mutation.
54
+ When `updatable` is `true`, the entity can be created using a dedicated GraphQL `delete<ModelName>` mutation.
55
55
 
56
56
  For this to work, at least one entity field needs to be marked as `updatable`.
57
57
 
@@ -61,15 +61,15 @@ If a field is updatable, a `<ModelName>Revisions` table is created (containing o
61
61
 
62
62
  ### `deletable`
63
63
 
64
- When `deletable` is `true`, the entity can be created using a dedicated graphql `delete<ModelName>` mutation.
64
+ When `deletable` is `true`, the entity can be created using a dedicated GraphQL `delete<ModelName>` mutation.
65
65
 
66
- This is a soft delete (the `deleted` field is set to `true`), and the entity can be restored with the graphql `restore<ModelName>` mutation.
66
+ This is a soft delete (the `deleted` field is set to `true`), and the entity can be restored with the GraphQL `restore<ModelName>` mutation.
67
67
 
68
68
  `deletable` also accepts an object to override properties of the implicitly generated `deleted`, `deletedBy` and `deletedAt` fields.
69
69
 
70
70
  ### `queriable`
71
71
 
72
- When `queriable` is `true` a graphql `Query` becomes available to fetch exactly one element by id.
72
+ When `queriable` is `true` a GraphQL `Query` becomes available to fetch exactly one element by id.
73
73
 
74
74
  For example, with
75
75
 
@@ -82,7 +82,7 @@ For example, with
82
82
  }
83
83
  ```
84
84
 
85
- the following graphql query becomes possible
85
+ the following GraphQL query becomes possible
86
86
 
87
87
  ```graphql
88
88
  query {
@@ -94,7 +94,7 @@ query {
94
94
 
95
95
  ### `listQueriable`
96
96
 
97
- When `listQueriable` is `true` a graphql `Query` becomes available to fetch a list of elements of this model.
97
+ When `listQueriable` is `true` a GraphQL `Query` becomes available to fetch a list of elements of this model.
98
98
 
99
99
  For example, with
100
100
 
@@ -107,7 +107,7 @@ For example, with
107
107
  }
108
108
  ```
109
109
 
110
- the following graphql query becomes possible
110
+ the following GraphQL query becomes possible
111
111
 
112
112
  ```graphql
113
113
  query {
@@ -123,7 +123,7 @@ The name of the field that ought to be used as display value, e.g. a `Post`'s `t
123
123
 
124
124
  ### `defaultOrderBy`
125
125
 
126
- An array of orders with the same structure as the `orderBy` parameters in graphql queries. The implicit default order by is `[{ createdAt: 'DESC }]`.
126
+ An array of orders with the same structure as the `orderBy` parameters in GraphQL queries. The implicit default order by is `[{ createdAt: 'DESC }]`.
127
127
 
128
128
  ### `fields`
129
129
 
@@ -131,7 +131,7 @@ An array of fields. See [fields](./fields)
131
131
 
132
132
  ## Scalars
133
133
 
134
- Used for graphql scalars, e.g.
134
+ Used for GraphQL scalars, e.g.
135
135
 
136
136
  ```ts
137
137
  {
@@ -85,11 +85,11 @@ For more details, see section on [kinds](#kinds) below.
85
85
 
86
86
  ### `type`
87
87
 
88
- This represents the graphql "return type", which can be a primitive or a separate model (depending on the [kind](#kinds)).
88
+ This represents the GraphQL "return type", which can be a primitive or a separate model (depending on the [kind](#kinds)).
89
89
 
90
90
  ### `description`
91
91
 
92
- Will appear as description in the graphql schema.
92
+ Will appear as description in the GraphQL schema.
93
93
 
94
94
  ### `list`
95
95
 
@@ -97,11 +97,11 @@ If `list` is `true` the result is an array.
97
97
 
98
98
  ### `nonNull`
99
99
 
100
- Will make the field required both in the graphql schema and in the database.
100
+ Will make the field required both in the GraphQL schema and in the database.
101
101
 
102
102
  ### `defaultValue`
103
103
 
104
- Will set this as default value in graphql mutations and in the database.
104
+ Will set this as default value in GraphQL mutations and in the database.
105
105
 
106
106
  ### `args`
107
107
 
@@ -309,7 +309,7 @@ Available postfixes are:
309
309
 
310
310
  ### `queriable`
311
311
 
312
- `true` by default. If explicitly set to `false`, the field won't be queriable via graphql.
312
+ `true` by default. If explicitly set to `false`, the field won't be queriable via GraphQL.
313
313
 
314
314
  Also accepts an object that defines a list of `roles` to restrict access to specific roles.
315
315
 
@@ -1,6 +1,6 @@
1
1
  # Code generation
2
2
 
3
- `graphql-magic` generates a lot of utility code for you based on the models, in particular typescript types.
3
+ `graphql-magic` generates a lot of utility code for you based on the models, in particular TypeScript types.
4
4
 
5
5
  This can be done directly with `npx gqm generate`.
6
6
 
@@ -10,20 +10,20 @@ During the first run, the tool applies the following changes to the repo:
10
10
  * Add local database connection variables to `.env` file.
11
11
  * Add generated folder to `.gitignore`
12
12
  * Generate `models.ts` file (if not present).
13
- * Generate a basic `get-me.ts` example graphql query.
13
+ * Generate a basic `get-me.ts` example GraphQL query.
14
14
  * Generate the `execute.ts` file for the execution
15
15
 
16
16
  With each application, it generates the following files in the configured "generated" folder:
17
17
 
18
- * `schema.graphql` - the schema of the api, for reference
18
+ * `schema.graphql` - the schema of the API, for reference
19
19
  * `models.json` - the final models array, including generated fields such as "id","createdBy"... for reference
20
- * `api/index.ts` - the server-side model typescipt types
21
- * `client/index.ts` - the client-side typescript types for the provided queries
20
+ * `api/index.ts` - the server-side model TypeScript types
21
+ * `client/index.ts` - the client-side TypeScript types for the provided queries
22
22
  * `client/mutations.ts` - standard mutation queries for all models
23
23
  * `db/index.ts` - types for data from/to the database
24
24
  * `db/knex.ts` - types to extend the `knex` query builder
25
25
 
26
- Whenever the models have been changed, it is necessary regenerate this code.
26
+ Whenever the models have been changed, it is necessary to regenerate this code.
27
27
  It is recommended to create a `package.json` script and to always generate code after install (or with `npm run generate`):
28
28
 
29
29
  ```
@@ -39,7 +39,7 @@ export const executeGraphql = async <T, V = undefined>(
39
39
  }
40
40
  ```
41
41
 
42
- This is where you can set up your graphql server with
42
+ This is where you can set up your GraphQL server with
43
43
 
44
44
  * user authentication (see the [Tutorial](./tutorial) for an example with auth0)
45
45
  * custom resolvers (see [Custom resolvers](#custom-resolvers))
@@ -47,8 +47,8 @@ This is where you can set up your graphql server with
47
47
 
48
48
  ## Graphql API
49
49
 
50
- If you only need to execute graphql on the server (e.g. on `next.js` server components or server actions), you don't need a graphql endpoint.
51
- If you need client side querying, use `executeGraphql` to create a graphql endpoint, e.g. in `src/app/api/graphql/route.ts`:
50
+ If you only need to execute GraphQL on the server (e.g. on `next.js` server components or server actions), you don't need a GraphQL endpoint.
51
+ If you need client side querying, use `executeGraphql` to create a GraphQL endpoint, e.g. in `src/app/api/graphql/route.ts`:
52
52
 
53
53
  ```ts
54
54
  export const POST = (req) => {
@@ -18,7 +18,7 @@ module.exports = {
18
18
 
19
19
  ### Server side
20
20
 
21
- On the server side, and with `next.js` server actions, a graphql api becomes unnecessary, and you can execute queries directly using `executeGraphql`:
21
+ On the server side, and with `next.js` server actions, a GraphQL API becomes unnecessary, and you can execute queries directly using `executeGraphql`:
22
22
 
23
23
  ```tsx
24
24
  import { GetMeQuery, GetPostsQuery } from "@/generated/client";
@@ -48,7 +48,7 @@ async function Posts({ me }: { me: GetMeQuery['me'] }) {
48
48
 
49
49
  ### Client side
50
50
 
51
- On the client, you'd need to set up a graphql endpoint and then query it like any other graphql api, such as with [`@apollo/client`](https://www.apollographql.com/docs/react/get-started).
51
+ On the client, you'd need to set up a GraphQL endpoint and then query it like any other GraphQL API, such as with [`@apollo/client`](https://www.apollographql.com/docs/react/get-started).
52
52
 
53
53
  ```tsx
54
54
  import { GetMeQuery, GetPostsQuery } from "@/generated/client";
@@ -148,4 +148,4 @@ async function CreatePost() {
148
148
  }
149
149
  ```
150
150
 
151
- Just like with queries, if is necessary to perform mutations on the client, use a graphql client instead of `executeGraphql`.
151
+ Just like with queries, if is necessary to perform mutations on the client, use a GraphQL client instead of `executeGraphql`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartive/graphql-magic",
3
- "version": "16.3.0",
3
+ "version": "16.3.2",
4
4
  "description": "",
5
5
  "source": "src/index.ts",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "generate:setup-migration": "npm run build:bin && npx gqm generate-migration setup 20230912185644",
20
20
  "lint": "eslint src",
21
21
  "lint:fix": "eslint src --fix",
22
- "deps": "docker-compose up",
22
+ "deps": "docker compose up",
23
23
  "test": "npm run lint && npm run test:all && npm run build",
24
24
  "test:all": "jest tests --no-cache --no-watchman --setupFiles dotenv/config",
25
25
  "test:unit": "jest tests/unit --no-cache --no-watchman --setupFiles dotenv/config",
@@ -50,7 +50,7 @@
50
50
  "@graphql-codegen/typescript-compatibility": "^2.1.5",
51
51
  "@graphql-codegen/typescript-operations": "^4.0.1",
52
52
  "@graphql-codegen/typescript-resolvers": "^4.0.1",
53
- "code-block-writer": "^12.0.0",
53
+ "code-block-writer": "^13.0.0",
54
54
  "commander": "^11.0.0",
55
55
  "dayjs": "^1.11.10",
56
56
  "dotenv": "^16.3.1",
@@ -63,7 +63,7 @@
63
63
  "pg": "^8.11.3",
64
64
  "simple-git": "^3.21.0",
65
65
  "ts-morph": "^19.0.0",
66
- "uuid": "^9.0.0"
66
+ "uuid": "^11.0.0"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "knex": "^3.0.1"
@@ -75,16 +75,16 @@
75
75
  "@types/lodash": "4.17.15",
76
76
  "@types/luxon": "3.4.2",
77
77
  "@types/pg": "8.11.11",
78
- "@types/uuid": "9.0.8",
78
+ "@types/uuid": "10.0.0",
79
79
  "create-ts-index": "1.14.0",
80
80
  "del-cli": "5.1.0",
81
- "esbuild": "0.24.2",
81
+ "esbuild": "0.25.0",
82
82
  "eslint": "8.57.1",
83
83
  "graphql-request": "6.1.0",
84
84
  "jest": "29.7.0",
85
85
  "mock-knex": "0.4.13",
86
86
  "prettier": "2.8.8",
87
- "ts-jest": "29.2.5",
87
+ "ts-jest": "29.2.6",
88
88
  "ts-node": "10.9.2",
89
89
  "typescript": "5.5.4"
90
90
  }
@@ -30,21 +30,6 @@ export const applyFilters = (node: FieldResolverNode, query: Knex.QueryBuilder,
30
30
  normalizedArguments.orderBy = [{ createdAt: 'DESC' }];
31
31
  }
32
32
  }
33
- if (node.model.deletable) {
34
- if (!normalizedArguments.where) {
35
- normalizedArguments.where = {};
36
- }
37
- if (
38
- normalizedArguments.where.deleted &&
39
- (!Array.isArray(normalizedArguments.where.deleted) || normalizedArguments.where.deleted.some((v) => v))
40
- ) {
41
- if (node.ctx.user?.role !== 'ADMIN') {
42
- throw new ForbiddenError('You cannot access deleted entries.');
43
- }
44
- } else {
45
- normalizedArguments.where.deleted = false;
46
- }
47
- }
48
33
  const { limit, offset, orderBy, where, search } = normalizedArguments;
49
34
 
50
35
  if (limit) {
@@ -67,18 +52,33 @@ export const applyFilters = (node: FieldResolverNode, query: Knex.QueryBuilder,
67
52
  });
68
53
  }
69
54
 
70
- if (where) {
71
- const ops: QueryBuilderOps = [];
72
- applyWhere(node, where, ops, joins);
73
- void apply(query, ops);
74
- }
55
+ const ops: QueryBuilderOps = [];
56
+ applyWhere(node, where, ops, joins);
57
+ void apply(query, ops);
75
58
 
76
59
  if (search) {
77
60
  void applySearch(node, search, query);
78
61
  }
79
62
  };
80
63
 
81
- const applyWhere = (node: WhereNode, where: Where, ops: QueryBuilderOps, joins: Joins) => {
64
+ const applyWhere = (node: WhereNode, where: Where | undefined, ops: QueryBuilderOps, joins: Joins) => {
65
+ if (node.model.deletable) {
66
+ if (!where) {
67
+ where = {};
68
+ }
69
+ if (where.deleted && (!Array.isArray(where.deleted) || where.deleted.some((v) => v))) {
70
+ if (node.ctx.user?.role !== 'ADMIN') {
71
+ throw new ForbiddenError('You cannot access deleted entries.');
72
+ }
73
+ } else {
74
+ where.deleted = false;
75
+ }
76
+ }
77
+
78
+ if (!where) {
79
+ return;
80
+ }
81
+
82
82
  const aliases = node.ctx.aliases;
83
83
 
84
84
  for (const key of Object.keys(where)) {