01 Software

Advanced

Complex queries - filtering, pagination, deep relations, Schema Introspection

Advanced

Filtering

query {
  Products(
    where: {
      and: [
        { status: { equals: published } }
        { price: { greater_than: 10000, less_than: 50000 } }
        {
          or: [
            { category: { equals: "electronics" } }
            { tags: { contains: "featured" } }
          ]
        }
      ]
    }
  ) {
    docs {
      id
      name
      price
    }
  }
}

Sorting and Pagination

query {
  Posts(
    limit: 20
    page: 2
    sort: "-publishedAt"
  ) {
    docs {
      id
      title
      publishedAt
    }
    totalDocs
    page
    totalPages
    hasNextPage
    hasPrevPage
  }
}

Deep Relationship Queries

query {
  Post(id: "post_id") {
    id
    title
    author {
      id
      email
      tenants {
        id
        name
        plan
      }
    }
    categories {
      id
      name
      parent {
        id
        name
      }
    }
  }
}

Schema Introspection

Full Schema Query

query {
  __schema {
    types {
      name
      description
    }
  }
}

Specific Type Query

query {
  __type(name: "Product") {
    name
    fields {
      name
      type {
        name
        kind
      }
    }
  }
}

On this page