@subsquid/openreader 4.6.0 → 5.0.0-beta.62d187

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 (131) hide show
  1. package/lib/context.d.ts +2 -2
  2. package/lib/context.d.ts.map +1 -1
  3. package/lib/db.d.ts +3 -3
  4. package/lib/db.d.ts.map +1 -1
  5. package/lib/db.js +2 -2
  6. package/lib/db.js.map +1 -1
  7. package/lib/dialect/common.d.ts +19 -0
  8. package/lib/dialect/common.d.ts.map +1 -0
  9. package/lib/dialect/common.js +42 -0
  10. package/lib/dialect/common.js.map +1 -0
  11. package/lib/dialect/index.d.ts +6 -0
  12. package/lib/dialect/index.d.ts.map +1 -0
  13. package/lib/dialect/index.js +49 -0
  14. package/lib/dialect/index.js.map +1 -0
  15. package/lib/{opencrud → dialect/opencrud}/orderBy.d.ts +2 -3
  16. package/lib/dialect/opencrud/orderBy.d.ts.map +1 -0
  17. package/lib/{opencrud → dialect/opencrud}/orderBy.js +4 -21
  18. package/lib/dialect/opencrud/orderBy.js.map +1 -0
  19. package/lib/{opencrud → dialect/opencrud}/schema.d.ts +2 -6
  20. package/lib/dialect/opencrud/schema.d.ts.map +1 -0
  21. package/lib/{opencrud → dialect/opencrud}/schema.js +21 -34
  22. package/lib/dialect/opencrud/schema.js.map +1 -0
  23. package/lib/{opencrud → dialect/opencrud}/tree.d.ts +3 -3
  24. package/lib/dialect/opencrud/tree.d.ts.map +1 -0
  25. package/lib/{opencrud → dialect/opencrud}/tree.js +3 -3
  26. package/lib/dialect/opencrud/tree.js.map +1 -0
  27. package/lib/{opencrud → dialect/opencrud}/where.d.ts +1 -1
  28. package/lib/dialect/opencrud/where.d.ts.map +1 -0
  29. package/lib/{opencrud → dialect/opencrud}/where.js +4 -13
  30. package/lib/dialect/opencrud/where.js.map +1 -0
  31. package/lib/dialect/thegraph/locale.d.ts +2 -0
  32. package/lib/dialect/thegraph/locale.d.ts.map +1 -0
  33. package/lib/dialect/thegraph/locale.js +49 -0
  34. package/lib/dialect/thegraph/locale.js.map +1 -0
  35. package/lib/dialect/thegraph/orderBy.d.ts +11 -0
  36. package/lib/dialect/thegraph/orderBy.d.ts.map +1 -0
  37. package/lib/dialect/thegraph/orderBy.js +71 -0
  38. package/lib/dialect/thegraph/orderBy.js.map +1 -0
  39. package/lib/dialect/thegraph/schema.d.ts +25 -0
  40. package/lib/dialect/thegraph/schema.d.ts.map +1 -0
  41. package/lib/dialect/thegraph/schema.js +429 -0
  42. package/lib/dialect/thegraph/schema.js.map +1 -0
  43. package/lib/dialect/thegraph/tree.d.ts +10 -0
  44. package/lib/dialect/thegraph/tree.d.ts.map +1 -0
  45. package/lib/dialect/thegraph/tree.js +148 -0
  46. package/lib/dialect/thegraph/tree.js.map +1 -0
  47. package/lib/dialect/thegraph/where.d.ts +9 -0
  48. package/lib/dialect/thegraph/where.d.ts.map +1 -0
  49. package/lib/dialect/thegraph/where.js +188 -0
  50. package/lib/dialect/thegraph/where.js.map +1 -0
  51. package/lib/ir/args.d.ts +1 -1
  52. package/lib/ir/args.d.ts.map +1 -1
  53. package/lib/main.js +1 -1
  54. package/lib/main.js.map +1 -1
  55. package/lib/model.d.ts +2 -0
  56. package/lib/model.d.ts.map +1 -1
  57. package/lib/model.schema.d.ts.map +1 -1
  58. package/lib/model.schema.js +31 -2
  59. package/lib/model.schema.js.map +1 -1
  60. package/lib/server.d.ts +3 -1
  61. package/lib/server.d.ts.map +1 -1
  62. package/lib/server.js +7 -6
  63. package/lib/server.js.map +1 -1
  64. package/lib/sql/cursor.d.ts +2 -2
  65. package/lib/sql/cursor.d.ts.map +1 -1
  66. package/lib/sql/cursor.js +2 -2
  67. package/lib/sql/cursor.js.map +1 -1
  68. package/lib/sql/printer.d.ts +3 -3
  69. package/lib/sql/printer.d.ts.map +1 -1
  70. package/lib/sql/printer.js +17 -15
  71. package/lib/sql/printer.js.map +1 -1
  72. package/lib/sql/query.d.ts +5 -5
  73. package/lib/sql/query.d.ts.map +1 -1
  74. package/lib/sql/query.js.map +1 -1
  75. package/lib/sql/util.d.ts +2 -2
  76. package/lib/sql/util.d.ts.map +1 -1
  77. package/lib/sql/util.js.map +1 -1
  78. package/lib/test/basic.test.js +471 -229
  79. package/lib/test/basic.test.js.map +1 -1
  80. package/lib/test/isNull.test.js +87 -36
  81. package/lib/test/isNull.test.js.map +1 -1
  82. package/lib/test/limits.test.js +206 -94
  83. package/lib/test/limits.test.js.map +1 -1
  84. package/lib/test/lookup.test.js +184 -81
  85. package/lib/test/lookup.test.js.map +1 -1
  86. package/lib/test/setup.js +2 -2
  87. package/lib/test/setup.js.map +1 -1
  88. package/lib/test/where.test.js +216 -99
  89. package/lib/test/where.test.js.map +1 -1
  90. package/package.json +5 -3
  91. package/src/context.ts +2 -2
  92. package/src/db.ts +4 -2
  93. package/src/dialect/common.ts +49 -0
  94. package/src/dialect/index.ts +20 -0
  95. package/src/{opencrud → dialect/opencrud}/orderBy.ts +4 -21
  96. package/src/{opencrud → dialect/opencrud}/schema.ts +30 -55
  97. package/src/{opencrud → dialect/opencrud}/tree.ts +6 -7
  98. package/src/{opencrud → dialect/opencrud}/where.ts +4 -16
  99. package/src/dialect/thegraph/locale.ts +284 -0
  100. package/src/dialect/thegraph/orderBy.ts +75 -0
  101. package/src/dialect/thegraph/schema.ts +484 -0
  102. package/src/dialect/thegraph/tree.ts +162 -0
  103. package/src/dialect/thegraph/where.ts +184 -0
  104. package/src/ir/args.ts +2 -0
  105. package/src/main.ts +3 -3
  106. package/src/model.schema.ts +37 -4
  107. package/src/model.ts +2 -0
  108. package/src/server.ts +21 -19
  109. package/src/sql/cursor.ts +4 -4
  110. package/src/sql/printer.ts +22 -18
  111. package/src/sql/query.ts +5 -5
  112. package/src/sql/util.ts +2 -2
  113. package/src/test/basic.test.ts +570 -282
  114. package/src/test/isNull.test.ts +95 -38
  115. package/src/test/limits.test.ts +212 -91
  116. package/src/test/lookup.test.ts +190 -83
  117. package/src/test/setup.ts +2 -2
  118. package/src/test/where.test.ts +235 -108
  119. package/lib/dialect.d.ts +0 -2
  120. package/lib/dialect.d.ts.map +0 -1
  121. package/lib/dialect.js +0 -3
  122. package/lib/dialect.js.map +0 -1
  123. package/lib/opencrud/orderBy.d.ts.map +0 -1
  124. package/lib/opencrud/orderBy.js.map +0 -1
  125. package/lib/opencrud/schema.d.ts.map +0 -1
  126. package/lib/opencrud/schema.js.map +0 -1
  127. package/lib/opencrud/tree.d.ts.map +0 -1
  128. package/lib/opencrud/tree.js.map +0 -1
  129. package/lib/opencrud/where.d.ts.map +0 -1
  130. package/lib/opencrud/where.js.map +0 -1
  131. package/src/dialect.ts +0 -2
