@@ -339,6 +339,7 @@ type Object struct {
339
339
PrivateName string `json:"name"`
340
340
PrivateDescription string `json:"description"`
341
341
IsTypeOf IsTypeOfFn
342
+ Subscribe SubscribeFn
342
343
343
344
typeConfig ObjectConfig
344
345
initialisedFields bool
@@ -368,12 +369,15 @@ type IsTypeOfFn func(p IsTypeOfParams) bool
368
369
369
370
type InterfacesThunk func () []* Interface
370
371
372
+ type SubscribeFn func (p ResolveParams ) error
373
+
371
374
type ObjectConfig struct {
372
375
Name string `json:"name"`
373
376
Interfaces interface {} `json:"interfaces"`
374
377
Fields interface {} `json:"fields"`
375
378
IsTypeOf IsTypeOfFn `json:"isTypeOf"`
376
379
Description string `json:"description"`
380
+ Subscribe SubscribeFn `json:"-"`
377
381
}
378
382
379
383
type FieldsThunk func () Fields
@@ -396,6 +400,7 @@ func NewObject(config ObjectConfig) *Object {
396
400
objectType .PrivateDescription = config .Description
397
401
objectType .IsTypeOf = config .IsTypeOf
398
402
objectType .typeConfig = config
403
+ objectType .Subscribe = config .Subscribe
399
404
400
405
return objectType
401
406
}
@@ -535,6 +540,7 @@ func defineFieldMap(ttype Named, fieldMap Fields) (FieldDefinitionMap, error) {
535
540
Type : field .Type ,
536
541
Resolve : field .Resolve ,
537
542
DeprecationReason : field .DeprecationReason ,
543
+ Subscribe : field .Subscribe ,
538
544
}
539
545
540
546
fieldDef .Args = []* Argument {}
@@ -602,10 +608,11 @@ type ResolveInfo struct {
602
608
type Fields map [string ]* Field
603
609
604
610
type Field struct {
605
- Name string `json:"name"` // used by graphlql -relay
611
+ Name string `json:"name"` // used by graphql -relay
606
612
Type Output `json:"type"`
607
613
Args FieldConfigArgument `json:"args"`
608
614
Resolve FieldResolveFn `json:"-"`
615
+ Subscribe SubscribeFn `json:"-"`
609
616
DeprecationReason string `json:"deprecationReason"`
610
617
Description string `json:"description"`
611
618
}
@@ -625,6 +632,7 @@ type FieldDefinition struct {
625
632
Type Output `json:"type"`
626
633
Args []* Argument `json:"args"`
627
634
Resolve FieldResolveFn `json:"-"`
635
+ Subscribe SubscribeFn `json:"-"`
628
636
DeprecationReason string `json:"deprecationReason"`
629
637
}
630
638
0 commit comments