22
33module Schemas
44 module Arguments
5- class StitchingResolver < GraphQL ::Schema ::Directive
6- graphql_name "stitch"
7- locations FIELD_DEFINITION
8- argument :key , String , required : true
9- argument :arguments , String , required : false
10- repeatable true
11- end
12-
135 DIRECTORS = [
146 { id : "1" , name : "Steven Spielberg" } ,
157 { id : "2" , name : "Christopher Nolan" } ,
@@ -78,7 +70,7 @@ class Movie < GraphQL::Schema::Object
7870
7971 class Query < GraphQL ::Schema ::Object
8072 field :movies , [ Movie , null : true ] , null : false do
81- directive StitchingResolver , key : "id"
73+ directive GraphQL :: Stitching :: Directives :: Stitch , key : "id"
8274 argument :ids , [ ID ] , required : true
8375 end
8476
@@ -133,7 +125,7 @@ class ScalarKey < GraphQL::Schema::Scalar
133125
134126 class Query < GraphQL ::Schema ::Object
135127 field :movies2 , [ Movie , null : true ] , null : false do
136- directive StitchingResolver , key : "id" , arguments : "ids: $.id, status: STREAMING"
128+ directive GraphQL :: Stitching :: Directives :: Stitch , key : "id" , arguments : "ids: $.id, status: STREAMING"
137129 argument :ids , [ ID ] , required : true
138130 argument :status , MovieStatus , required : true
139131 end
@@ -144,7 +136,7 @@ def movies2(ids:, status: nil)
144136 end
145137
146138 field :director , Director , null : false do
147- directive StitchingResolver , key : "id" , arguments : "key: { subkey: { id: $.id } }"
139+ directive GraphQL :: Stitching :: Directives :: Stitch , key : "id" , arguments : "key: { subkey: { id: $.id } }"
148140 argument :key , ComplexKey , required : true
149141 end
150142
@@ -153,7 +145,7 @@ def director(key:)
153145 end
154146
155147 field :studios , [ Studio , null : true ] , null : false do
156- directive StitchingResolver , key : "id" , arguments : "keys: { subkey: { id: $.id } }"
148+ directive GraphQL :: Stitching :: Directives :: Stitch , key : "id" , arguments : "keys: { subkey: { id: $.id } }"
157149 argument :keys , [ ScalarKey ] , required : true
158150 end
159151
@@ -162,7 +154,7 @@ def studios(keys:)
162154 end
163155
164156 field :genres , [ Genre , null : true ] , null : false do
165- directive StitchingResolver , key : "id" , arguments : "keys: $.id, prefix: 'action'"
157+ directive GraphQL :: Stitching :: Directives :: Stitch , key : "id" , arguments : "keys: $.id, prefix: 'action'"
166158 argument :keys , [ ID ] , required : true
167159 argument :prefix , String , required : false
168160 end
0 commit comments