@subsquid/openreader 4.6.0 → 5.0.0-beta.b87ffb
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/lib/context.d.ts +2 -2
- package/lib/context.d.ts.map +1 -1
- package/lib/db.d.ts +3 -3
- package/lib/db.d.ts.map +1 -1
- package/lib/db.js +2 -2
- package/lib/db.js.map +1 -1
- package/lib/dialect/common.d.ts +19 -0
- package/lib/dialect/common.d.ts.map +1 -0
- package/lib/dialect/common.js +42 -0
- package/lib/dialect/common.js.map +1 -0
- package/lib/dialect/index.d.ts +6 -0
- package/lib/dialect/index.d.ts.map +1 -0
- package/lib/dialect/index.js +49 -0
- package/lib/dialect/index.js.map +1 -0
- package/lib/{opencrud → dialect/opencrud}/orderBy.d.ts +2 -3
- package/lib/dialect/opencrud/orderBy.d.ts.map +1 -0
- package/lib/{opencrud → dialect/opencrud}/orderBy.js +4 -21
- package/lib/dialect/opencrud/orderBy.js.map +1 -0
- package/lib/{opencrud → dialect/opencrud}/schema.d.ts +2 -6
- package/lib/dialect/opencrud/schema.d.ts.map +1 -0
- package/lib/{opencrud → dialect/opencrud}/schema.js +21 -34
- package/lib/dialect/opencrud/schema.js.map +1 -0
- package/lib/{opencrud → dialect/opencrud}/tree.d.ts +3 -3
- package/lib/dialect/opencrud/tree.d.ts.map +1 -0
- package/lib/{opencrud → dialect/opencrud}/tree.js +3 -3
- package/lib/dialect/opencrud/tree.js.map +1 -0
- package/lib/{opencrud → dialect/opencrud}/where.d.ts +1 -1
- package/lib/dialect/opencrud/where.d.ts.map +1 -0
- package/lib/{opencrud → dialect/opencrud}/where.js +4 -13
- package/lib/dialect/opencrud/where.js.map +1 -0
- package/lib/dialect/thegraph/locale.d.ts +2 -0
- package/lib/dialect/thegraph/locale.d.ts.map +1 -0
- package/lib/dialect/thegraph/locale.js +49 -0
- package/lib/dialect/thegraph/locale.js.map +1 -0
- package/lib/dialect/thegraph/orderBy.d.ts +11 -0
- package/lib/dialect/thegraph/orderBy.d.ts.map +1 -0
- package/lib/dialect/thegraph/orderBy.js +71 -0
- package/lib/dialect/thegraph/orderBy.js.map +1 -0
- package/lib/dialect/thegraph/schema.d.ts +25 -0
- package/lib/dialect/thegraph/schema.d.ts.map +1 -0
- package/lib/dialect/thegraph/schema.js +429 -0
- package/lib/dialect/thegraph/schema.js.map +1 -0
- package/lib/dialect/thegraph/tree.d.ts +10 -0
- package/lib/dialect/thegraph/tree.d.ts.map +1 -0
- package/lib/dialect/thegraph/tree.js +148 -0
- package/lib/dialect/thegraph/tree.js.map +1 -0
- package/lib/dialect/thegraph/where.d.ts +9 -0
- package/lib/dialect/thegraph/where.d.ts.map +1 -0
- package/lib/dialect/thegraph/where.js +188 -0
- package/lib/dialect/thegraph/where.js.map +1 -0
- package/lib/ir/args.d.ts +1 -1
- package/lib/ir/args.d.ts.map +1 -1
- package/lib/main.js +1 -1
- package/lib/main.js.map +1 -1
- package/lib/model.d.ts +2 -0
- package/lib/model.d.ts.map +1 -1
- package/lib/model.schema.d.ts.map +1 -1
- package/lib/model.schema.js +31 -2
- package/lib/model.schema.js.map +1 -1
- package/lib/server.d.ts +3 -1
- package/lib/server.d.ts.map +1 -1
- package/lib/server.js +7 -6
- package/lib/server.js.map +1 -1
- package/lib/sql/cursor.d.ts +2 -2
- package/lib/sql/cursor.d.ts.map +1 -1
- package/lib/sql/cursor.js +2 -2
- package/lib/sql/cursor.js.map +1 -1
- package/lib/sql/printer.d.ts +3 -3
- package/lib/sql/printer.d.ts.map +1 -1
- package/lib/sql/printer.js +17 -15
- package/lib/sql/printer.js.map +1 -1
- package/lib/sql/query.d.ts +5 -5
- package/lib/sql/query.d.ts.map +1 -1
- package/lib/sql/query.js.map +1 -1
- package/lib/sql/util.d.ts +2 -2
- package/lib/sql/util.d.ts.map +1 -1
- package/lib/sql/util.js.map +1 -1
- package/lib/test/basic.test.js +471 -229
- package/lib/test/basic.test.js.map +1 -1
- package/lib/test/isNull.test.js +87 -36
- package/lib/test/isNull.test.js.map +1 -1
- package/lib/test/limits.test.js +206 -94
- package/lib/test/limits.test.js.map +1 -1
- package/lib/test/lookup.test.js +184 -81
- package/lib/test/lookup.test.js.map +1 -1
- package/lib/test/setup.js +2 -2
- package/lib/test/setup.js.map +1 -1
- package/lib/test/where.test.js +216 -99
- package/lib/test/where.test.js.map +1 -1
- package/package.json +5 -3
- package/src/context.ts +2 -2
- package/src/db.ts +4 -2
- package/src/dialect/common.ts +49 -0
- package/src/dialect/index.ts +20 -0
- package/src/{opencrud → dialect/opencrud}/orderBy.ts +4 -21
- package/src/{opencrud → dialect/opencrud}/schema.ts +30 -55
- package/src/{opencrud → dialect/opencrud}/tree.ts +6 -7
- package/src/{opencrud → dialect/opencrud}/where.ts +4 -16
- package/src/dialect/thegraph/locale.ts +284 -0
- package/src/dialect/thegraph/orderBy.ts +75 -0
- package/src/dialect/thegraph/schema.ts +484 -0
- package/src/dialect/thegraph/tree.ts +162 -0
- package/src/dialect/thegraph/where.ts +184 -0
- package/src/ir/args.ts +2 -0
- package/src/main.ts +3 -3
- package/src/model.schema.ts +37 -4
- package/src/model.ts +2 -0
- package/src/server.ts +21 -19
- package/src/sql/cursor.ts +4 -4
- package/src/sql/printer.ts +22 -18
- package/src/sql/query.ts +5 -5
- package/src/sql/util.ts +2 -2
- package/src/test/basic.test.ts +570 -282
- package/src/test/isNull.test.ts +95 -38
- package/src/test/limits.test.ts +212 -91
- package/src/test/lookup.test.ts +190 -83
- package/src/test/setup.ts +2 -2
- package/src/test/where.test.ts +235 -108
- package/lib/dialect.d.ts +0 -2
- package/lib/dialect.d.ts.map +0 -1
- package/lib/dialect.js +0 -3
- package/lib/dialect.js.map +0 -1
- package/lib/opencrud/orderBy.d.ts.map +0 -1
- package/lib/opencrud/orderBy.js.map +0 -1
- package/lib/opencrud/schema.d.ts.map +0 -1
- package/lib/opencrud/schema.js.map +0 -1
- package/lib/opencrud/tree.d.ts.map +0 -1
- package/lib/opencrud/tree.js.map +0 -1
- package/lib/opencrud/where.d.ts.map +0 -1
- package/lib/opencrud/where.js.map +0 -1
- package/src/dialect.ts +0 -2
package/src/test/lookup.test.ts
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
113
|
-
|
|
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
|
-
|
|
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
|
})
|
package/src/test/where.test.ts
CHANGED
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
131
|
-
|
|
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