public String print ( GraphQLSchema schema ) { StringWriter sw = new StringWriter ( ) ; PrintWriter out = new PrintWriter ( sw ) ; GraphqlFieldVisibility visibility = schema . getCodeRegistry ( ) . getFieldVisibility ( ) ; printer ( schema . getClass ( ) ) . print ( out , schema , visibility ) ; List < GraphQLType > typesAsList = schema . getAllTypesAsList ( ) . stream ( ) . sorted ( Comparator . comparing ( GraphQLType :: getName ) ) . collect ( toList ( ) ) ; printType ( out , typesAsList , GraphQLInterfaceType . class , visibility ) ; printType ( out , typesAsList , GraphQLUnionType . class , visibility ) ; printType ( out , typesAsList , GraphQLObjectType . class , visibility ) ; printType ( out , typesAsList , GraphQLEnumType . class , visibility ) ; printType ( out , typesAsList , GraphQLScalarType . class , visibility ) ; printType ( out , typesAsList , GraphQLInputObjectType . class , visibility ) ; String result = sw . toString ( ) ; if ( result . endsWith ( "\n\n" ) ) { result = result . substring ( 0 , result . length ( ) - 1 ) ; } return result ; }
This can print an in memory GraphQL schema back to a logical schema definition