graphql 1.7.9 → 1.7.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -82,8 +82,7 @@ rule
82
82
  | EQUALS literal_value { return val[1] }
83
83
 
84
84
  selection_set:
85
- LCURLY RCURLY { return [] }
86
- | LCURLY selection_list RCURLY { return val[1] }
85
+ LCURLY selection_list RCURLY { return val[1] }
87
86
 
88
87
  selection_set_opt:
89
88
  /* none */ { return [] }
@@ -154,8 +154,8 @@ module GraphQL
154
154
  def print_object_type_definition(object_type)
155
155
  out = print_description(object_type)
156
156
  out << "type #{object_type.name}"
157
- out << print_directives(object_type.directives)
158
157
  out << " implements " << object_type.interfaces.map(&:name).join(", ") unless object_type.interfaces.empty?
158
+ out << print_directives(object_type.directives)
159
159
  out << print_field_definitions(object_type.fields)
160
160
  end
161
161
 
@@ -24,7 +24,11 @@ module GraphQL
24
24
  msg = if resolved_type.nil?
25
25
  nil
26
26
  elsif resolved_type.kind.scalar? && ast_node.selections.any?
27
- "Selections can't be made on scalars (%{node_name} returns #{resolved_type.name} but has selections [#{ast_node.selections.map(&:name).join(", ")}])"
27
+ if ast_node.selections.first.is_a?(GraphQL::Language::Nodes::InlineFragment)
28
+ "Selections can't be made on scalars (%{node_name} returns #{resolved_type.name} but has inline fragments [#{ast_node.selections.map(&:type).map(&:name).join(", ")}])"
29
+ else
30
+ "Selections can't be made on scalars (%{node_name} returns #{resolved_type.name} but has selections [#{ast_node.selections.map(&:name).join(", ")}])"
31
+ end
28
32
  elsif resolved_type.kind.object? && ast_node.selections.none?
29
33
  "Objects must have selections (%{node_name} returns #{resolved_type.name} but has no selections)"
30
34
  else
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.7.9"
3
+ VERSION = "1.7.10"
4
4
  end
@@ -105,7 +105,7 @@ describe GraphQL::Language::Printer do
105
105
  end
106
106
 
107
107
  describe "full featured schema" do
108
- # From: https://github.com/graphql/graphql-js/blob/bc96406ab44453a120da25a0bd6e2b0237119ddf/src/language/__tests__/schema-kitchen-sink.graphql
108
+ # Based on: https://github.com/graphql/graphql-js/blob/bc96406ab44453a120da25a0bd6e2b0237119ddf/src/language/__tests__/schema-kitchen-sink.graphql
109
109
  let(:query_string) {<<-schema
110
110
  schema {
111
111
  query: QueryType
@@ -128,7 +128,7 @@ describe GraphQL::Language::Printer do
128
128
  # Scalar description
129
129
  scalar CustomScalar
130
130
 
131
- type AnnotatedObject @onObject(arg: "value") {
131
+ type AnnotatedObject implements Bar @onObject(arg: "value") {
132
132
  annotatedField(arg: Type = "default" @onArg): Type @onField
133
133
  }
134
134
 
@@ -8,18 +8,19 @@ describe GraphQL::StaticValidation::FieldsHaveAppropriateSelections do
8
8
  okCheese: cheese(id: 1) { fatContent, similarCheese(source: YAK) { source } }
9
9
  missingFieldsCheese: cheese(id: 1)
10
10
  illegalSelectionCheese: cheese(id: 1) { id { something, ... someFields } }
11
+ incorrectFragmentSpread: cheese(id: 1) { flavor { ... on String { __typename } } }
11
12
  }
12
13
  "}
13
14
 
14
15
  it "adds errors for selections on scalars" do
15
- assert_equal(2, errors.length)
16
+ assert_equal(3, errors.length)
16
17
 
17
18
  illegal_selection_error = {
18
19
  "message"=>"Selections can't be made on scalars (field 'id' returns Int but has selections [something, someFields])",
19
20
  "locations"=>[{"line"=>5, "column"=>47}],
20
21
  "fields"=>["query getCheese", "illegalSelectionCheese", "id"],
21
22
  }
22
- assert_includes(errors, illegal_selection_error, "finds illegal selections on scalarss")
23
+ assert_includes(errors, illegal_selection_error, "finds illegal selections on scalars")
23
24
 
24
25
  selection_required_error = {
25
26
  "message"=>"Objects must have selections (field 'cheese' returns Cheese but has no selections)",
@@ -27,6 +28,13 @@ describe GraphQL::StaticValidation::FieldsHaveAppropriateSelections do
27
28
  "fields"=>["query getCheese", "missingFieldsCheese"],
28
29
  }
29
30
  assert_includes(errors, selection_required_error, "finds objects without selections")
31
+
32
+ incorrect_fragment_error = {
33
+ "message"=>"Selections can't be made on scalars (field 'flavor' returns String but has inline fragments [String])",
34
+ "locations"=>[{"line"=>6, "column"=>48}],
35
+ "fields"=>["query getCheese", "incorrectFragmentSpread", "flavor"],
36
+ }
37
+ assert_includes(errors, incorrect_fragment_error, "finds scalar fields with selections")
30
38
  end
31
39
 
32
40
  describe "anonymous operations" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.9
4
+ version: 1.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-01 00:00:00.000000000 Z
11
+ date: 2018-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -1030,7 +1030,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1030
1030
  version: '0'
1031
1031
  requirements: []
1032
1032
  rubyforge_project:
1033
- rubygems_version: 2.6.11
1033
+ rubygems_version: 2.7.3
1034
1034
  signing_key:
1035
1035
  specification_version: 4
1036
1036
  summary: A GraphQL language and runtime for Ruby