@@ -1,3 +1,4 @@
1
+ import {Dialect} from '../dialect'
1
2
  import {isCockroach, useDatabase, useServer} from "./setup"
2
3
 
3
4
  describe('lookup test', function () {
@@ -13,105 +14,211 @@ describe('lookup test', function () {
13
14
  `insert into issue_cancellation (id, issue_id, height) values ('3', '3', 10)`,
14
15
  ])
15
16
 
16
- const client = useServer(`
17
- type Issue @entity {
18
- id: ID!
19
- payment: IssuePayment @derivedFrom(field: "issue")
20
- cancellation: IssueCancellation @derivedFrom(field: "issue")
21
- }
22
-
23
- type IssuePayment @entity {
24
- id: ID!
25
- issue: Issue! @unique
26
- amount: Int!
27
- }
28
-
29
- type IssueCancellation @entity {
30
- id: ID!
31
- issue: Issue! @unique
32
- height: Int!
33
- }
34
- `)
35
-
36
- it('fetches correctly', function () {
37
- return client.test(`
38
- query {
39
- issues(orderBy: [id_ASC]) {
40
- id
41
- payment {
42
- amount
43
- }
44
- cancellation {
45
- height
46
- issue {
47
- cancellation {
48
- id
17
+ describe('opencrud', function () {
18
+ const client = useServer(`
19
+ type Issue @entity {
20
+ id: ID!
21
+ payment: IssuePayment @derivedFrom(field: "issue")
22
+ cancellation: IssueCancellation @derivedFrom(field: "issue")
23
+ }
24
+
25
+ type IssuePayment @entity {
26
+ id: ID!
27
+ issue: Issue! @unique
28
+ amount: Int!
29
+ }
30
+
31
+ type IssueCancellation @entity {
32
+ id: ID!
33
+ issue: Issue! @unique
34
+ height: Int!
35
+ }
36
+ `)
37
+
38
+ it('fetches correctly', function () {
39
+ return client.test(`
40
+ query {
41
+ issues(orderBy: [id_ASC]) {
42
+ id
43
+ payment {
44
+ amount
45
+ }
46
+ cancellation {
47
+ height
48
+ issue {
49
+ cancellation {
50
+ id
51
+ }
49
52
  }
50
53
  }
51
54
  }
52
55
  }
53
- }
54
- `, {
55
- issues: [
56
- {
57
- id: '1',
58
- payment: {amount: 2},
59
- cancellation: null
60
- },
61
- {
62
- id: '2',
63
- payment: {amount: 1},
64
- cancellation: null
65
- },
66
- {
67
- id: '3',
68
- payment: null,
69
- cancellation: {
70
- height: 10,
71
- issue: {
72
- cancellation: {
73
- id: '3'
56
+ `, {
57
+ issues: [
58
+ {
59
+ id: '1',
60
+ payment: {amount: 2},
61
+ cancellation: null
62
+ },
63
+ {
64
+ id: '2',
65
+ payment: {amount: 1},
66
+ cancellation: null
67
+ },
68
+ {
69
+ id: '3',
70
+ payment: null,
71
+ cancellation: {
72
+ height: 10,
73
+ issue: {
74
+ cancellation: {
75
+ id: '3'
76
+ }
74
77
  }
75
78
  }
76
79
  }
80
+ ]
81
+ })
82
+ })
83
+
84
+ it('supports sorting on lookup fields', function () {
85
+ return client.test(`
86
+ query {
87
+ issues(orderBy: [payment_amount_ASC]) {
88
+ id
89
+ }
77
90
  }
78
- ]
91
+ `, {
92
+ issues: isCockroach()
93
+ ? [
94
+ {id: '3'},
95
+ {id: '2'},
96
+ {id: '1'}
97
+ ]
98
+ : [
99
+ {id: '2'},
100
+ {id: '1'},
101
+ {id: '3'}
102
+ ]
103
+ })
79
104
  })
80
- })
81
-
82
- it('supports sorting on lookup fields', function () {
83
- return client.test(`
84
- query {
85
- issues(orderBy: [payment_amount_ASC]) {
86
- id
105
+
106
+ it('supports where conditions', function () {
107
+ return client.test(`
108
+ query {
109
+ issues(where: {payment: {amount_gt: 1}}) {
110
+ id
111
+ }
87
112
  }
88
- }
89
- `, {
90
- issues: isCockroach()
91
- ? [
92
- {id: '3'},
93
- {id: '2'},
113
+ `, {
114
+ issues: [
94
115
  {id: '1'}
95
116
  ]
96
- : [
97
- {id: '2'},
98
- {id: '1'},
99
- {id: '3'}
100
- ]
117
+ })
101
118
  })
