diff --git a/codegen/lib/graphql_java_gen.rb b/codegen/lib/graphql_java_gen.rb index ca637ef..dd91187 100644 --- a/codegen/lib/graphql_java_gen.rb +++ b/codegen/lib/graphql_java_gen.rb @@ -83,7 +83,7 @@ def write_response(path, query, root_name) end def write_entities(path) - schema.types.reject{ |type| type.name.start_with?('__') || type.scalar? }.each do |type| + schema.types.reject{ |type| skip_type?(type) }.each do |type| case type.kind when 'OBJECT', 'INTERFACE', 'UNION' File.write(path + "/#{type.name}QueryDefinition.java", generate_entity("QueryDefinition.java", type)) File.write(path + "/#{type.name}Query.java", generate_entity("Query.java", type)) @@ -146,11 +146,22 @@ def write_entities(path) ] private_constant :RESERVED_WORDS + def escape_reserved_word(word) return word unless RESERVED_WORDS.include?(word) "#{word}Value" end + INTROSPECTION_TYPES = [ + "InContextAnnotation", + "InContextAnnotationType" + ] + private_constant :INTROSPECTION_TYPES + + def skip_type?(type) + type.name.start_with?('__') || type.scalar? || INTROSPECTION_TYPES.include?(type.name) + end + def reformat(code) Reformatter.new(indent: " " * 4).reformat(code) end diff --git a/codegen/lib/graphql_java_gen/templates/APISchema.java.erb b/codegen/lib/graphql_java_gen/templates/APISchema.java.erb index c4d2c71..00c01fa 100644 --- a/codegen/lib/graphql_java_gen/templates/APISchema.java.erb +++ b/codegen/lib/graphql_java_gen/templates/APISchema.java.erb @@ -107,7 +107,7 @@ public class <%= schema_name %> { } <% end %> - <% schema.types.reject{ |type| type.name.start_with?('__') || type.scalar? }.each do |type| %> + <% schema.types.reject{ |type| skip_type?(type) }.each do |type| %> <% case type.kind when 'OBJECT', 'INTERFACE', 'UNION' %> <% fields = type.fields(include_deprecated: include_deprecated) || [] %> public interface <%= type.name %>QueryDefinition {