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
impl Parser
pub fn new() -> Self
sourcepub fn recursion_limit(self, value: usize) -> Self
pub fn recursion_limit(self, value: usize) -> Self
Configure the recursion to use while parsing.
sourcepub fn token_limit(self, value: usize) -> Self
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.
sourcepub fn parse_ast(
&mut self,
source_text: impl Into<String>,
path: impl AsRef<Path>
) -> Result<Document, WithErrors<Document>>
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.
sourcepub fn parse_schema(
&mut self,
source_text: impl Into<String>,
path: impl AsRef<Path>
) -> Result<Schema, WithErrors<Schema>>
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
.
sourcepub fn parse_into_schema_builder(
&mut self,
source_text: impl Into<String>,
path: impl AsRef<Path>,
builder: &mut SchemaBuilder
)
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
.
sourcepub fn parse_executable(
&mut self,
schema: &Valid<Schema>,
source_text: impl Into<String>,
path: impl AsRef<Path>
) -> Result<ExecutableDocument, WithErrors<ExecutableDocument>>
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.
sourcepub fn parse_mixed_validate(
&mut self,
source_text: impl Into<String>,
path: impl AsRef<Path>
) -> Result<(Valid<Schema>, Valid<ExecutableDocument>), DiagnosticList>
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.
sourcepub 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>>
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.
sourcepub fn parse_type(
&mut self,
source_text: impl Into<String>,
path: impl AsRef<Path>
) -> Result<Type, DiagnosticList>
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.
sourcepub fn recursion_reached(&self) -> usize
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
.
sourcepub fn tokens_reached(&self) -> usize
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
.