Filtering in Teachify Admin API
Note: The Teachify Admin API is currently under development and not yet available for public use. This documentation is provided for preview purposes only.
Understanding Filtering
Section titled “Understanding Filtering”The Teachify Admin API supports powerful filtering capabilities that allow you to narrow down query results to exactly what you need. Filtering is performed on the server side, which improves performance by reducing the amount of data transferred.
Filter Structure
Section titled “Filter Structure”Filters are provided as input objects to queries. Each resource type has its own filter input type with fields specific to that resource. For example:
CourseFilterfor filtering coursesStudentFilterfor filtering studentsAssignmentFilterfor filtering assignments
Common Filter Types
Section titled “Common Filter Types”String Filters
Section titled “String Filters”String fields typically support these filtering operations:
| Operation | Description | Example |
|---|---|---|
equals | Exact match | { name: { equals: "Math 101" } } |
contains | Contains substring | { name: { contains: "Math" } } |
startsWith | Starts with substring | { name: { startsWith: "Math" } } |
endsWith | Ends with substring | { name: { endsWith: "101" } } |
Number Filters
Section titled “Number Filters”Number fields support range operations:
| Operation | Description | Example |
|---|---|---|
equals | Exact match | { enrollmentCount: { equals: 25 } } |
gt | Greater than | { enrollmentCount: { gt: 20 } } |
gte | Greater than or equal | { enrollmentCount: { gte: 20 } } |
lt | Less than | { enrollmentCount: { lt: 30 } } |
lte | Less than or equal | { enrollmentCount: { lte: 30 } } |
between | Between two values | { enrollmentCount: { between: [20, 30] } } |
Date Filters
Section titled “Date Filters”Date fields support similar operations to number fields:
| Operation | Description | Example |
|---|---|---|
equals | Exact date match | { startDate: { equals: "2023-09-01" } } |
before | Before date | { startDate: { before: "2023-09-01" } } |
after | After date | { startDate: { after: "2023-09-01" } } |
between | Between two dates | { startDate: { between: ["2023-09-01", "2023-12-31"] } } |
Boolean Filters
Section titled “Boolean Filters”Boolean fields can be filtered directly:
{ isActive: true}ID Filters
Section titled “ID Filters”ID fields support exact match or inclusion in a list:
| Operation | Description | Example |
|---|---|---|
equals | Exact ID match | { id: { equals: "course-123" } } |
in | ID in list | { id: { in: ["course-123", "course-456"] } } |
Combining Filters
Section titled “Combining Filters”You can combine multiple filters in a single query. By default, all conditions must be met (AND logic):
query { courses( filter: { name: { contains: "Math" } startDate: { after: "2023-01-01" } enrollmentCount: { gt: 10 } } ) { nodes { id name } }}Logical Operators
Section titled “Logical Operators”For more complex filtering, you can use logical operators:
query { courses( filter: { AND: [ { name: { contains: "Math" } }, { enrollmentCount: { gt: 10 } } ] } ) { nodes { id name } }}query { courses( filter: { OR: [ { name: { contains: "Math" } }, { name: { contains: "Science" } } ] } ) { nodes { id name } }}query { courses( filter: { NOT: { name: { contains: "Archived" } } } ) { nodes { id name } }}Filtering on Related Resources
Section titled “Filtering on Related Resources”You can filter based on related resources. For example, finding courses with specific instructors:
query { courses( filter: { instructors: { some: { name: { contains: "Smith" } } } } ) { nodes { id name } }}Resource-Specific Filters
Section titled “Resource-Specific Filters”Each resource type has specific filter fields. For detailed information on available filters for each resource, see the resource-specific documentation:
Best Practices
Section titled “Best Practices”-
Filter on the server: Always use API filtering instead of retrieving large datasets and filtering client-side.
-
Be specific: Use the most specific filter operations available to minimize data transfer.
-
Combine with pagination: Use filtering together with pagination for the most efficient queries.
-
Test complex filters: Complex logical combinations should be thoroughly tested to ensure they return the expected results.