Struct apollo_encoder::SchemaDefinition
source · [−]pub struct SchemaDefinition { /* private fields */ }
Expand description
A GraphQL service’s collective type system capabilities are referred to as that service’s “schema”.
SchemaDefinition: Description? schema Directives? { RootOperationTypeDefinition* }
Detailed documentation can be found in GraphQL spec.
Example
use apollo_encoder::{SchemaDefinition};
use indoc::indoc;
let mut schema_def = SchemaDefinition::new();
schema_def.query("TryingToFindCatQuery".to_string());
schema_def.mutation("MyMutation".to_string());
schema_def.subscription("MySubscription".to_string());
assert_eq!(
schema_def.to_string(),
indoc! { r#"
schema {
query: TryingToFindCatQuery
mutation: MyMutation
subscription: MySubscription
}
"#}
);
Implementations
sourceimpl SchemaDefinition
impl SchemaDefinition
sourcepub fn description(&mut self, description: String)
pub fn description(&mut self, description: String)
Set the SchemaDef’s description.
sourcepub fn subscription(&mut self, subscription: String)
pub fn subscription(&mut self, subscription: String)
Set the schema def’s subscription type.
Trait Implementations
sourceimpl Clone for SchemaDefinition
impl Clone for SchemaDefinition
sourcefn clone(&self) -> SchemaDefinition
fn clone(&self) -> SchemaDefinition
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for SchemaDefinition
impl Debug for SchemaDefinition
sourceimpl Default for SchemaDefinition
impl Default for SchemaDefinition
sourceimpl Display for SchemaDefinition
impl Display for SchemaDefinition
sourceimpl TryFrom<SchemaDefinition> for SchemaDefinition
impl TryFrom<SchemaDefinition> for SchemaDefinition
sourcefn try_from(node: SchemaDefinition) -> Result<Self, Self::Error>
fn try_from(node: SchemaDefinition) -> Result<Self, Self::Error>
Create an apollo-encoder node from an apollo-parser one.
Errors
This returns an error if the apollo-parser tree is not valid. The error doesn’t have much context due to TryFrom API constraints: validate the parse tree before using TryFrom if granular errors are important to you.
type Error = FromError
type Error = FromError
sourceimpl TryFrom<SchemaExtension> for SchemaDefinition
impl TryFrom<SchemaExtension> for SchemaDefinition
sourcefn try_from(node: SchemaExtension) -> Result<Self, Self::Error>
fn try_from(node: SchemaExtension) -> Result<Self, Self::Error>
Create an apollo-encoder node from an apollo-parser one.
Errors
This returns an error if the apollo-parser tree is not valid. The error doesn’t have much context due to TryFrom API constraints: validate the parse tree before using TryFrom if granular errors are important to you.