@@ -80,7 +80,7 @@ public boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType) {
8080 }
8181
8282 @ Override
83- public GraphQLType buildType (String typeName , Class <?> aClass , AnnotatedType annotatedType ) {
83+ public GraphQLType buildType (boolean inputType , Class <?> aClass , AnnotatedType annotatedType ) {
8484 return Scalars .GraphQLString ;
8585 }
8686 }
@@ -98,7 +98,7 @@ public boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType) {
9898 }
9999
100100 @ Override
101- public GraphQLType buildType (String typeName , Class <?> aClass , AnnotatedType annotatedType ) {
101+ public GraphQLType buildType (boolean inputType , Class <?> aClass , AnnotatedType annotatedType ) {
102102 return Scalars .GraphQLBoolean ;
103103 }
104104 }
@@ -116,7 +116,7 @@ public boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType) {
116116 }
117117
118118 @ Override
119- public GraphQLType buildType (String typeName , Class <?> aClass , AnnotatedType annotatedType ) {
119+ public GraphQLType buildType (boolean inputType , Class <?> aClass , AnnotatedType annotatedType ) {
120120 return Scalars .GraphQLFloat ;
121121 }
122122 }
@@ -134,7 +134,7 @@ public boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType) {
134134 }
135135
136136 @ Override
137- public GraphQLType buildType (String typeName , Class <?> aClass , AnnotatedType annotatedType ) {
137+ public GraphQLType buildType (boolean inputType , Class <?> aClass , AnnotatedType annotatedType ) {
138138 return Scalars .GraphQLInt ;
139139 }
140140 }
@@ -152,7 +152,7 @@ public boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType) {
152152 }
153153
154154 @ Override
155- public GraphQLType buildType (String typeName , Class <?> aClass , AnnotatedType annotatedType ) {
155+ public GraphQLType buildType (boolean inputType , Class <?> aClass , AnnotatedType annotatedType ) {
156156 return Scalars .GraphQLLong ;
157157 }
158158 }
@@ -168,7 +168,7 @@ public boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType) {
168168 }
169169
170170 @ Override
171- public GraphQLType buildType (String typeName , Class <?> aClass , AnnotatedType annotatedType ) {
171+ public GraphQLType buildType (boolean inputType , Class <?> aClass , AnnotatedType annotatedType ) {
172172 if (!(annotatedType instanceof AnnotatedParameterizedType )) {
173173 throw new IllegalArgumentException ("List type parameter should be specified" );
174174 }
@@ -180,7 +180,7 @@ public GraphQLType buildType(String typeName, Class<?> aClass, AnnotatedType ann
180180 } else {
181181 klass = (Class <?>) arg .getType ();
182182 }
183- return new GraphQLList (DefaultTypeFunction .this .buildType (klass , arg ));
183+ return new GraphQLList (DefaultTypeFunction .this .buildType (inputType , klass , arg ));
184184 }
185185 }
186186
@@ -192,7 +192,7 @@ public boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType) {
192192 }
193193
194194 @ Override
195- public GraphQLType buildType (String typeName , Class <?> aClass , AnnotatedType annotatedType ) {
195+ public GraphQLType buildType (boolean inputType , Class <?> aClass , AnnotatedType annotatedType ) {
196196 if (!(annotatedType instanceof AnnotatedParameterizedType )) {
197197 throw new IllegalArgumentException ("Stream type parameter should be specified" );
198198 }
@@ -204,7 +204,7 @@ public GraphQLType buildType(String typeName, Class<?> aClass, AnnotatedType ann
204204 } else {
205205 klass = (Class <?>) arg .getType ();
206206 }
207- return new GraphQLList (DefaultTypeFunction .this .buildType (klass , arg ));
207+ return new GraphQLList (DefaultTypeFunction .this .buildType (inputType , klass , arg ));
208208 }
209209 }
210210
@@ -222,9 +222,9 @@ public String getTypeName(Class<?> aClass, AnnotatedType annotatedType) {
222222 }
223223
224224 @ Override
225- public GraphQLType buildType (String typeName , Class <?> aClass , AnnotatedType annotatedType ) {
225+ public GraphQLType buildType (boolean inputType , Class <?> aClass , AnnotatedType annotatedType ) {
226226 AnnotatedType arg = getAnnotatedType (annotatedType );
227- return DefaultTypeFunction .this .buildType (typeName , getClass (annotatedType ), arg );
227+ return DefaultTypeFunction .this .buildType (inputType , getClass (annotatedType ), arg );
228228 }
229229
230230 private AnnotatedType getAnnotatedType (AnnotatedType annotatedType ) {
@@ -259,12 +259,11 @@ public boolean canBuildType(Class<?> aClass, AnnotatedType annotatedType) {
259259 }
260260
261261 @ Override
262- public GraphQLType buildType (String typeName , Class <?> aClass , AnnotatedType annotatedType ) {
263- try {
264- return annotationsProcessor .getOutputTypeOrRef (aClass );
265- } catch (ClassCastException e ) {
266- // Also try to resolve to input object
262+ public GraphQLType buildType (boolean inputType , Class <?> aClass , AnnotatedType annotatedType ) {
263+ if (inputType ) {
267264 return annotationsProcessor .getInputObject (aClass );
265+ } else {
266+ return annotationsProcessor .getOutputTypeOrRef (aClass );
268267 }
269268 }
270269 }
@@ -322,13 +321,13 @@ public String getTypeName(Class<?> aClass, AnnotatedType annotatedType) {
322321 }
323322
324323 @ Override
325- public GraphQLType buildType (String typeName , Class <?> aClass , AnnotatedType annotatedType ) {
324+ public GraphQLType buildType (boolean inputType , Class <?> aClass , AnnotatedType annotatedType ) {
326325 TypeFunction typeFunction = getTypeFunction (aClass , annotatedType );
327326 if (typeFunction == null ) {
328327 throw new IllegalArgumentException ("unsupported type" );
329328 }
330329
331- GraphQLType result = typeFunction .buildType (typeName , aClass , annotatedType );
330+ GraphQLType result = typeFunction .buildType (inputType , aClass , annotatedType );
332331 if (aClass .getAnnotation (GraphQLNonNull .class ) != null ||
333332 (annotatedType != null && annotatedType .getAnnotation (GraphQLNonNull .class ) != null )) {
334333 result = new graphql .schema .GraphQLNonNull (result );
0 commit comments