Skip to main content

Generator

Struct Generator 

Source
pub struct Generator { /* private fields */ }

Implementations§

Source§

impl Generator

Source

pub fn new(schema: impl AsRef<str>) -> Result<Self, SchemaParseError>

Source

pub fn with_schema_name(self, schema_name: impl Into<String>) -> Self

Provides the name of a registered schema to use inside generated #[cynic(schema = "schema_name")] attributes.

Source

pub fn set_schema_name(&mut self, schema_name: impl Into<String>)

Provides the name of a registered schema to use inside generated #[cynic(schema = "schema_name")] attributes.

Source

pub fn with_override( self, coordinate: impl AsRef<str>, replacement: impl Into<String>, ) -> Result<Self, InvalidSchemaCoordinate>

Sets an override to the code that this Generator will generate.

The coordinate argument should be set to a valid schema coordinate - note that currently only member coordinates are currently supported by the generator.

§Member Coordinate Behaviour

The field name should have the same casing as the field name in the GraphQL schema (i.e. before conversion to snake_case). Note that the provided type override will still be wrapped in an Option if the field is nullable in the schema.

The replacement type must be a registered custom scalar for the schema scalar type of the overridden field.

Source

pub fn with_overrides<Iter, Coord, Replacement>( self, iter: Iter, ) -> Result<Self, InvalidSchemaCoordinate>
where Iter: IntoIterator<Item = (Coord, Replacement)>, Coord: AsRef<str>, Replacement: Into<String>,

Sets many overrides to the code that this Generator will generate.

See Generator::with_override for more details on overrides.

Source

pub fn set_override( &mut self, coordinate: impl AsRef<str>, replacement: impl Into<String>, ) -> Result<(), InvalidSchemaCoordinate>

Sets an override in the code that this Generator will generate.

The coordinate argument should be set to a valid schema coordinate - note that currently only member coordinates are currently supported by the generator.

§Member Coordinate Behaviour

The field name should have the same casing as the field name in the GraphQL schema (i.e. before conversion to snake_case). Note that the provided type override will still be wrapped in an Option if the field is nullable in the schema.

The replacement type must be a registered custom scalar for the schema scalar type of the overridden field.

Source

pub fn set_overrides<Iter, Coord, Replacement>( &mut self, iter: Iter, ) -> Result<(), InvalidSchemaCoordinate>
where Iter: IntoIterator<Item = (Coord, Replacement)>, Coord: AsRef<str>, Replacement: Into<String>,

Sets many overrides to the code that this Generator will generate.

See Generator::set_override for more details on overrides.

Source

pub fn generate(&self, query: impl AsRef<str>) -> Result<String, Error>

Generates rust code for the provided query

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.