@@ -64,10 +64,10 @@ macro_rules! graphql_input_object {
64
64
// Generate the struct declaration, including (Rust) meta attributes
65
65
(
66
66
@generate_struct_fields,
67
- ( $( $meta: tt) * ) , $name: tt,
67
+ ( $( $meta: tt) * ) , ( $ ( $pubmod : tt ) * ) , $name: tt,
68
68
( $( $field_name: ident : $field_type: ty $( as $descr: tt) * $( , ) * ) ,* )
69
69
) => {
70
- $( $meta) * struct $name {
70
+ $( $meta) * $ ( $pubmod ) * struct $name {
71
71
$( $field_name: $field_type, ) *
72
72
}
73
73
} ;
@@ -93,12 +93,26 @@ macro_rules! graphql_input_object {
93
93
// struct $name { ... }
94
94
(
95
95
@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 ) ,
97
97
$( #[ $meta: meta] ) * struct $name: ident { $( $fields: tt) * } $( $rest: tt) *
98
98
) => {
99
99
graphql_input_object!(
100
100
@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 ) ,
102
116
$( $rest) *
103
117
) ;
104
118
} ;
@@ -107,35 +121,49 @@ macro_rules! graphql_input_object {
107
121
// struct $name as "GraphQLName" { ... }
108
122
(
109
123
@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 ) ,
111
125
$( #[ $meta: meta] ) * struct $name: ident as $outname: tt { $( $fields: tt) * } $( $rest: tt) *
112
126
) => {
113
127
graphql_input_object!(
114
128
@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 ) ,
116
144
$( $rest) *
117
145
) ;
118
146
} ;
119
147
120
148
// description: <description>
121
149
(
122
150
@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 ) ,
124
152
description: $descr: tt $( $rest: tt) *
125
153
) => {
126
154
graphql_input_object!(
127
155
@parse,
128
- ( $meta, $name, $outname, $fields, $descr ) ,
156
+ ( $meta, $pubmod , $ name, $outname, $fields, $descr ) ,
129
157
$( $rest) *
130
158
) ;
131
159
} ;
132
160
133
161
// No more data to parse, generate the struct and impls
134
162
(
135
163
@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 ) ,
137
165
) => {
138
- graphql_input_object!( @generate_struct_fields, $meta, $name, $fields) ;
166
+ graphql_input_object!( @generate_struct_fields, $meta, $pubmod , $ name, $fields) ;
139
167
140
168
impl $crate:: FromInputValue for $name {
141
169
fn from( value: & $crate:: InputValue ) -> Option <$name> {
@@ -164,20 +192,29 @@ macro_rules! graphql_input_object {
164
192
}
165
193
} ;
166
194
167
- // Entry point: parse calls starting with the struct declaration
195
+ // Entry point: parse calls starting with a struct declaration
168
196
( $( #[ $meta: meta] ) * struct $( $items: tt) * ) => {
169
197
graphql_input_object!(
170
198
@parse,
171
- ( ( ) , None , None , None , None ) ,
199
+ ( ( ) , ( ) , None , None , None , None ) ,
172
200
$( #[ $meta] ) * struct $( $items) *
173
201
) ;
174
202
} ;
175
203
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
+
176
213
// Entry point: parse calls starting with the description
177
214
( description: $( $items: tt) * ) => {
178
215
graphql_input_object!(
179
216
@parse,
180
- ( ( ) , None , None , None , None ) ,
217
+ ( ( ) , ( ) , None , None , None , None ) ,
181
218
description: $( $items) *
182
219
) ;
183
220
} ;
0 commit comments