Skip to main content

QueryMatch

Struct QueryMatch 

Source
pub struct QueryMatch {
    pub query_def: QueryDefinition,
    pub fields: Vec<String>,
    pub selections: Vec<FieldSelection>,
    pub arguments: HashMap<String, Value>,
    pub operation_name: Option<String>,
    pub scope_where: Option<Value>,
    pub search_relevance: Option<RelevanceOrder>,
    pub parsed_query: ParsedQuery,
}
Expand description

A matched query with extracted information.

Fields§

§query_def: QueryDefinition

The matched query definition from compiled schema.

§fields: Vec<String>

Requested fields (selection set) - now includes full field info.

§selections: Vec<FieldSelection>

Parsed and processed field selections (after fragment/directive resolution).

§arguments: HashMap<String, Value>

Query arguments/variables.

§operation_name: Option<String>

Query operation name (if provided).

§scope_where: Option<Value>

The server’s own row-scoping predicate, in the same {field: {op: value}} shape a client where uses, or None when the caller is a plain GraphQL document.

Kept apart from arguments["where"] because the two are not the same kind of thing and must not share a fate (#1170). REST resource embedding used to build its parent-scoping join predicate into arguments["where"] and dispatch it through the ordinary read path — which composes that argument only when the target query’s auto_params.has_where is set. has_where governs the client-facing filter surface; a project that turns it off is saying “clients may not filter this”, not “and relations that embed it may go unscoped”. Turning it off silently discarded the predicate and reported the target’s entire result set as the relation’s contents — every row under every parent, and, on the ManyToOne branch, the wrong parent attributed outright.

Composed unconditionally alongside RLS and inject_params, which is where server-side scoping belongs, and never read from client input: a GraphQL document has no syntax that reaches this field.

§search_relevance: Option<RelevanceOrder>

The server’s own relevance ordering, derived from a ?search= request, or None when the read was not a full-text search (#1284).

Kept apart from arguments["orderBy"] for the same reason scope_where is kept apart from arguments["where"]: the argument map is the client’s surface, and this is not something a client can spell. The previous attempt did put it there — as [{"_relevance": "desc"}] — and it type-checked at the handler, at serde_json, and at the argument map, failing only in the ORDER BY parser three layers down, which is how the documented default path of full-text search answered 400 on every representation.

The transport sets this only when the client named no sort of its own, so an explicit ?sort= always wins — which is what the generated OpenAPI document promises (“ranked by relevance unless sort is specified”).

§parsed_query: ParsedQuery

The parsed query (for access to fragments, variables, etc.).

Implementations§

Source§

impl QueryMatch

Source

pub fn response_key(&self) -> &str

The key this query’s result appears under in data.

The document’s alias when it supplies one, otherwise the field name as written. The envelope used to be keyed by the compiled query definition’s name, so { a: users { id } } answered under users and two aliased selections of one query collapsed into a single key.

Falls back to the definition name when there is no selection to read — the REST transport builds a QueryMatch with no GraphQL document behind it.

Source

pub fn from_operation( query_def: QueryDefinition, fields: Vec<String>, arguments: HashMap<String, Value>, _type_def: Option<&TypeDefinition>, ) -> Result<Self>

Build a QueryMatch directly from a query definition and arguments, bypassing GraphQL string parsing.

Used by the REST transport to construct sub-queries for resource embedding and bulk operations without synthesising a GraphQL query string.

The result has the same shape as QueryMatcher::match_query’s: a single root selection named for the query, carrying the requested fields as its nested_fields. Every consumer of a QueryMatch reads the requested field set as selections.first().nested_fields — the planner’s projection extraction, the #423 field-authorization gate, and project_nested_lists all do — so a flat list of leaf selections reads to all of them as “no fields requested”.

That was #886: this constructor built the flat shape, so every REST read projected zero fields ({"data":[{},{},{}]}) and the field-authorization gate was handed an empty slice and never fired. The two defects masked each other — no gated value leaked only because no value was served at all.

§Errors

Returns FraiseQLError::Validation if the query definition has no SQL source.

Source

pub fn with_scope_where(self, scope_where: Value) -> Self

Attach the server’s own scoping predicate to a QueryMatch built by a non-GraphQL transport.

See scope_where for why this is not simply another entry in arguments.

Source

pub fn with_search_relevance(self, relevance: RelevanceOrder) -> Self

Attach the relevance ordering a ?search= request implies (#1284).

See search_relevance for why this is not another entry in arguments.

Trait Implementations§

Source§

impl Clone for QueryMatch

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QueryMatch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more