Module: GraphQL::Compatibility::QueryParserSpecification::QueryAssertions

Defined in:
lib/graphql/compatibility/query_parser_specification/query_assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_valid_directive(directive) ⇒ Object


56
57
58
59
60
61
# File 'lib/graphql/compatibility/query_parser_specification/query_assertions.rb', line 56

def assert_valid_directive(directive)
  assert_equal "skip", directive.name
  assert_equal "if", directive.arguments.first.name
  assert_equal 1, directive.arguments.length
  assert_equal [3, 62], directive.position
end

#assert_valid_field(field) ⇒ Object


31
32
33
34
35
36
37
38
# File 'lib/graphql/compatibility/query_parser_specification/query_assertions.rb', line 31

def assert_valid_field(field)
  assert_equal "someField", field.name
  assert_equal "myField", field.alias
  assert_equal 2, field.directives.length
  assert_equal 2, field.arguments.length
  assert_equal 0, field.selections.length
  assert_equal [3, 15], field.position
end

#assert_valid_fragment(fragment_def) ⇒ Object


15
16
17
18
19
20
21
22
# File 'lib/graphql/compatibility/query_parser_specification/query_assertions.rb', line 15

def assert_valid_fragment(fragment_def)
  assert fragment_def.is_a?(GraphQL::Language::Nodes::FragmentDefinition)
  assert_equal "moreNestedFields", fragment_def.name
  assert_equal 1, fragment_def.selections.length
  assert_equal "NestedType", fragment_def.type.name
  assert_equal 1, fragment_def.directives.length
  assert_equal [20, 13], fragment_def.position
end

#assert_valid_fragment_spread(fragment_spread) ⇒ Object


50
51
52
53
54
# File 'lib/graphql/compatibility/query_parser_specification/query_assertions.rb', line 50

def assert_valid_fragment_spread(fragment_spread)
  assert_equal "moreNestedFields", fragment_spread.name
  assert_equal 1, fragment_spread.directives.length
  assert_equal [7, 17], fragment_spread.position
end

#assert_valid_literal_argument(argument) ⇒ Object


40
41
42
43
# File 'lib/graphql/compatibility/query_parser_specification/query_assertions.rb', line 40

def assert_valid_literal_argument(argument)
  assert_equal "ok", argument.name
  assert_equal 1.4, argument.value
end

#assert_valid_query(query) ⇒ Object


5
6
7
8
9
10
11
12
13
# File 'lib/graphql/compatibility/query_parser_specification/query_assertions.rb', line 5

def assert_valid_query(query)
  assert query.is_a?(GraphQL::Language::Nodes::OperationDefinition)
  assert_equal "getStuff", query.name
  assert_equal "query", query.operation_type
  assert_equal 2, query.variables.length
  assert_equal 4, query.selections.length
  assert_equal 1, query.directives.length
  assert_equal [2, 13], [query.line, query.col]
end

#assert_valid_typed_inline_fragment(inline_fragment) ⇒ Object


63
64
65
66
67
68
# File 'lib/graphql/compatibility/query_parser_specification/query_assertions.rb', line 63

def assert_valid_typed_inline_fragment(inline_fragment)
  assert_equal "OtherType", inline_fragment.type.name
  assert_equal 2, inline_fragment.selections.length
  assert_equal 1, inline_fragment.directives.length
  assert_equal [10, 15], inline_fragment.position
end

#assert_valid_typeless_inline_fragment(inline_fragment) ⇒ Object


70
71
72
73
74
# File 'lib/graphql/compatibility/query_parser_specification/query_assertions.rb', line 70

def assert_valid_typeless_inline_fragment(inline_fragment)
  assert_equal nil, inline_fragment.type
  assert_equal 1, inline_fragment.selections.length
  assert_equal 0, inline_fragment.directives.length
end

#assert_valid_variable(variable) ⇒ Object


24
25
26
27
28
29
# File 'lib/graphql/compatibility/query_parser_specification/query_assertions.rb', line 24

def assert_valid_variable(variable)
  assert_equal "someVar", variable.name
  assert_equal "Int", variable.type.name
  assert_equal 1, variable.default_value
  assert_equal [2, 28], variable.position
end

#assert_valid_variable_argument(argument) ⇒ Object


45
46
47
48
# File 'lib/graphql/compatibility/query_parser_specification/query_assertions.rb', line 45

def assert_valid_variable_argument(argument)
  assert_equal "someArg", argument.name
  assert_equal "someVar", argument.value.name
end