pub enum Type_ {
NonNull {
ty: Box<Type_>,
},
List {
ty: Box<Type_>,
},
NamedType {
name: String,
},
}
Expand description
Convenience Type_ implementation used when creating a Field.
Can be a NamedType
, a NonNull
or a List
.
This enum is resposible for encoding creating values such as String!
, [[[[String]!]!]!]!
, etc.
§Example
use apollo_encoder::{Type_};
let field_ty = Type_::NamedType {
name: "String".to_string(),
};
let list = Type_::List {
ty: Box::new(field_ty),
};
let non_null = Type_::NonNull { ty: Box::new(list) };
assert_eq!(non_null.to_string(), "[String]!");
Variants§
Trait Implementations§
Source§impl TryFrom<ListType> for Type_
impl TryFrom<ListType> for Type_
Source§fn try_from(node: ListType) -> Result<Self, Self::Error>
fn try_from(node: ListType) -> 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.
Source§impl TryFrom<NamedType> for Type_
impl TryFrom<NamedType> for Type_
Source§fn try_from(node: NamedType) -> Result<Self, Self::Error>
fn try_from(node: NamedType) -> 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.
Source§impl TryFrom<NonNullType> for Type_
impl TryFrom<NonNullType> for Type_
Source§fn try_from(node: NonNullType) -> Result<Self, Self::Error>
fn try_from(node: NonNullType) -> 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.
Source§impl TryFrom<Type> for Type_
impl TryFrom<Type> for Type_
Source§fn try_from(node: Type) -> Result<Self, Self::Error>
fn try_from(node: Type) -> 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.