pub struct QueryMatcher { /* private fields */ }Expand description
Query pattern matcher.
Matches incoming GraphQL queries against the compiled schema to determine which pre-compiled SQL template to execute.
Implementations§
Source§impl QueryMatcher
impl QueryMatcher
Sourcepub fn new(schema: CompiledSchema) -> Self
pub fn new(schema: CompiledSchema) -> Self
Create new query matcher.
Indexes are (re)built at construction time so that match_query
works correctly regardless of whether build_indexes() was called
on the schema before passing it here.
Sourcepub fn match_query(
&self,
query: &str,
variables: Option<&Value>,
) -> Result<QueryMatch>
pub fn match_query( &self, query: &str, variables: Option<&Value>, ) -> Result<QueryMatch>
Match a GraphQL query to a compiled template.
§Arguments
query- GraphQL query stringvariables- Query variables (optional)
§Returns
QueryMatch with query definition and extracted information
§Errors
Returns error if:
- Query syntax is invalid
- Query references undefined operation
- Query structure doesn’t match schema
- Fragment resolution fails
- Directive evaluation fails
§Example
// Requires: compiled schema.
// See: tests/integration/ for runnable examples.
let matcher = QueryMatcher::new(schema);
let query = "query { users { id name } }";
let matched = matcher.match_query(query, None)?;
assert_eq!(matched.query_def.name, "users");Sourcepub fn extract_arguments(variables: Option<&Value>) -> HashMap<String, Value>
pub fn extract_arguments(variables: Option<&Value>) -> HashMap<String, Value>
Build the variables map exposed on QueryMatch::arguments from the
raw GraphQL variables JSON payload.
This is the public entry point used by tests; internally the
match_query hot path now constructs the same map exactly once
via a private helper.
Sourcepub const fn schema(&self) -> &CompiledSchema
pub const fn schema(&self) -> &CompiledSchema
Get the compiled schema.
Auto Trait Implementations§
impl Freeze for QueryMatcher
impl RefUnwindSafe for QueryMatcher
impl Send for QueryMatcher
impl Sync for QueryMatcher
impl Unpin for QueryMatcher
impl UnsafeUnpin for QueryMatcher
impl UnwindSafe for QueryMatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more