Filtrelenmiş Liste Sorguları
Sorgu sonuçlarınızı filtreleyebilirsiniz. Aşağıdaki örneklerde, createdAt, firstName, email, age gibi alanları ve ilişkileri içeren students adlı bir tablomuz var.
Sorgularda Filtre Kullanımı
Section titled “Sorgularda Filtre Kullanımı”Filtrelenmiş bir kayıt listesini sorgulayın. filter argümanına dikkat edin.
İstek
query MyQuery1 { students( filter: { createdAt: { gt: "2025-12-01T13:00:00.000Z" }, email: { contains: "williams" } } ) { items { id createdAt firstName email } }}Yanıt
{ "data": { "students": { "items": [ { "id": "97fb89ac-e0ad-44f5-b671-24a1b751287c", "createdAt": "2025-12-02T05:03:17.180675Z", "firstName": "John", "email": "john.williams@example.com" }, { "id": "e25c4955-7ea7-4a83-a3de-d4c7427cc9fa", "createdAt": "2025-12-04T14:18:15.955194Z", "firstName": "Robert", "email": "robert.williams@example.com" } ] } }}Koşullu Filtreler
Section titled “Koşullu Filtreler”Koşullu filtreler AND ve OR anahtarlarını kullanır.
AND Kullanımı
Section titled “AND Kullanımı”AND belirtildiğinde, tüm filtre nesneleri true döndürmelidir.
İstek
query MyQuery1 { students( filter: { AND: { email: { contains: "johnson" }, isActive: { not_equals: false } } } ) { items { id createdAt firstName email isActive } }}Yanıt
{ "data": { "students": { "items": [ { "id": "13fcb5bf-a8a4-4e55-860f-74f425944ec0", "createdAt": "2025-12-04T20:30:58.586321Z", "firstName": "Mary", "email": "mary.johnson@example.com", "isActive": true } ] } }}OR Kullanımı
Section titled “OR Kullanımı”OR belirtildiğinde, en az bir filtre nesnesi true döndürmelidir.
İstek
query MyQuery1 { students( filter: { OR: { firstName: { equals: "Mary" }, lastName: { equals: "Williams" } } } ) { items { id createdAt firstName email isActive } }}Yanıt
{ "data": { "students": { "items": [ { "id": "429cf99f-4481-49c4-adb4-605731b20eb2", "createdAt": "2025-12-04T14:16:53.049955Z", "firstName": "Mary", "email": "mary.brown@example.com", "isActive": true }, { "id": "97fb89ac-e0ad-44f5-b671-24a1b751287c", "createdAt": "2025-12-02T05:03:17.180675Z", "firstName": "John", "email": "john.williams@example.com", "isActive": true }, { "id": "13fcb5bf-a8a4-4e55-860f-74f425944ec0", "createdAt": "2025-12-04T20:30:58.586321Z", "firstName": "Mary", "email": "mary.johnson@example.com", "isActive": true }, { "id": "0174dc55-d494-4ebc-a0e9-13575461cad4", "createdAt": "2025-12-05T15:20:10.123456Z", "firstName": "Robert", "email": "robert.williams@example.com", "isActive": true } ] } }}