class OpticsAgent::Reporting::Schema
A report for a whole schema
Attributes
message[RW]
Public Class Methods
new(schema)
click to toggle source
# File lib/optics-agent/reporting/schema.rb, line 17 def initialize(schema) @message = SchemaReport.new({ header: generate_report_header(), introspection_result: JSON.generate(introspect_schema(schema)), type: get_types(schema) }) end
Public Instance Methods
get_types(schema)
click to toggle source
construct an array of Type (protobuf) objects
# File lib/optics-agent/reporting/schema.rb, line 26 def get_types(schema) types = [] schema.types.keys.each do |type_name| next if type_name =~ /^__/ type = schema.types[type_name] next unless type.is_a? GraphQL::ObjectType fields = type.all_fields.map do |field| Field.new({ name: field.name, # XXX: does this actually work for all types? returnType: field.type.to_s }) end types << Type.new({ name: type_name, field: fields }) end types end
send_with(agent)
click to toggle source
# File lib/optics-agent/reporting/schema.rb, line 51 def send_with(agent) agent.send_message('/api/ss/schema', @message) end