@smartive/graphql-magic 11.0.0 → 11.1.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.
package/CHANGELOG.md CHANGED
@@ -1 +1,6 @@
1
- # [11.0.0](https://github.com/smartive/graphql-magic/compare/v10.0.0...v11.0.0) (2023-11-09)
1
+ # [11.1.0](https://github.com/smartive/graphql-magic/compare/v11.0.0...v11.1.0) (2023-11-16)
2
+
3
+
4
+ ### Features
5
+
6
+ * Update knex ([e7821f6](https://github.com/smartive/graphql-magic/commit/e7821f6d11c4ce92b39f06a890a991ddf7ba3523))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartive/graphql-magic",
3
- "version": "11.0.0",
3
+ "version": "11.1.0",
4
4
  "description": "",
5
5
  "source": "src/index.ts",
6
6
  "type": "module",
@@ -55,8 +55,8 @@
55
55
  "dotenv": "^16.3.1",
56
56
  "graphql": "^15.8.0",
57
57
  "inflection": "^2.0.1",
58
- "knex": "^2.4.2",
59
- "knex-schema-inspector": "^3.0.1",
58
+ "knex": "^3.0.1",
59
+ "knex-schema-inspector": "^3.1.0",
60
60
  "lodash": "^4.17.21",
61
61
  "luxon": "^3.3.0",
62
62
  "ts-morph": "^19.0.0",
@@ -41,46 +41,3 @@ exports[`resolvers are generated correctly 1`] = `
41
41
  },
42
42
  }
43
43
  `;
44
-
45
- exports[`resolvers resolve lists, many-to-one and one-to-many queries 1`] = `
46
- {
47
- "data": {
48
- "manyObjects": [
49
- {
50
- "another": {
51
- "id": "bar",
52
- "manyObjects": [
53
- {
54
- "field": "foo",
55
- "id": "foo",
56
- },
57
- ],
58
- },
59
- "field": "foo",
60
- "id": "foo",
61
- },
62
- ],
63
- },
64
- }
65
- `;
66
-
67
- exports[`resolvers resolve lists, many-to-one and one-to-many queries: query 1`] = `"select * from "User" where "id" = $1 limit $2"`;
68
-
69
- exports[`resolvers resolve lists, many-to-one and one-to-many queries: query 2`] = `"select "SO"."id" as "SO__ID", "SO"."id" as "SO__id", "SO"."field" as "SO__field", "SO__a"."id" as "SO__a__ID", "SO__a"."id" as "SO__a__id" from "SomeObject" as "SO" left join "AnotherObject" as "SO__W__a" on "SO"."anotherId" = "SO__W__a"."id" left join "AnotherObject" as "SO__a" on "SO"."anotherId" = "SO__a"."id" where "SO__W__a"."id" in ($1) and "SO"."deleted" = $2 order by "SO"."xyz" DESC"`;
70
-
71
- exports[`resolvers resolve lists, many-to-one and one-to-many queries: query 3`] = `"select "SO__a__mO"."id" as "SO__a__mO__ID", "SO__a__mO"."id" as "SO__a__mO__id", "SO__a__mO"."field" as "SO__a__mO__field", "SO__a__mO"."anotherId" as "SO__a__mO__anotherId" from "SomeObject" as "SO__a__mO" where "SO__a__mO"."id" in ($1) and "SO__a__mO"."deleted" = $2 and "SO__a__mO"."anotherId" = $3 order by "SO__a__mO"."createdAt" DESC"`;
72
-
73
- exports[`resolvers resolve single query 1`] = `
74
- {
75
- "data": {
76
- "someObject": {
77
- "field": "foo",
78
- "id": "foo",
79
- },
80
- },
81
- }
82
- `;
83
-
84
- exports[`resolvers resolve single query: query 1`] = `"select * from "User" where "id" = $1 limit $2"`;
85
-
86
- exports[`resolvers resolve single query: query 2`] = `"select "SO"."id" as "SO__ID", "SO"."id" as "SO__id", "SO"."field" as "SO__field" from "SomeObject" as "SO" where "SO"."id" = $1 and "SO"."deleted" = $2 order by "SO"."createdAt" DESC limit $3"`;
@@ -1,114 +1,8 @@
1
- import knex from 'knex';
2
- import { DateTime } from 'luxon';
3
- import { execute } from '../../src';
4
- import { gql } from '../../src/client/gql';
5
1
  import { getResolvers } from '../../src/resolvers';
6
- import { ADMIN_ID } from '../utils/database/seed';
7
- import { models, permissions } from '../utils/models';
8
-
9
- const test = async (operationName: string, query: string, variables: object, responses: unknown[]) => {
10
- const knexInstance = knex({
11
- client: 'postgresql',
12
- });
13
-
14
- // eslint-disable-next-line @typescript-eslint/no-var-requires
15
- const mockKnex = require('mock-knex');
16
- mockKnex.mock(knexInstance);
17
- const tracker = mockKnex.getTracker();
18
-
19
- tracker.install();
20
- tracker.on('query', function someFunction(query, step) {
21
- expect(query.sql).toMatchSnapshot('query');
22
- query.response(responses[step - 1]);
23
- });
24
-
25
- const user = await knexInstance('User').where({ id: ADMIN_ID }).first();
26
- const result = await execute({
27
- req: null as any,
28
- knex: knexInstance,
29
- locale: 'en',
30
- locales: ['en'],
31
- user,
32
- models,
33
- permissions,
34
- now: DateTime.fromISO('2020-01-01T00:00:00.000Z'),
35
- body: { operationName, query, variables },
36
- });
37
-
38
- expect(result).toMatchSnapshot();
39
-
40
- tracker.uninstall();
41
- };
2
+ import { models } from '../utils/models';
42
3
 
43
4
  describe('resolvers', () => {
44
5
  it('are generated correctly', () => {
45
6
  expect(getResolvers(models)).toMatchSnapshot();
46
7
  });
47
-
48
- it('resolve lists, many-to-one and one-to-many queries', async () => {
49
- await test(
50
- 'AnotherQuery',
51
- gql`
52
- query AnotherQuery {
53
- manyObjects(where: { another: { id: "bar" } }, orderBy: [{ xyz: DESC }]) {
54
- id
55
- field
56
- another {
57
- id
58
- manyObjects(where: { id: "foo" }) {
59
- id
60
- field
61
- }
62
- }
63
- }
64
- }
65
- `,
66
- {},
67
- [
68
- { id: 1, role: 'ADMIN' },
69
- [
70
- {
71
- SO__ID: 'foo',
72
- SO__id: 'foo',
73
- SO__field: 'foo',
74
- SO__a__ID: 'bar',
75
- SO__a__id: 'bar',
76
- },
77
- ],
78
- [
79
- {
80
- SO__a__mO__ID: 'foo',
81
- SO__a__mO__id: 'foo',
82
- SO__a__mO__field: 'foo',
83
- SO__a__mO__anotherId: 'bar',
84
- },
85
- ],
86
- ]
87
- );
88
- });
89
-
90
- it('resolve single query', async () => {
91
- await test(
92
- 'YetAnotherQuery',
93
- gql`
94
- query YetAnotherQuery {
95
- someObject(where: { id: "foo" }) {
96
- id
97
- field
98
- }
99
- }
100
- `,
101
- {},
102
- [
103
- { id: 1, role: 'ADMIN' },
104
- [
105
- {
106
- SO__ID: 'foo',
107
- SO__id: 'foo',
108
- SO__field: 'foo',
109
- },
110
- ],
111
- ]
112
- );
113
- });
114
8
  });