@@ -112,17 +112,25 @@ def self.resolve_type(object, ctx)
112112 end
113113
114114 class Query < GraphQL ::Schema ::Object
115- field :boxed_union , BoxedUnion
115+ field :boxed_union , BoxedUnion , resolve_static : true
116116
117- def boxed_union
117+ def self . boxed_union ( context )
118118 Box . new ( context [ :value ] )
119119 end
120120
121- field :unboxed_union , UnboxedUnion
121+ def boxed_union
122+ self . class . boxed_union ( context )
123+ end
124+
125+ field :unboxed_union , UnboxedUnion , resolve_static : true
122126
123- def unboxed_union
127+ def self . unboxed_union ( context )
124128 context [ :value ]
125129 end
130+
131+ def unboxed_union
132+ self . class . unboxed_union ( context )
133+ end
126134 end
127135
128136 query ( Query )
@@ -410,29 +418,33 @@ def unboxed_union
410418 describe "use with loads:" do
411419 class UnionLoadsSchema < GraphQL ::Schema
412420 class Image < GraphQL ::Schema ::Object
413- field :title , String
421+ field :title , String , hash_key : :title
414422 end
415423
416424 class Video < GraphQL ::Schema ::Object
417- field :title , String
425+ field :title , String , hash_key : :title
418426 end
419427
420428 class Post < GraphQL ::Schema ::Object
421- field :title , String
429+ field :title , String , hash_key : :title
422430 end
423431
424432 class MediaItem < GraphQL ::Schema ::Union
425433 possible_types Image , Video
426434 end
427435
428436 class Query < GraphQL ::Schema ::Object
429- field :media_item_type , String do
437+ field :media_item_type , String , resolve_static : true do
430438 argument :id , ID , loads : MediaItem , as : :media_item
431439 end
432440
433- def media_item_type ( media_item :)
441+ def self . media_item_type ( context , media_item :)
434442 media_item [ :type ]
435443 end
444+
445+ def media_item_type ( media_item :)
446+ self . class . media_item_type ( context , media_item : media_item )
447+ end
436448 end
437449
438450 query ( Query )
0 commit comments