module GraphQL::StaticValidation::FragmentTypesExist
Public Instance Methods
on_fragment_definition(node, _parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/rules/fragment_types_exist.rb, line 5 def on_fragment_definition(node, _parent) if validate_type_exists(node) super end end
on_inline_fragment(node, _parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/rules/fragment_types_exist.rb, line 11 def on_inline_fragment(node, _parent) if validate_type_exists(node) super end end
Private Instance Methods
validate_type_exists(fragment_node)
click to toggle source
# File lib/graphql/static_validation/rules/fragment_types_exist.rb, line 19 def validate_type_exists(fragment_node) if !fragment_node.type true else type_name = fragment_node.type.name type = context.warden.get_type(type_name) if type.nil? add_error(GraphQL::StaticValidation::FragmentTypesExistError.new( "No such type #{type_name}, so it can't be a fragment condition", nodes: fragment_node, type: type_name )) false else true end end end