Skip to content

Commit

Permalink
Skip introspection types during auto-generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoahero committed Jan 17, 2024
1 parent 295f0e2 commit 23d92d8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion codegen/lib/graphql_java_gen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion codegen/lib/graphql_java_gen/templates/APISchema.java.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 23d92d8

Please sign in to comment.