module GraphQL::StaticValidation::FragmentsAreOnCompositeTypes
Public Instance Methods
on_fragment_definition(node, parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb, line 5 def on_fragment_definition(node, parent) validate_type_is_composite(node) && super end
on_inline_fragment(node, parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb, line 9 def on_inline_fragment(node, parent) validate_type_is_composite(node) && super end
Private Instance Methods
validate_type_is_composite(node)
click to toggle source
# File lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb, line 15 def validate_type_is_composite(node) node_type = node.type if node_type.nil? # Inline fragment on the same type true else type_name = node_type.to_query_string type_def = context.warden.get_type(type_name) if type_def.nil? || !type_def.kind.composite? add_error(GraphQL::StaticValidation::FragmentsAreOnCompositeTypesError.new( "Invalid fragment on type #{type_name} (must be Union, Interface or Object)", nodes: node, type: type_name )) false else true end end end