rusty_gql/types/
input_object.rs

1use graphql_parser::{schema::InputObjectType as ParserInputObjectType, Pos};
2
3use super::{argument::InputValueType, directive::GqlDirective};
4
5#[derive(Debug, Clone)]
6pub struct InputObjectType {
7    pub name: String,
8    pub description: Option<String>,
9    pub position: Pos,
10    pub directives: Vec<GqlDirective>,
11    pub fields: Vec<InputValueType>,
12}
13
14impl<'a> From<ParserInputObjectType<'a, String>> for InputObjectType {
15    fn from(input_object: ParserInputObjectType<'a, String>) -> Self {
16        let directives = input_object
17            .directives
18            .into_iter()
19            .map(GqlDirective::from)
20            .collect();
21
22        let fields = input_object
23            .fields
24            .into_iter()
25            .map(InputValueType::from)
26            .collect();
27
28        InputObjectType {
29            name: input_object.name,
30            description: input_object.description,
31            position: input_object.position,
32            directives,
33            fields,
34        }
35    }
36}