Struct apollo_compiler::Parser

source ·
pub struct Parser { /* private fields */ }
Expand description

Configuration for parsing an input string as GraphQL syntax

Implementations§

source§

impl Parser

source

pub fn new() -> Self

source

pub fn recursion_limit(self, value: usize) -> Self

Configure the recursion to use while parsing.

source

pub fn token_limit(self, value: usize) -> Self

Configure the limit on the number of tokens to parse. If an input document is too big, parsing will be aborted. By default, there is no limit.

source

pub fn parse_ast( &mut self, source_text: impl Into<String>, path: impl AsRef<Path> ) -> Result<Document, WithErrors<Document>>

Parse the given source text into an AST document.

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

source

pub fn parse_schema( &mut self, source_text: impl Into<String>, path: impl AsRef<Path> ) -> Result<Schema, WithErrors<Schema>>

Parse the given source text as the sole input file of a schema.

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

To have multiple files contribute to a schema, use Schema::builder and Parser::parse_into_schema_builder.

source

pub fn parse_into_schema_builder( &mut self, source_text: impl Into<String>, path: impl AsRef<Path>, builder: &mut SchemaBuilder )

Parse the given source text as an additional input to a schema builder.

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

This can be used to build a schema from multiple source files.

Errors (if any) are recorded in the builder and returned by SchemaBuilder::build.

source

pub fn parse_executable( &mut self, schema: &Valid<Schema>, source_text: impl Into<String>, path: impl AsRef<Path> ) -> Result<ExecutableDocument, WithErrors<ExecutableDocument>>

Parse the given source text into an executable document, with the given schema.

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

source

pub fn parse_mixed_validate( &mut self, source_text: impl Into<String>, path: impl AsRef<Path> ) -> Result<(Valid<Schema>, Valid<ExecutableDocument>), DiagnosticList>

Parse a schema and executable document from the given source text containing a mixture of type system definitions and executable definitions, and validate them. This is mostly useful for unit tests.

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

source

pub fn parse_field_set( &mut self, schema: &Valid<Schema>, type_name: NamedType, source_text: impl Into<String>, path: impl AsRef<Path> ) -> Result<FieldSet, WithErrors<FieldSet>>

Parse the given source text as a selection set with optional outer brackets.

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

source

pub fn parse_type( &mut self, source_text: impl Into<String>, path: impl AsRef<Path> ) -> Result<Type, DiagnosticList>

Parse the given source text as a reference to a type.

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

source

pub fn recursion_reached(&self) -> usize

What level of recursion was reached during the last call to a parse_* method.

Collecting this on a corpus of documents can help decide how to set recursion_limit.

source

pub fn tokens_reached(&self) -> usize

How many tokens were created during the last call to a parse_* method.

Collecting this on a corpus of documents can help decide how to set recursion_limit.

Trait Implementations§

source§

impl Clone for Parser

source§

fn clone(&self) -> Parser

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 Parser

source§

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

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

impl Default for Parser

source§

fn default() -> Parser

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

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

§

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

§

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.