@@ -64,10 +64,10 @@ macro_rules! graphql_input_object {
6464 // Generate the struct declaration, including (Rust) meta attributes
6565 (
6666 @generate_struct_fields,
67- ( $( $meta: tt) * ) , $name: tt,
67+ ( $( $meta: tt) * ) , ( $ ( $pubmod : tt ) * ) , $name: tt,
6868 ( $( $field_name: ident : $field_type: ty $( as $descr: tt) * $( , ) * ) ,* )
6969 ) => {
70- $( $meta) * struct $name {
70+ $( $meta) * $ ( $pubmod ) * struct $name {
7171 $( $field_name: $field_type, ) *
7272 }
7373 } ;
@@ -93,12 +93,26 @@ macro_rules! graphql_input_object {
9393 // struct $name { ... }
9494 (
9595 @parse,
96- ( $_ignore1: tt, $_ignore2: tt, $_ignore3: tt, $_ignore4: tt, $descr: tt ) ,
96+ ( $_ignore1: tt, $_ignore2: tt, $_ignore3: tt, $_ignore4: tt, $_ignore5 : tt , $ descr: tt ) ,
9797 $( #[ $meta: meta] ) * struct $name: ident { $( $fields: tt) * } $( $rest: tt) *
9898 ) => {
9999 graphql_input_object!(
100100 @parse,
101- ( ( $( #[ $meta] ) * ) , $name, ( stringify!( $name) ) , ( $( $fields) * ) , $descr ) ,
101+ ( ( $( #[ $meta] ) * ) , ( ) , $name, ( stringify!( $name) ) , ( $( $fields) * ) , $descr ) ,
102+ $( $rest) *
103+ ) ;
104+ } ;
105+
106+ // #[...] pub struct $name { ... }
107+ // pub struct $name { ... }
108+ (
109+ @parse,
110+ ( $_ignore1: tt, $_ignore2: tt, $_ignore3: tt, $_ignore4: tt, $_ignore5: tt, $descr: tt ) ,
111+ $( #[ $meta: meta] ) * pub struct $name: ident { $( $fields: tt) * } $( $rest: tt) *
112+ ) => {
113+ graphql_input_object!(
114+ @parse,
115+ ( ( $( #[ $meta] ) * ) , ( pub ) , $name, ( stringify!( $name) ) , ( $( $fields) * ) , $descr ) ,
102116 $( $rest) *
103117 ) ;
104118 } ;
@@ -107,35 +121,49 @@ macro_rules! graphql_input_object {
107121 // struct $name as "GraphQLName" { ... }
108122 (
109123 @parse,
110- ( $_ignore1: tt, $_ignore2: tt, $_ignore3: tt, $_ignore4: tt, $descr: tt ) ,
124+ ( $_ignore1: tt, $_ignore2: tt, $_ignore3: tt, $_ignore4: tt, $_ignore5 : tt , $ descr: tt ) ,
111125 $( #[ $meta: meta] ) * struct $name: ident as $outname: tt { $( $fields: tt) * } $( $rest: tt) *
112126 ) => {
113127 graphql_input_object!(
114128 @parse,
115- ( ( $( $meta) * ) , $name, $outname, ( $( $fields) * ) , $descr ) ,
129+ ( ( $( $meta) * ) , ( ) , $name, $outname, ( $( $fields) * ) , $descr ) ,
130+ $( $rest) *
131+ ) ;
132+ } ;
133+
134+ // #[...] pub struct $name as "GraphQLName" { ... }
135+ // pub struct $name as "GraphQLName" { ... }
136+ (
137+ @parse,
138+ ( $_ignore1: tt, $_ignore2: tt, $_ignore3: tt, $_ignore4: tt, $_ignore5: tt, $descr: tt ) ,
139+ $( #[ $meta: meta] ) * pub struct $name: ident as $outname: tt { $( $fields: tt) * } $( $rest: tt) *
140+ ) => {
141+ graphql_input_object!(
142+ @parse,
143+ ( ( $( $meta) * ) , ( pub ) , $name, $outname, ( $( $fields) * ) , $descr ) ,
116144 $( $rest) *
117145 ) ;
118146 } ;
119147
120148 // description: <description>
121149 (
122150 @parse,
123- ( $meta: tt, $name: tt, $outname: tt, $fields: tt, $_ignore: tt ) ,
151+ ( $meta: tt, $pubmod : tt , $ name: tt, $outname: tt, $fields: tt, $_ignore: tt ) ,
124152 description: $descr: tt $( $rest: tt) *
125153 ) => {
126154 graphql_input_object!(
127155 @parse,
128- ( $meta, $name, $outname, $fields, $descr ) ,
156+ ( $meta, $pubmod , $ name, $outname, $fields, $descr ) ,
129157 $( $rest) *
130158 ) ;
131159 } ;
132160
133161 // No more data to parse, generate the struct and impls
134162 (
135163 @parse,
136- ( $meta: tt, $name: tt, $outname: tt, $fields: tt, $descr: tt ) ,
164+ ( $meta: tt, $pubmod : tt , $ name: tt, $outname: tt, $fields: tt, $descr: tt ) ,
137165 ) => {
138- graphql_input_object!( @generate_struct_fields, $meta, $name, $fields) ;
166+ graphql_input_object!( @generate_struct_fields, $meta, $pubmod , $ name, $fields) ;
139167
140168 impl $crate:: FromInputValue for $name {
141169 fn from( value: & $crate:: InputValue ) -> Option <$name> {
@@ -164,20 +192,29 @@ macro_rules! graphql_input_object {
164192 }
165193 } ;
166194
167- // Entry point: parse calls starting with the struct declaration
195+ // Entry point: parse calls starting with a struct declaration
168196 ( $( #[ $meta: meta] ) * struct $( $items: tt) * ) => {
169197 graphql_input_object!(
170198 @parse,
171- ( ( ) , None , None , None , None ) ,
199+ ( ( ) , ( ) , None , None , None , None ) ,
172200 $( #[ $meta] ) * struct $( $items) *
173201 ) ;
174202 } ;
175203
204+ // Entry point: parse calls starting with a public struct declaration
205+ ( $( #[ $meta: meta] ) * pub struct $( $items: tt) * ) => {
206+ graphql_input_object!(
207+ @parse,
208+ ( ( ) , ( ) , None , None , None , None ) ,
209+ $( #[ $meta] ) * pub struct $( $items) *
210+ ) ;
211+ } ;
212+
176213 // Entry point: parse calls starting with the description
177214 ( description: $( $items: tt) * ) => {
178215 graphql_input_object!(
179216 @parse,
180- ( ( ) , None , None , None , None ) ,
217+ ( ( ) , ( ) , None , None , None , None ) ,
181218 description: $( $items) *
182219 ) ;
183220 } ;
0 commit comments