You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add support for filtering collection fields (one-to-many relationships) using the same query format as main queries
- Implement formatArgs function for proper GraphQL argument formatting
- Add comprehensive documentation for collection field filtering feature
- Update version to 2.0.0
This major version bump introduces the ability to filter related objects directly within GraphQL queries, providing more powerful and flexible querying capabilities.
Copy file name to clipboardExpand all lines: README.md
+116Lines changed: 116 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -204,6 +204,122 @@ query {
204
204
-`NIN` - Not in array
205
205
-`BTW` - Between two values
206
206
207
+
### Collection Field Filtering
208
+
209
+
Simfinity.js now supports filtering collection fields (one-to-many relationships) using the same powerful query format. This allows you to filter related objects directly within your GraphQL queries.
210
+
211
+
#### Basic Collection Filtering
212
+
213
+
Filter collection fields using the same operators and format as main queries:
214
+
215
+
```graphql
216
+
query {
217
+
series {
218
+
seasons(number: { operator: EQ, value: 1 }) {
219
+
number
220
+
id
221
+
year
222
+
}
223
+
}
224
+
}
225
+
```
226
+
227
+
#### Advanced Collection Filtering
228
+
229
+
You can use complex filtering with nested object properties:
230
+
231
+
```graphql
232
+
query {
233
+
series {
234
+
seasons(
235
+
year: { operator: GTE, value: 2020 }
236
+
episodes: {
237
+
terms: [
238
+
{
239
+
path: "name",
240
+
operator: LIKE,
241
+
value: "Pilot"
242
+
}
243
+
]
244
+
}
245
+
) {
246
+
number
247
+
year
248
+
episodes {
249
+
name
250
+
date
251
+
}
252
+
}
253
+
}
254
+
}
255
+
```
256
+
257
+
#### Collection Filtering with Multiple Conditions
258
+
259
+
Combine multiple filter conditions for collection fields:
260
+
261
+
```graphql
262
+
query {
263
+
series {
264
+
seasons(
265
+
number: { operator: GT, value: 1 }
266
+
year: { operator: BTW, value: [2015, 2023] }
267
+
) {
268
+
number
269
+
year
270
+
state
271
+
}
272
+
}
273
+
}
274
+
```
275
+
276
+
#### Nested Collection Filtering
277
+
278
+
Filter deeply nested collections using dot notation:
279
+
280
+
```graphql
281
+
query {
282
+
series {
283
+
seasons(
284
+
episodes: {
285
+
terms: [
286
+
{
287
+
path: "name",
288
+
operator: LIKE,
289
+
value: "Final"
290
+
}
291
+
]
292
+
}
293
+
) {
294
+
number
295
+
episodes {
296
+
name
297
+
date
298
+
}
299
+
}
300
+
}
301
+
}
302
+
```
303
+
304
+
#### Collection Filtering with Array Operations
305
+
306
+
Use array operations for collection fields:
307
+
308
+
```graphql
309
+
query {
310
+
series {
311
+
seasons(
312
+
categories: { operator: IN, value: ["Drama", "Crime"] }
313
+
) {
314
+
number
315
+
categories
316
+
}
317
+
}
318
+
}
319
+
```
320
+
321
+
**Note**: Collection field filtering uses the exact same format as main query filtering, ensuring consistency across your GraphQL API. All available operators (`EQ`, `NE`, `GT`, `LT`, `GTE`, `LTE`, `LIKE`, `IN`, `NIN`, `BTW`) work with collection fields.
322
+
207
323
## 🔧 Middlewares
208
324
209
325
Middlewares provide a powerful way to intercept and process all GraphQL operations before they execute. Use them for cross-cutting concerns like authentication, logging, validation, and performance monitoring.
// Collection field - generate resolve for one-to-many relationship
1629
+
//This is a one-to-many resolver that will return a list of related objects. Also this one allows to filter the related objects as is in the find endpoint.
thrownewError(`Related type ${relatedType.name} not found or not connected. Make sure it's connected with simfinity.connect() or simfinity.addNoEndpointType().`);
0 commit comments