Class: GraphQL::Language::FragmentDefinition

Inherits:
Struct
  • Object
show all
Defined in:
lib/graphql/language/fragment_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#directivesObject

Returns the value of attribute directives

Returns:

  • (Object)

    the current value of directives



3
4
5
# File 'lib/graphql/language/fragment_definition.rb', line 3

def directives
  @directives
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/graphql/language/fragment_definition.rb', line 3

def name
  @name
end

#selection_setObject

Returns the value of attribute selection_set

Returns:

  • (Object)

    the current value of selection_set



3
4
5
# File 'lib/graphql/language/fragment_definition.rb', line 3

def selection_set
  @selection_set
end

#type_conditionObject

Returns the value of attribute type_condition

Returns:

  • (Object)

    the current value of type_condition



3
4
5
# File 'lib/graphql/language/fragment_definition.rb', line 3

def type_condition
  @type_condition
end

Instance Method Details

#apply?(context, object_type) ⇒ Boolean

GraphQL Specification

6.3 Evaluating selection sets
  doesFragmentTypeApply implementation
    objectType, fragmentType = self.type_condition => Schema.type
      + context[schema, document]

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
# File 'lib/graphql/language/fragment_definition.rb', line 11

def apply?(context, object_type)
  type = context[:schema].type(type_condition.type)

  return type == object_type if type.is_a?(GraphQLObjectType)

  return type.possible_type?(object_type) if type.is_a?(GraphQLInterfaceType)

  return type.possible_type?(object_type) if type.is_a?(GraphQLUnionType)
end