77require 'set'
88
99class GraphQLJavaGen
10- attr_reader :schema , :package_name , :scalars , :imports , :script_name , :schema_name , :include_deprecated
10+ attr_reader :schema , :package_name , :scalars , :imports , :script_name , :schema_name , :include_deprecated , :version
1111
1212 def initialize ( schema ,
1313 package_name :, nest_under :, script_name : 'graphql_java_gen gem' ,
14- custom_scalars : [ ] , custom_annotations : [ ] , include_deprecated : false
14+ custom_scalars : [ ] , custom_annotations : [ ] , include_deprecated : false , version : ''
1515 )
1616 @schema = schema
1717 @schema_name = nest_under
@@ -22,13 +22,15 @@ def initialize(schema,
2222 @annotations = custom_annotations
2323 @imports = ( @scalars . values . map ( &:imports ) + @annotations . map ( &:imports ) ) . flatten . sort . uniq
2424 @include_deprecated = include_deprecated
25+ @version = version
2526 end
2627
2728 def save ( path )
2829 File . write ( path , generate )
2930 end
3031
3132 def save_granular ( path )
33+ write_schema ( path )
3234 write_static_methods ( path )
3335 write_response ( path , :query , schema . query_root_name )
3436 write_response ( path , :mutation , schema . mutation_root_name )
@@ -66,6 +68,10 @@ def generate_entity(template, type)
6668 reformat ( erb_template . result ( binding ) )
6769 end
6870
71+ def write_schema ( path )
72+ File . write ( path + "/Schema.java" , reformat ( erb_for_entity ( "Schema.java" ) . result ( binding ) ) )
73+ end
74+
6975 def write_static_methods ( path )
7076 File . write ( path + "/Operations.java" , reformat ( erb_for_entity ( "Operations.java" ) . result ( binding ) ) )
7177 end
0 commit comments