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§

source§

impl SchemaDefinition

source

pub fn new() -> Self

Create a new instance of SchemaDef.

source

pub fn description(&mut self, description: String)

Set the SchemaDef’s description.

source

pub fn directive(&mut self, directive: Directive)

Add a directive.

source

pub fn extend(&mut self)

Set as an extension

source

pub fn query(&mut self, query: String)

Set the schema def’s query type.

source

pub fn mutation(&mut self, mutation: String)

Set the schema def’s mutation type.

source

pub fn subscription(&mut self, subscription: String)

Set the schema def’s subscription type.

Trait Implementations§

source§

impl Clone for SchemaDefinition

source§

fn clone(&self) -> SchemaDefinition

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 SchemaDefinition

source§

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

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

impl Default for SchemaDefinition

source§

fn default() -> Self

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

impl Display for SchemaDefinition

source§

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

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

impl TryFrom<SchemaDefinition> for SchemaDefinition

source§

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

The type returned in the event of a conversion error.
source§

impl TryFrom<SchemaExtension> for SchemaDefinition

source§

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.

§

type Error = FromError

The type returned in the event of a conversion error.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Fmt for Twhere T: Display,

§

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

Give this value the specified foreground colour.
§

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 Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.