pub struct Generator { /* private fields */ }Implementations§
Source§impl Generator
impl Generator
pub fn new(schema: impl AsRef<str>) -> Result<Self, SchemaParseError>
Sourcepub fn with_schema_name(self, schema_name: impl Into<String>) -> Self
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.
Sourcepub fn set_schema_name(&mut self, schema_name: impl Into<String>)
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.
Sourcepub fn with_override(
self,
coordinate: impl AsRef<str>,
replacement: impl Into<String>,
) -> Result<Self, InvalidSchemaCoordinate>
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.
Sourcepub fn with_overrides<Iter, Coord, Replacement>(
self,
iter: Iter,
) -> Result<Self, InvalidSchemaCoordinate>where
Iter: IntoIterator<Item = (Coord, Replacement)>,
Coord: AsRef<str>,
Replacement: Into<String>,
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.
Sourcepub fn set_override(
&mut self,
coordinate: impl AsRef<str>,
replacement: impl Into<String>,
) -> Result<(), InvalidSchemaCoordinate>
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.
Sourcepub fn set_overrides<Iter, Coord, Replacement>(
&mut self,
iter: Iter,
) -> Result<(), InvalidSchemaCoordinate>where
Iter: IntoIterator<Item = (Coord, Replacement)>,
Coord: AsRef<str>,
Replacement: Into<String>,
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.