mochi/security

Types

pub type QueryAnalysis {
  QueryAnalysis(
    depth: Int,
    complexity: Int,
    alias_count: Int,
    root_field_count: Int,
    field_count: Int,
  )
}

Constructors

  • QueryAnalysis(
      depth: Int,
      complexity: Int,
      alias_count: Int,
      root_field_count: Int,
      field_count: Int,
    )
pub type SecurityConfig {
  SecurityConfig(
    max_depth: option.Option(Int),
    max_complexity: option.Option(Int),
    max_aliases: option.Option(Int),
    max_root_fields: option.Option(Int),
  )
}

Constructors

pub type SecurityError {
  DepthLimitExceeded(depth: Int, max: Int)
  ComplexityLimitExceeded(complexity: Int, max: Int)
  AliasLimitExceeded(count: Int, max: Int)
  RootFieldLimitExceeded(count: Int, max: Int)
}

Constructors

  • DepthLimitExceeded(depth: Int, max: Int)
  • ComplexityLimitExceeded(complexity: Int, max: Int)
  • AliasLimitExceeded(count: Int, max: Int)
  • RootFieldLimitExceeded(count: Int, max: Int)

Values

pub fn analyze(document: @internal Document) -> QueryAnalysis

Analyze a query document

pub fn default_config() -> SecurityConfig

Default security configuration

pub fn error_message(error: SecurityError) -> String
pub fn no_limits() -> SecurityConfig

Permissive configuration (no limits)

pub fn validate(
  document: @internal Document,
  config: SecurityConfig,
) -> Result(QueryAnalysis, SecurityError)

Validate a query against security configuration

Search Document