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.
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
ⓘ
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 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