Struct apollo_compiler::executable::ExecutableDocument
source · 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
impl ExecutableDocument
sourcepub fn parse(
schema: &Valid<Schema>,
source_text: impl Into<String>,
path: impl AsRef<Path>
) -> Result<Self, WithErrors<Self>>
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.
sourcepub fn parse_and_validate(
schema: &Valid<Schema>,
source_text: impl Into<String>,
path: impl AsRef<Path>
) -> Result<Valid<Self>, WithErrors<Self>>
pub fn parse_and_validate( schema: &Valid<Schema>, source_text: impl Into<String>, path: impl AsRef<Path> ) -> Result<Valid<Self>, WithErrors<Self>>
pub fn validate( self, schema: &Valid<Schema> ) -> Result<Valid<Self>, WithErrors<Self>>
sourcepub fn all_operations(&self) -> impl Iterator<Item = &Node<Operation>>
pub fn all_operations(&self) -> impl Iterator<Item = &Node<Operation>>
Returns an iterator of operations, both anonymous and named
sourcepub fn get_operation(
&self,
name_request: Option<&str>
) -> Result<&Node<Operation>, GetOperationError>
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.
sourcepub fn get_operation_mut(
&mut self,
name_request: Option<&str>
) -> Result<&mut Operation, GetOperationError>
pub fn get_operation_mut( &mut self, name_request: Option<&str> ) -> Result<&mut Operation, GetOperationError>
Similar to get_operation
but returns a mutable reference.
Trait Implementations§
source§impl Clone for ExecutableDocument
impl Clone for ExecutableDocument
source§fn clone(&self) -> ExecutableDocument
fn clone(&self) -> ExecutableDocument
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ExecutableDocument
impl Debug for ExecutableDocument
source§impl Default for ExecutableDocument
impl Default for ExecutableDocument
source§fn default() -> ExecutableDocument
fn default() -> ExecutableDocument
source§impl Display for ExecutableDocument
impl Display for ExecutableDocument
Serialize to GraphQL syntax with the default configuration
source§impl PartialEq for ExecutableDocument
impl PartialEq for ExecutableDocument
sources
and build_errors
are ignored for comparison
impl Eq for ExecutableDocument
Auto Trait Implementations§
impl RefUnwindSafe for ExecutableDocument
impl Send for ExecutableDocument
impl Sync for ExecutableDocument
impl Unpin for ExecutableDocument
impl UnwindSafe for ExecutableDocument
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.