graphql 0.19.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql.rb +1 -0
  3. data/lib/graphql/base_type.rb +0 -42
  4. data/lib/graphql/define/instance_definable.rb +27 -14
  5. data/lib/graphql/interface_type.rb +1 -2
  6. data/lib/graphql/invalid_null_error.rb +3 -2
  7. data/lib/graphql/language/lexer.rl +1 -1
  8. data/lib/graphql/language/parser.rb +544 -531
  9. data/lib/graphql/language/parser.y +1 -0
  10. data/lib/graphql/language/parser_tests.rb +1 -1
  11. data/lib/graphql/object_type.rb +0 -21
  12. data/lib/graphql/query/serial_execution/value_resolution.rb +5 -6
  13. data/lib/graphql/relay/node.rb +6 -1
  14. data/lib/graphql/schema.rb +30 -10
  15. data/lib/graphql/schema/loader.rb +5 -1
  16. data/lib/graphql/schema/validation.rb +31 -0
  17. data/lib/graphql/union_type.rb +0 -1
  18. data/lib/graphql/unresolved_type_error.rb +16 -0
  19. data/lib/graphql/version.rb +1 -1
  20. data/spec/graphql/analysis/query_complexity_spec.rb +5 -1
  21. data/spec/graphql/define/instance_definable_spec.rb +11 -0
  22. data/spec/graphql/field_spec.rb +3 -2
  23. data/spec/graphql/non_null_type_spec.rb +2 -2
  24. data/spec/graphql/query/context_spec.rb +1 -0
  25. data/spec/graphql/query/executor_spec.rb +2 -2
  26. data/spec/graphql/query/serial_execution/value_resolution_spec.rb +49 -9
  27. data/spec/graphql/schema/loader_spec.rb +6 -1
  28. data/spec/graphql/schema/printer_spec.rb +1 -1
  29. data/spec/graphql/schema_spec.rb +56 -0
  30. data/spec/graphql/static_validation/rules/mutation_root_exists_spec.rb +1 -1
  31. data/spec/graphql/static_validation/rules/subscription_root_exists_spec.rb +1 -1
  32. data/spec/support/dairy_app.rb +0 -5
  33. metadata +3 -2
@@ -106,7 +106,12 @@ describe GraphQL::Schema::Loader do
106
106
  field :ping, field: ping_mutation.field
107
107
  end
108
108
 
109
- GraphQL::Schema.define(query: query_root, mutation: mutation_root, orphan_types: [audio_type, video_type])
109
+ GraphQL::Schema.define(
110
+ query: query_root,
111
+ mutation: mutation_root,
112
+ orphan_types: [audio_type, video_type],
113
+ resolve_type: :pass,
114
+ )
110
115
  }
111
116
 
112
117
  let(:schema_json) {
@@ -63,7 +63,7 @@ describe GraphQL::Schema::Printer do
63
63
  end
64
64
  end
65
65
 
66
- GraphQL::Schema.define(query: query_root)
66
+ GraphQL::Schema.define(query: query_root, resolve_type: :pass)
67
67
  }
68
68
 
69
69
  describe ".print_introspection_schema" do
@@ -47,6 +47,25 @@ describe GraphQL::Schema do
47
47
  }
48
48
  end
49
49
  end
50
+
51
+ describe "when a schema is defined with abstract types, but no resolve type hook" do
52
+ it "raises not implemented" do
53
+ interface = GraphQL::InterfaceType.define do
54
+ name "SomeInterface"
55
+ end
56
+
57
+ query_type = GraphQL::ObjectType.define do
58
+ name "Query"
59
+ field :something, interface
60
+ end
61
+
62
+ assert_raises(NotImplementedError) {
63
+ GraphQL::Schema.define do
64
+ query(query_type)
65
+ end
66
+ }
67
+ end
68
+ end
50
69
  end
51
70
 
52
71
  describe "object_from_id" do
@@ -57,6 +76,27 @@ describe GraphQL::Schema do
57
76
  }
58
77
  end
59
78
  end
79
+
80
+ describe "when a schema is defined with a relay ID field, but no hook" do
81
+ it "raises not implemented" do
82
+ thing_type = GraphQL::ObjectType.define do
83
+ name "Thing"
84
+ global_id_field :id
85
+ end
86
+
87
+ query_type = GraphQL::ObjectType.define do
88
+ name "Query"
89
+ field :thing, thing_type
90
+ end
91
+
92
+ assert_raises(NotImplementedError) {
93
+ GraphQL::Schema.define do
94
+ query(query_type)
95
+ resolve_type -> (obj, ctx) { :whatever }
96
+ end
97
+ }
98
+ end
99
+ end
60
100
  end
61
101
 
62
102
  describe "id_from_object" do
@@ -67,5 +107,21 @@ describe GraphQL::Schema do
67
107
  }
68
108
  end
69
109
  end
110
+
111
+ describe "when a schema is defined with a node field, but no hook" do
112
+ it "raises not implemented" do
113
+ query_type = GraphQL::ObjectType.define do
114
+ name "Query"
115
+ field :node, GraphQL::Relay::Node.field
116
+ end
117
+
118
+ assert_raises(NotImplementedError) {
119
+ GraphQL::Schema.define do
120
+ query(query_type)
121
+ resolve_type -> (obj, ctx) { :whatever }
122
+ end
123
+ }
124
+ end
125
+ end
70
126
  end
71
127
  end
@@ -15,7 +15,7 @@ describe GraphQL::StaticValidation::MutationRootExists do
15
15
  |}
16
16
 
17
17
  let(:schema) {
18
- query_root = GraphQL::Field.define do
18
+ query_root = GraphQL::ObjectType.define do
19
19
  name "Query"
20
20
  description "Query root of the system"
21
21
  end
@@ -10,7 +10,7 @@ describe GraphQL::StaticValidation::SubscriptionRootExists do
10
10
  |}
11
11
 
12
12
  let(:schema) {
13
- query_root = GraphQL::Field.define do
13
+ query_root = GraphQL::ObjectType.define do
14
14
  name "Query"
15
15
  description "Query root of the system"
16
16
  end
@@ -9,11 +9,6 @@ LocalProductInterface = GraphQL::InterfaceType.define do
9
9
  name "LocalProduct"
10
10
  description "Something that comes from somewhere"
11
11
  field :origin, !types.String, "Place the thing comes from"
12
- # This is a "bug" in the dummy app:
13
- # it should actually check the incoming object to determine the type.
14
- # But this is here so we can check _where_ misbehaving resolve_type
15
- # functions wreak their havoc.
16
- resolve_type -> (o, c) { MilkType }
17
12
  end
18
13
 
19
14
  EdibleInterface = GraphQL::InterfaceType.define 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: 0.19.0
4
+ version: 0.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-30 00:00:00.000000000 Z
11
+ date: 2016-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter
@@ -435,6 +435,7 @@ files:
435
435
  - lib/graphql/string_type.rb
436
436
  - lib/graphql/type_kinds.rb
437
437
  - lib/graphql/union_type.rb
438
+ - lib/graphql/unresolved_type_error.rb
438
439
  - lib/graphql/version.rb
439
440
  - readme.md
440
441
  - spec/graphql/analysis/analyze_query_spec.rb