Consultas de Lista Filtrada
Você pode filtrar os resultados da sua consulta. Nos exemplos a seguir, temos uma tabela chamada students, que contém campos e relações como createdAt, firstName, email, age.
Usando Filtros em Consultas
Seção intitulada “Usando Filtros em Consultas”Consulte uma lista de registros que são filtrados. Observe o argumento filter.
Solicitação
query MyQuery1 { students( filter: { createdAt: { gt: "2025-12-01T13:00:00.000Z" }, email: { contains: "williams" } } ) { items { id createdAt firstName email } }}Resposta
{ "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" } ] } }}Filtros Condicionais
Seção intitulada “Filtros Condicionais”Filtros condicionais usam as chaves AND e OR.
Usando AND
Seção intitulada “Usando AND”Quando AND é especificado, todos os objetos de filtro devem retornar verdadeiro.
Solicitação
query MyQuery1 { students( filter: { AND: { email: { contains: "johnson" }, isActive: { not_equals: false } } } ) { items { id createdAt firstName email isActive } }}Resposta
{ "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 } ] } }}Usando OR
Seção intitulada “Usando OR”Quando OR é especificado, pelo menos um objeto de filtro deve retornar verdadeiro.
Solicitação
query MyQuery1 { students( filter: { OR: { firstName: { equals: "Mary" }, lastName: { equals: "Williams" } } } ) { items { id createdAt firstName email isActive } }}Resposta
{ "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 } ] } }}