102
119
  })
103
120
 
104
- it('supports where conditions', function () {
105
- return client.test(`
106
- query {
107
- issues(where: {payment: {amount_gt: 1}}) {
108
- id
109
- }
121
+ describe('thegraph', function () {
122
+ const client = useServer(`
123
+ type Issue @entity {
124
+ id: ID!
125
+ payment: IssuePayment @derivedFrom(field: "issue")
126
+ cancellation: IssueCancellation @derivedFrom(field: "issue")
127
+ }
128
+
129
+ type IssuePayment @entity {
130
+ id: ID!
131
+ issue: Issue! @unique
132
+ amount: Int!
133
+ }
134
+
135
+ type IssueCancellation @entity {
136
+ id: ID!
137
+ issue: Issue! @unique
138
+ height: Int!
110
139
  }
111
- `, {
112
- issues: [
113
- {id: '1'}
114
- ]
140
+ `, {dialect: Dialect.TheGraph})
141
+
142
+ it('fetches correctly', function () {
143
+ return client.test(`
144
+ query {
145
+ issues(orderBy: id, orderDirection: asc) {
146
+ id
147
+ payment {
148
+ amount
149
+ }
150
+ cancellation {
151
+ height
152
+ issue {
153
+ cancellation {
154
+ id
155
+ }
156
+ }
157
+ }
158
+ }
159
+ }
160
+ `, {
161
+ issues: [
162
+ {
163
+ id: '1',
164
+ payment: {amount: 2},
165
+ cancellation: null
166
+ },
167
+ {
168
+ id: '2',
169
+ payment: {amount: 1},
170
+ cancellation: null
171
+ },
172
+ {
173
+ id: '3',
174
+ payment: null,
175
+ cancellation: {
176
+ height: 10,
177
+ issue: {
178
+ cancellation: {
179
+ id: '3'
180
+ }
181
+ }
182
+ }
183
+ }
184
+ ]
185
+ })
186
+ })
187
+
188
+ it('supports sorting on lookup fields', function () {
189
+ return client.test(`
190
+ query {
191
+ issues(orderBy: payment__amount, orderDirection: asc) {
192
+ id
193
+ }
194
+ }
195
+ `, {
196
+ issues: isCockroach()
197
+ ? [
198
+ {id: '3'},
199
+ {id: '2'},
200
+ {id: '1'}
201
+ ]
202
+ : [
203
+ {id: '2'},
204
+ {id: '1'},
205
+ {id: '3'}
206
+ ]
207
+ })
208
+ })
209
+
210
+ it('supports where conditions', function () {
211
+ return client.test(`
212
+ query {
213
+ issues(where: {payment_: {amount_gt: 1}}) {
214
+ id
215
+ }
216
+ }
217
+ `, {
218
+ issues: [
219
+ {id: '1'}
220
+ ]
221
+ })
115
222
  })
116
223
  })
