Operators And Directives Quick reference for GraphJin filter operators, directives, JSON operators, and expression surfaces. reference reference reference/operators-directives reference/operators-directives.md

Operators And Directives

Quick reference for GraphJin filter operators, directives, JSON operators, and expression surfaces.

Filters

OperatorMeaning
eq, neqEquals / not equals
gt, gte, lt, lteNumeric or ordered comparisons
in, ninInclusion or exclusion lists
is_nullNull checks
like, ilike, regex, iregex, similarText pattern matching where supported
has_key, has_key_any, has_key_allJSON key checks
contains, contained_inJSON/array containment where supported
st_dwithin, st_within, st_contains, st_intersects, st_coveredby, st_covers, st_touches, st_overlaps, nearSpatial and MongoDB geo filters
Verified by TestGeoStDWithinPoint core/internal/qcode/geo_test.go:21

Logical operators

Use and, or, and not to compose filters.

GraphQL
where: {
  and: [
    { price: { gt: 10 } }
    { not: { id: { is_null: true } } }
  ]
}

Whole-object variables are not valid filter syntax. Use variables only at leaf values:

GraphQL
query($label: String) {
  user_fields(where: { label: { eq: $label } }) {
    id
    label
  }
}

Pagination and ordering

FeatureSyntax
Limit/offsetlimit: 10, offset: 20
Forward cursorfirst: 10, after: $products_cursor
Backward cursorlast: 10, before: $products_cursor
Cursor fieldproducts_cursor at query root
Distinctdistinct: [category_id]
Nested orderorder_by: { owner: { email: asc } }
Custom listorder_by: { id: [$ids, "asc"] }
Null placementorder_by: { price: { dir: desc, nulls: last } }

Cursor values are opaque and must come from GraphJin. Do not hardcode cursor prefixes.

Aggregates and expressions

GraphQL
query {
  products(distinct: [category_id], order_by: { revenue: desc }, limit: 10) {
    category_id
    count_id
    revenue: sum(expr: { mul: [price, quantity] })
  }
}

Expression aggregate operators include add, sub, mul, div, mod, coalesce, nullif, case, cast, aggregate nodes such as { sum: id }, column refs, and literals.

Analytics directives

DirectiveMeaning
@running(aggregate:)Running aggregate without collapsing rows.
@moving(aggregate:, rows:)Trailing moving aggregate over a fixed row window.
@previous, @nextPrevious/next row value.
@first, @lastFirst/last value in an ordered group.
@rank, @denseRank, @rowNumberRanking and row numbering.
GraphQL
query {
  orders {
    account_id
    month
    total
    running_total: total @running(aggregate: sum, by: "account_id", orderBy: { month: asc })
    rank_by_total: total @rank(by: "account_id", order: desc)
  }
}
Verified by TestAnalytics_DialectRendering core/internal/psql/window_test.go:56

Analytics directives and GraphQL directives

GraphJin supports GraphQL conditional directives plus GraphJin-specific directives.

DirectiveUse
@include(ifRole:), @skip(ifRole:)Role-aware field selection.
@include(ifVar:), @skip(ifVar:)Variable-aware field selection.
@objectReturn a single object instead of an array.
@schema(name:)Target a specific database schema.
@through(table:)Name the intermediate join table for many-to-many relationships.
@through(column:)Name the FK column to follow when multiple relationships are possible.
@notRelatedDisable automatic relationship detection for a field.
@cacheControl(maxAge:)Set a query cache TTL in seconds.
@database(name:)Assign a schema/table definition to a named database.

Keep MCP docs aligned

When operators or syntax change, update the MCP syntax documentation in serv/mcp_syntax.go so AI clients can discover the new shape.

Verified by TestQuerySyntaxReference_HasAnalyticsDirectives serv/mcp_test.go:1619
Docs