QueryBuilder

Struct QueryBuilder 

Source
pub struct QueryBuilder<'schema, 'fragreg>(/* private fields */);

Implementations§

Source§

impl<'schema: 'fragreg, 'fragreg> QueryBuilder<'schema, 'fragreg>

Source

pub fn add_directive( self, annot: DirectiveAnnotation, ) -> Result<Self, QueryBuildError>

Add a DirectiveAnnotation after any previously added DirectiveAnnotations.

Source

pub fn add_selection( self, selection: Selection<'schema>, ) -> Result<Self, QueryBuildError>

Add a Selection after any previously added Selections.

Source

pub fn add_variable(self, variable: Variable) -> Result<Self, QueryBuildError>

Add a Variable after any previously added Variables.

Source

pub fn build(self) -> Result<Query<'schema, 'fragreg>, QueryBuildError>

Consume this QueryBuilder to produce a Query.

Source

pub fn build_from_ast( schema: &'schema Schema, fragment_registry: &'fragreg FragmentRegistry<'schema>, ast: &Query, file_path: Option<&Path>, ) -> Result<Query<'schema, 'fragreg>, QueryBuildError>

Produce a Query from a ast::operation::Query.

Source

pub fn build_from_file( schema: &'schema Schema, fragment_registry: &'fragreg FragmentRegistry<'schema>, file_path: impl AsRef<Path>, ) -> Result<Query<'schema, 'fragreg>, QueryBuildError>

Produce a Query from a file on disk that whose contents contain an executable document with only a single query defined in it.

If multiple operations are defined in the document, an error will be returned. For cases where multiple operations may be defined in a single document, use ExecutableDocumentBuilder.

If the document contents include any fragment definitions, an error will be returned. For cases where operations and fragments may be defined together in a single document, use ’ExecutableDocumentBuilder`.

Source

pub fn build_from_str( schema: &'schema Schema, fragment_registry: &'fragreg FragmentRegistry<'schema>, file_path: Option<&Path>, content: impl AsRef<str>, ) -> Result<Query<'schema, 'fragreg>, QueryBuildError>

Produce a Query from a string whose contents contain a document with only a single query defined in it.

If multiple operations are defined in the document, an error will be returned. For cases where multiple operations may be defined in a single document, use ExecutableDocumentBuilder.

If the document contents include any fragment definitions, an error will be returned. For cases where operations and fragments may be defined together in a single document, use ’ExecutableDocumentBuilder`.

Source

pub fn from_ast( schema: &'schema Schema, fragment_registry: &'fragreg FragmentRegistry<'schema>, ast: &Query, file_path: Option<&Path>, ) -> Result<Self, QueryBuildError>

Produce a QueryBuilder from a Query.

Source

pub fn from_file( schema: &'schema Schema, fragment_registry: &'fragreg FragmentRegistry<'schema>, file_path: impl AsRef<Path>, ) -> Result<Self, QueryBuildError>

Produce a QueryBuilder from a file on disk that whose contents contain an executable document with only a single query defined in it.

If multiple operations are defined in the document, an error will be returned. For cases where multiple operations may be defined in a single document, use ExecutableDocumentBuilder.

If the document contents include any fragment definitions, an error will be returned. For cases where operations and fragments may be defined together in a single document, use ’ExecutableDocumentBuilder`.

Source

pub fn from_str( schema: &'schema Schema, fragment_registry: &'fragreg FragmentRegistry<'schema>, content: impl AsRef<str>, file_path: Option<&Path>, ) -> Result<Self, QueryBuildError>

Produce a QueryBuilder from a string whose contents contain a document with only a single query defined in it.

If multiple operations are defined in the document, an error will be returned. For cases where multiple operations may be defined in a single document, use ExecutableDocumentBuilder.

If the document contents include any fragment definitions, an error will be returned. For cases where operations and fragments may be defined together in a single document, use ’ExecutableDocumentBuilder`.

Source

pub fn new( schema: &'schema Schema, fragment_registry: &'fragreg FragmentRegistry<'schema>, ) -> Self

See [OperationBuilderTrait::new]

Source

pub fn set_directives( self, directives: &[DirectiveAnnotation], ) -> Result<Self, QueryBuildError>

Set the list of DirectiveAnnotations.

NOTE: If any previous directives were added (either using this function or QueryBuilder::add_directive()), they will be fully replaced by the DirectiveAnnotations passed here.

Source

pub fn set_name(self, name: Option<String>) -> Result<Self, QueryBuildError>

Set the name of the Query.

Source

pub fn set_variables( self, variables: Vec<Variable>, ) -> Result<Self, QueryBuildError>

Set the list of Variables.

NOTE: If any previous variables were added (either using this function or QueryBuilder::add_variable()), they will be fully replaced by the collection of variables passed here.

Trait Implementations§

Source§

impl<'schema, 'fragreg> Clone for QueryBuilder<'schema, 'fragreg>

Source§

fn clone(&self) -> QueryBuilder<'schema, 'fragreg>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'schema, 'fragreg> Debug for QueryBuilder<'schema, 'fragreg>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'schema, 'fragreg> PartialEq for QueryBuilder<'schema, 'fragreg>

Source§

fn eq(&self, other: &QueryBuilder<'schema, 'fragreg>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'schema, 'fragreg> StructuralPartialEq for QueryBuilder<'schema, 'fragreg>

Auto Trait Implementations§

§

impl<'schema, 'fragreg> Freeze for QueryBuilder<'schema, 'fragreg>

§

impl<'schema, 'fragreg> RefUnwindSafe for QueryBuilder<'schema, 'fragreg>

§

impl<'schema, 'fragreg> Send for QueryBuilder<'schema, 'fragreg>

§

impl<'schema, 'fragreg> Sync for QueryBuilder<'schema, 'fragreg>

§

impl<'schema, 'fragreg> Unpin for QueryBuilder<'schema, 'fragreg>

§

impl<'schema, 'fragreg> UnwindSafe for QueryBuilder<'schema, 'fragreg>

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, 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.