117
224
  })
package/src/test/setup.ts CHANGED
@@ -69,12 +69,12 @@ export function useServer(schema: string, options?: Partial<ServerOptions>): Cli
69
69
  connection: db,
70
70
  model: buildModel(buildSchema(parse(schema))),
71
71
  port: 0,
72
- dialect: isCockroach() ? 'cockroach' : 'postgres',
72
+ dbType: isCockroach() ? 'cockroach' : 'postgres',
73
73
  subscriptions: true,
74
74
  subscriptionPollInterval: 500,
75
75
  maxRootFields: 10,
76
76
  // log: createLogger('sqd:openreader'),
77
- ...options
77
+ ...options,
78
78
  })
79
79
  client.endpoint = `http://localhost:${info.port}/graphql`
80
80
  })
@@ -1,3 +1,4 @@
1
+ import {Dialect} from '../dialect'
1
2
  import {useDatabase, useServer} from "./setup"
2
3
 
3
4
  describe('AND, OR on entity filters', function () {
@@ -11,125 +12,251 @@ describe('AND, OR on entity filters', function () {
11
12
  `insert into item (id, a, b) values ('6', 5, 6)`,
12
13
  ])
13
14
 
14
- const client = useServer(`
15
- type Item @entity {
16
- id: ID!
17
- a: Int
18
- b: Int
19
- }
20
- `)
21
-
22
- it('{c, and: {c}}', function () {
23
- return client.test(`
24
- query {
25
- items(where: {a_eq: 1, AND: {b_eq: 1}} orderBy: id_ASC) { id }
15
+ describe('opencrud', function() {
16
+ const client = useServer(`
17
+ type Item @entity {
18
+ id: ID!
19
+ a: Int
20
+ b: Int
26
21
  }
27
- `, {
28
- items: [
29
- {id: '1'}
30
- ]
22
+ `)
23
+
24
+ it('{c, and: {c}}', function () {
25
+ return client.test(`
26
+ query {
27
+ items(where: {a_eq: 1, AND: {b_eq: 1}} orderBy: id_ASC) { id }
28
+ }
29
+ `, {
30
+ items: [
31
+ {id: '1'}
32
+ ]
33
+ })
31
34
  })
32
- })
33
-
34
- it('{and: {and: {c}, c}}', function () {
35
- return client.test(`
36
- query {
37
- items(where: {AND: {b_eq: 2, AND: {a_eq: 3}}} orderBy: id_ASC) { id }
38
- }
39
- `, {
40
- items: [
41
- {id: '3'}
42
- ]
35
+
36
+ it('{and: {and: {c}, c}}', function () {
37
+ return client.test(`
38
+ query {
39
+ items(where: {AND: {b_eq: 2, AND: {a_eq: 3}}} orderBy: id_ASC) { id }
40
+ }
41
+ `, {
42
+ items: [
43
+ {id: '3'}
44
+ ]
45
+ })
43
46
  })
44
- })
45
-
46
- it('{and: [{c}, {c}]}', function () {
47
- return client.test(`
48
- query {
49
- items(where: {AND: [{a_eq: 2}, {b_eq: 2}]} orderBy: id_ASC) { id }
50
- }
51
- `, {
52
- items: [
53
- {id: '2'}
54
- ]
47
+
48
+ it('{and: [{c}, {c}]}', function () {
49
+ return client.test(`
50
+ query {
51
+ items(where: {AND: [{a_eq: 2}, {b_eq: 2}]} orderBy: id_ASC) { id }
52
+ }
53
+ `, {
54
+ items: [
55
+ {id: '2'}
56
+ ]
57
+ })
55
58
  })
56
- })
57
-
58
- it('{c, {or: {c}}}', function () {
59
- return client.test(`
60
- query {
61
- items(where: {a_eq: 1, OR: {a_eq: 2}} orderBy: id_ASC) { id }
62
- }
63
- `, {
64
- items: [
65
- {id: '1'},
66
- {id: '2'}
67
- ]
59
+
60
+ it('{c, {or: {c}}}', function () {
61
+ return client.test(`
62
+ query {
63
+ items(where: {a_eq: 1, OR: {a_eq: 2}} orderBy: id_ASC) { id }
64
+ }
65
+ `, {
66
+ items: [
67
+ {id: '1'},
68
+ {id: '2'}
69
+ ]
70
+ })
68
71
  })
69
- })
70
-
71
- it('{or: [{c}, {c}]}', function () {
72
- return client.test(`
73
- query {
74
- items(where: {OR: [{a_eq: 2}, {a_eq: 3}]} orderBy: id_ASC) { id }
75
- }
76
- `, {
77
- items: [
78
- {id: '2'},
79
- {id: '3'}
80
- ]
72
+
73
+ it('{or: [{c}, {c}]}', function () {
74
+ return client.test(`
75
+ query {
76
+ items(where: {OR: [{a_eq: 2}, {a_eq: 3}]} orderBy: id_ASC) { id }
77
+ }
78
+ `, {
79
+ items: [
80
+ {id: '2'},
81
+ {id: '3'}
82
+ ]
83
+ })
81
84
  })
82
- })
83
-
84
- it('{or: {or: {c}, c}}', function () {
85
- return client.test(`
86
- query {
87
- items(where: {OR: {a_eq: 1, OR: {b_eq: 2}}} orderBy: id_ASC) { id }
88
- }
89
- `, {
90
- items: [
91
- {id: '1'},
92
- {id: '2'},
93
- {id: '3'}
94
- ]
85
+
86
+ it('{or: {or: {c}, c}}', function () {
87
+ return client.test(`
88
+ query {
89
+ items(where: {OR: {a_eq: 1, OR: {b_eq: 2}}} orderBy: id_ASC) { id }
90
+ }
91
+ `, {
92
+ items: [
93
+ {id: '1'},
94
+ {id: '2'},
95
+ {id: '3'}
96
+ ]
97
+ })
95
98
  })
96
- })
97
-
98
- it('{and: [{or: {c}, c}, {or: {c}, c}]}', function () {
99
- return client.test(`
100
- query {
101
- items(where: {AND: [{OR: {a_eq: 5}, a_eq: 4}, {OR: {b_eq: 2}, b_eq: 4}]} orderBy: id_ASC) { id }
102
- }
103
- `, {
104
- items: [
105
- {id: '4'},
106
- {id: '5'}
107
- ]
99
+
100
+ it('{and: [{or: {c}, c}, {or: {c}, c}]}', function () {
101
+ return client.test(`
102
+ query {
103
+ items(where: {AND: [{OR: {a_eq: 5}, a_eq: 4}, {OR: {b_eq: 2}, b_eq: 4}]} orderBy: id_ASC) { id }
104
+ }
105
+ `, {
106
+ items: [
107
+ {id: '4'},
108
+ {id: '5'}
109
+ ]
110
+ })
108
111
  })
109
- })
110
-
111
- it('{c, and: {c}, or: {c}}', function () {
112
- return client.test(`
113
- query {
114
- items(where: { a_eq: 4, AND: {b_eq: 4}, OR: {b_eq: 6} } orderBy: id_ASC) { id }
115
- }
116
- `, {
117
- items: [
118
- {id: '4'},
119
- {id: '6'}
120
- ]
112
+
113
+ it('{c, and: {c}, or: {c}}', function () {
114
+ return client.test(`
115
+ query {
116
+ items(where: { a_eq: 4, AND: {b_eq: 4}, OR: {b_eq: 6} } orderBy: id_ASC) { id }
117
+ }
118
+ `, {
119
+ items: [
120
+ {id: '4'},
121
+ {id: '6'}
122
+ ]
123
+ })
124
+ })
125
+
126
+ it('handles empty wheres', function () {
127
+ return client.test(`
128
+ query {
129
+ items(where: { a_eq: 4, AND: { OR: {}, AND: {} }, OR: { OR: {AND: {} } } } orderBy: id_ASC) { id }
130
+ }
131
+ `, {
132
+ items: [
133
+ {id: '4'}
134
+ ]
135
+ })
121
136
  })
122
137
  })
123
-
124
- it('handles empty wheres', function () {
125
- return client.test(`
126
- query {
127
- items(where: { a_eq: 4, AND: { OR: {}, AND: {} }, OR: { OR: {AND: {} } } } orderBy: id_ASC) { id }
138
+
139
+ describe('thegraph', function() {
140
+ const client = useServer(`
141
+ type Item @entity {
142
+ id: ID!
143
+ a: Int
144
+ b: Int
128
145
  }
129
- `, {
130
- items: [
131
- {id: '4'}
132
- ]
146
+ `, {dialect: Dialect.TheGraph})
147
+
148
+ it('{c, and: {c}}', function () {
149
+ return client.test(`
150
+ query {
151
+ items(where: {a: 1, and: {b: 1}}, orderBy: id, orderDirection: asc) { id }
152
+ }
153
+ `, {
154
+ items: [
155
+ {id: '1'}
156
+ ]
157
+ })
158
+ })
159
+
160
+ it('{and: {and: {c}, c}}', function () {
161
+ return client.test(`
162
+ query {
163
+ items(where: {and: {b: 2, and: {a: 3}}}, orderBy: id, orderDirection: asc) { id }
164
+ }
165
+ `, {
166
+ items: [
167
+ {id: '3'}
168
+ ]
169
+ })
170
+ })
171
+
172
+ it('{and: [{c}, {c}]}', function () {
173
+ return client.test(`
174
+ query {
175
+ items(where: {and: [{a: 2}, {b: 2}]}, orderBy: id, orderDirection: asc) { id }
176
+ }
177
+ `, {
178
+ items: [
179
+ {id: '2'}
180
+ ]
181
+ })
182
+ })
183
+
184
+ it('{c, {or: {c}}}', function () {
185
+ return client.test(`
186
+ query {
187
+ items(where: {a: 1, or: {a: 2}}, orderBy: id, orderDirection: asc) { id }
188
+ }
189
+ `, {
190
+ items: [
191
+ {id: '1'},
192
+ {id: '2'}
193
+ ]
194
+ })
195
+ })
196
+
197
+ it('{or: [{c}, {c}]}', function () {
198
+ return client.test(`
199
+ query {
200
+ items(where: {or: [{a: 2}, {a: 3}]}, orderBy: id, orderDirection: asc) { id }
201
+ }
202
+ `, {
203
+ items: [
204
+ {id: '2'},
205
+ {id: '3'}
206
+ ]
207
+ })
208
+ })
209
+
210
+ it('{or: {or: {c}, c}}', function () {
211
+ return client.test(`
212
+ query {
213
+ items(where: {or: {a: 1, or: {b: 2}}}, orderBy: id, orderDirection: asc) { id }
214
+ }
215
+ `, {
216
+ items: [
217
+ {id: '1'},
218
+ {id: '2'},
219
+ {id: '3'}
220
+ ]
221
+ })
222
+ })
223
+
224
+ it('{and: [{or: {c}, c}, {or: {c}, c}]}', function () {
225
+ return client.test(`
226
+ query {
227
+ items(where: {and: [{or: {a: 5}, a: 4}, {or: {b: 2}, b: 4}]}, orderBy: id, orderDirection: asc) { id }
228
+ }
229
+ `, {
230
+ items: [
231
+ {id: '4'},
232
+ {id: '5'}
233
+ ]
234
+ })
235
+ })
236
+
237
+ it('{c, and: {c}, or: {c}}', function () {
238
+ return client.test(`
239
+ query {
240
+ items(where: { a: 4, and: {b: 4}, or: {b: 6} }, orderBy: id, orderDirection: asc) { id }
241
+ }
242
+ `, {
243
+ items: [
244
+ {id: '4'},
245
+ {id: '6'}
246
+ ]
247
+ })
248
+ })
249
+
250
+ it('handles empty wheres', function () {
251
+ return client.test(`
252
+ query {
253
+ items(where: { a: 4, and: { or: {}, and: {} }, or: { or: {and: {} } } }, orderBy: id, orderDirection: asc) { id }
254
+ }
255
+ `, {
256
+ items: [
257
+ {id: '4'}
258
+ ]
259
+ })
133
260
  })
134
261
  })
135
262
  })
package/lib/dialect.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export type Dialect = 'postgres' | 'cockroach';
2
- //# sourceMappingURL=dialect.d.ts.map