pub struct ExecutableDocument {
    pub sources: SourceMap,
    pub anonymous_operation: Option<Node<Operation>>,
    pub named_operations: IndexMap<Name, Node<Operation>>,
    pub fragments: IndexMap<Name, Node<Fragment>>,
}
Expand description

Executable definitions, annotated with type information

Fields§

§sources: SourceMap

If this document was originally parsed from a source file, this map contains one entry for that file and its ID.

The document may have been modified since.

§anonymous_operation: Option<Node<Operation>>§named_operations: IndexMap<Name, Node<Operation>>§fragments: IndexMap<Name, Node<Fragment>>

Implementations§

source§

impl ExecutableDocument

source

pub fn new() -> Self

Create an empty document, to be filled programatically

source

pub fn parse( schema: &Valid<Schema>, source_text: impl Into<String>, path: impl AsRef<Path> ) -> Result<Self, WithErrors<Self>>

Parse an executable document with the default configuration.

path is the filesystem path (or arbitrary string) used in diagnostics to identify this source file to users.

Create a Parser to use different parser configuration.

source

pub fn parse_and_validate( schema: &Valid<Schema>, source_text: impl Into<String>, path: impl AsRef<Path> ) -> Result<Valid<Self>, WithErrors<Self>>

parse then validate, to get a Valid<ExecutableDocument> when mutating it isn’t needed.

source

pub fn validate( self, schema: &Valid<Schema> ) -> Result<Valid<Self>, WithErrors<Self>>

source

pub fn all_operations(&self) -> impl Iterator<Item = &Node<Operation>>

Returns an iterator of operations, both anonymous and named

source

pub fn get_operation( &self, name_request: Option<&str> ) -> Result<&Node<Operation>, GetOperationError>

Return the relevant operation for a request, or a request error

This the GetOperation() algorithm in the Executing Requests section of the specification.

A GraphQL request comes with a document (which may contain multiple operations) an an optional operation name. When a name is given the request executes the operation with that name, which is expected to exist. When it is not given / null / None, the document is expected to contain a single operation (which may or may not be named) to avoid ambiguity.

source

pub fn get_operation_mut( &mut self, name_request: Option<&str> ) -> Result<&mut Operation, GetOperationError>

Similar to get_operation but returns a mutable reference.

source

pub fn insert_operation( &mut self, operation: impl Into<Node<Operation>> ) -> Option<Node<Operation>>

Insert the given operation in either named_operations or anonymous_operation as appropriate, and return the old operation (if any) with that name (or lack thereof).

source

pub fn serialize(&self) -> Serialize<'_, Self>

Returns a builder that has chaining methods for setting serialization configuration, and implements the Display and ToString traits by writing GraphQL syntax.

Trait Implementations§

source§

impl Clone for ExecutableDocument

source§

fn clone(&self) -> ExecutableDocument

Returns a copy 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 Debug for ExecutableDocument

source§

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

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

impl Default for ExecutableDocument

source§

fn default() -> ExecutableDocument

Returns the “default value” for a type. Read more
source§

impl Display for ExecutableDocument

Serialize to GraphQL syntax with the default configuration

source§

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

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

impl PartialEq for ExecutableDocument

sources and build_errors are ignored for comparison

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for ExecutableDocument

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> Fmt for T
where T: Display,

source§

fn fg<C>(self, color: C) -> Foreground<Self>
where C: Into<Option<Color>>, Self: Display,

Give this value the specified foreground colour.
source§

fn bg<C>(self, color: C) -> Background<Self>
where C: Into<Option<Color>>, Self: Display,

Give this value the specified background colour.
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> StdoutFmt for T
where T: Display,

source§

fn fg<C>(self, color: C) -> Foreground<Self>
where C: Into<Option<Color>>,

Give this value the specified foreground colour, when color is enabled for stdout.
source§

fn bg<C>(self, color: C) -> Background<Self>
where C: Into<Option<Color>>,

Give this value the specified background colour, when color is enabled for stdout.
source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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

§

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.