@@ -162,59 +162,16 @@ pub fn schema() -> Result<Schema, SchemaError> {
162
162
} )
163
163
. argument ( InputValue :: new ( "id" , TypeRef :: named_nn ( TypeRef :: ID ) ) ) ,
164
164
) ;
165
- let subscription_root = Subscription :: new ( "Subscription" )
166
- // .field(
167
- // SubscriptionField::new(
168
- // "bookMutation",
169
- // TypeRef::named_nn(book_changed.type_name()),
170
- // |ctx| {
171
- // SubscriptionFieldFuture::new(async {
172
- // let mutation_type = match ctx.args.get("mutationType") {
173
- // Some(mutation_type) => Some(match mutation_type.enum_name()? {
174
- // "CREATED" => MutationType::Created,
175
- // "DELETED" => MutationType::Deleted,
176
- // _ => return Err("Invalid mutation type".into()),
177
- // }),
178
- // None => None,
179
- // };
180
- // Ok(
181
- // SimpleBroker::<BookChanged>::subscribe().filter(move |event| {
182
- // let res = if let Some(mutation_type) = mutation_type {
183
- // event.mutation_type == mutation_type
184
- // } else {
185
- // true
186
- // };
187
- // async move { res }
188
- // }),
189
- // )
190
- // })
191
- // },
192
- // )
193
- // .argument(InputValue::new(
194
- // "mutationType",
195
- // TypeRef::named(mutation_type.type_name()),
196
- // )),
197
- // )
198
- . field ( SubscriptionField :: new (
199
- "bookMutation" ,
200
- TypeRef :: named_nn ( book_changed. type_name ( ) ) ,
201
- |ctx| {
202
- let mutation_type: Result < MutationType , _ > = ctx. args . try_get ( "mutation_type" ) . unwrap ( ) . enum_name ( ) . unwrap ( ) . parse ( ) ;
203
-
204
- match mutation_type {
205
- Ok ( mutation_type) => match mutation_type {
206
- MutationType :: Created => println ! ( "Created" ) ,
207
- MutationType :: Deleted => println ! ( "Deleted" )
208
- } ,
209
- Err ( err) => println ! ( "Error: {}" , err) ,
210
- }
211
-
212
- SubscriptionFieldFuture :: new ( async {
213
- Ok ( SimpleBroker :: < BookChanged > :: subscribe ( )
214
- . map ( |book| Ok ( FieldValue :: owned_any ( book) ) ) )
215
- } )
216
- } ,
217
- ) . argument ( InputValue :: new ( "mutation_type" , TypeRef :: named ( mutation_type. type_name ( ) ) ) ) ) ;
165
+ let subscription_root = Subscription :: new ( "Subscription" ) . field ( SubscriptionField :: new (
166
+ "bookMutation" ,
167
+ TypeRef :: named_nn ( book_changed. type_name ( ) ) ,
168
+ |_| {
169
+ SubscriptionFieldFuture :: new ( async {
170
+ Ok ( SimpleBroker :: < BookChanged > :: subscribe ( )
171
+ . map ( |book| Ok ( FieldValue :: owned_any ( book) ) ) )
172
+ } )
173
+ } ,
174
+ ) ) ;
218
175
219
176
Schema :: build (
220
177
query_root. type_name ( ) ,
0 commit comments