from typing import Optional


def build_query_filter(risk_state: Optional[str], risk_level: Optional[str]) -> Optional[str]:
    """
    Build query filter for API call, in order to get filtered results.
    API query syntax reference: https://docs.microsoft.com/en-us/graph/query-parameters.

    Args:
        risk_state (str): Wanted risk state for filter.
        risk_level (str): Wanted risk level for filter.

    Returns:
        str: Query filter string for API call.
    """
    if risk_state and risk_level:
        return f"riskState eq '{risk_state}' and riskLevel eq '{risk_level}'"
    elif risk_state:
        return f"riskState eq '{risk_state}'"
    elif risk_level:
        return f"riskLevel eq '{risk_level}'"
    else:
        return None