Class: Generator::GraphqlTypeExtractor
- Inherits:
-
Object
- Object
- Generator::GraphqlTypeExtractor
- Defined in:
- lib/generator/parsers/graphql_type_extractor.rb
Overview
Extracts nested type definitions from GraphQL schemas Converts GraphQL type system to OpenAPI-style definitions for Type generation
Instance Attribute Summary collapse
-
#graphql_schema ⇒ Object
readonly
Returns the value of attribute graphql_schema.
-
#schema_name ⇒ Object
readonly
Returns the value of attribute schema_name.
Instance Method Summary collapse
-
#extract_types ⇒ Object
Extract all types from GraphQL schema Returns hash of type_name => definition (OpenAPI-style).
-
#initialize(graphql_schema, schema_name) ⇒ GraphqlTypeExtractor
constructor
A new instance of GraphqlTypeExtractor.
Constructor Details
#initialize(graphql_schema, schema_name) ⇒ GraphqlTypeExtractor
Returns a new instance of GraphqlTypeExtractor.
14 15 16 17 18 |
# File 'lib/generator/parsers/graphql_type_extractor.rb', line 14 def initialize(graphql_schema, schema_name) @graphql_schema = graphql_schema @schema_name = schema_name @extracted_types = {} end |
Instance Attribute Details
#graphql_schema ⇒ Object (readonly)
Returns the value of attribute graphql_schema.
12 13 14 |
# File 'lib/generator/parsers/graphql_type_extractor.rb', line 12 def graphql_schema @graphql_schema end |
#schema_name ⇒ Object (readonly)
Returns the value of attribute schema_name.
12 13 14 |
# File 'lib/generator/parsers/graphql_type_extractor.rb', line 12 def schema_name @schema_name end |
Instance Method Details
#extract_types ⇒ Object
Extract all types from GraphQL schema Returns hash of type_name => definition (OpenAPI-style)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/generator/parsers/graphql_type_extractor.rb', line 22 def extract_types graphql_schema.types.each do |type_name, type_obj| # Skip built-in GraphQL types next if type_name.start_with?("__") next if BUILTIN_TYPES.include?(type_name) # Skip root query types (e.g., Analytics_SalesAndTraffic_2024_04_24) next if type_obj == graphql_schema.query # Skip enums (handle separately if needed in the future) next if type_obj.kind.enum? # Extract object types only if type_obj.kind.object? @extracted_types[type_name] = convert_graphql_type_to_definition(type_obj) end end @extracted_types end |