3030import com .intellij .lang .jsgraphql .types .schema .idl .SchemaParser ;
3131import com .intellij .lang .jsgraphql .types .schema .idl .SchemaPrinter ;
3232import com .intellij .lang .jsgraphql .types .schema .idl .UnExecutableSchemaGenerator ;
33+ import com .intellij .lang .jsgraphql .types .schema .idl .errors .SchemaProblem ;
3334import com .intellij .lang .jsgraphql .types .util .EscapeUtil ;
3435import com .intellij .lang .jsgraphql .v1 .ide .project .JSGraphQLLanguageUIProjectService ;
3536import com .intellij .notification .Notification ;
@@ -267,9 +268,11 @@ public String printIntrospectionAsGraphQL(@NotNull Map<String, Object> introspec
267268 );
268269
269270 if (schemaInfo .hasErrors ()) {
270- for (GraphQLError error : schemaInfo .getErrors ()) {
271+ List <GraphQLError > errors = schemaInfo .getErrors ();
272+ for (GraphQLError error : errors ) {
271273 LOG .warn (error .getMessage ());
272274 }
275+ throw new SchemaProblem (errors );
273276 }
274277
275278 final StringBuilder sb = new StringBuilder (new SchemaPrinter (options ).print (schemaInfo .getSchema ()));
@@ -295,7 +298,12 @@ public String printIntrospectionAsGraphQL(@NotNull Map<String, Object> introspec
295298 }
296299 }
297300 }
298- return sb .toString ();
301+
302+ String sdl = sb .toString ();
303+ if (LOG .isDebugEnabled ()) {
304+ LOG .debug (sdl );
305+ }
306+ return sdl ;
299307 }
300308
301309 @ SuppressWarnings ("unchecked" )
@@ -396,13 +404,13 @@ void createOrUpdateIntrospectionOutputFile(@NotNull String schemaText,
396404 CodeStyleManager .getInstance (myProject ).reformat (psiFile );
397405 }
398406 });
399- } catch (IOException ioe ) {
400- LOG .info (ioe );
407+ } catch (IOException e ) {
408+ LOG .info (e );
401409 Notifications .Bus .notify (new Notification (
402410 GraphQLNotificationUtil .NOTIFICATION_GROUP_ID ,
403411 GraphQLBundle .message ("graphql.notification.error.title" ),
404412 GraphQLBundle .message ("graphql.notification.unable.to.create.file" ,
405- outputFileName , introspectionSourceFile .getParent ().getPath (), GraphQLNotificationUtil .formatExceptionMessage (ioe )),
413+ outputFileName , introspectionSourceFile .getParent ().getPath (), GraphQLNotificationUtil .formatExceptionMessage (e )),
406414 NotificationType .ERROR
407415 ));
408416 }
0 commit comments