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



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

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



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

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



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

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



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

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



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

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

#assert_valid_query(query) ⇒ Object



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

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



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

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



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

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



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

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



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

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