|
17 | 17 | assert_equal(4, errors.length) |
18 | 18 |
|
19 | 19 | illegal_selection_error = { |
20 | | - "message"=>"Selections can't be made on scalars (field 'id' returns Int but has selections [something, someFields])", |
| 20 | + "message"=>"Selections can't be made on scalars (field 'id' returns Int but has selections [\"something\", \"someFields\"])", |
21 | 21 | "locations"=>[{"line"=>6, "column"=>47}], |
22 | 22 | "path"=>["query getCheese", "illegalSelectionCheese", "id"], |
23 | 23 | "extensions"=>{"code"=>"selectionMismatch", "nodeName"=>"field 'id'", "typeName"=>"Int"} |
|
41 | 41 | assert_includes(errors, interfaces_selection_required_error, "finds interfaces without selections") |
42 | 42 |
|
43 | 43 | incorrect_fragment_error = { |
44 | | - "message"=>"Selections can't be made on scalars (field 'flavor' returns String but has inline fragments [String])", |
| 44 | + "message"=>"Selections can't be made on scalars (field 'flavor' returns String but has selections [\"... on String { ... }\"])", |
45 | 45 | "locations"=>[{"line"=>7, "column"=>48}], |
46 | 46 | "path"=>["query getCheese", "incorrectFragmentSpread", "flavor"], |
47 | 47 | "extensions"=>{"code"=>"selectionMismatch", "nodeName"=>"field 'flavor'", "typeName"=>"String"} |
|
63 | 63 | assert_includes(errors, selections_required_error) |
64 | 64 | end |
65 | 65 | end |
| 66 | + |
| 67 | + describe "selections and inline fragments on scalars" do |
| 68 | + let(:query_string) {" |
| 69 | + { |
| 70 | + cheese(id: 1) { |
| 71 | + fatContent { |
| 72 | + name |
| 73 | + ... on User { |
| 74 | + id |
| 75 | + } |
| 76 | + ... F |
| 77 | + } |
| 78 | + } |
| 79 | + } |
| 80 | +
|
| 81 | + fragment F on Cheese { |
| 82 | + id |
| 83 | + } |
| 84 | + "} |
| 85 | + it "returns an error" do |
| 86 | + expected_err = "Selections can't be made on scalars (field 'fatContent' returns Float but has selections [\"name\", \"... on User { ... }\", \"F\"])" |
| 87 | + assert_includes(errors.map { |e| e["message"] }, expected_err) |
| 88 | + end |
| 89 | + end |
66 | 90 | end |
0 commit comments