Skip to content

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.

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.

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:

  • CourseFilter for filtering courses
  • StudentFilter for filtering students
  • AssignmentFilter for filtering assignments

String fields typically support these filtering operations:

OperationDescriptionExample
equalsExact match{ name: { equals: "Math 101" } }
containsContains substring{ name: { contains: "Math" } }
startsWithStarts with substring{ name: { startsWith: "Math" } }
endsWithEnds with substring{ name: { endsWith: "101" } }

Number fields support range operations:

OperationDescriptionExample
equalsExact match{ enrollmentCount: { equals: 25 } }
gtGreater than{ enrollmentCount: { gt: 20 } }
gteGreater than or equal{ enrollmentCount: { gte: 20 } }
ltLess than{ enrollmentCount: { lt: 30 } }
lteLess than or equal{ enrollmentCount: { lte: 30 } }
betweenBetween two values{ enrollmentCount: { between: [20, 30] } }

Date fields support similar operations to number fields:

OperationDescriptionExample
equalsExact date match{ startDate: { equals: "2023-09-01" } }
beforeBefore date{ startDate: { before: "2023-09-01" } }
afterAfter date{ startDate: { after: "2023-09-01" } }
betweenBetween two dates{ startDate: { between: ["2023-09-01", "2023-12-31"] } }

Boolean fields can be filtered directly:

{
isActive: true
}

ID fields support exact match or inclusion in a list:

OperationDescriptionExample
equalsExact ID match{ id: { equals: "course-123" } }
inID in list{ id: { in: ["course-123", "course-456"] } }

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
}
}
}

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
}
}
}

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
}
}
}

Each resource type has specific filter fields. For detailed information on available filters for each resource, see the resource-specific documentation:

  1. Filter on the server: Always use API filtering instead of retrieving large datasets and filtering client-side.

  2. Be specific: Use the most specific filter operations available to minimize data transfer.

  3. Combine with pagination: Use filtering together with pagination for the most efficient queries.

  4. Test complex filters: Complex logical combinations should be thoroughly tested to ensure they return the expected results.