graphql 0.15.0 → 0.15.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.
@@ -13,7 +13,7 @@ rule
13
13
  | fragment_definition
14
14
 
15
15
  operation_definition:
16
- name operation_name_opt variable_definitions_opt directives_list_opt selection_set {
16
+ operation_type operation_name_opt variable_definitions_opt directives_list_opt selection_set {
17
17
  return make_node(
18
18
  :OperationDefinition, {
19
19
  operation_type: val[0],
@@ -34,6 +34,11 @@ rule
34
34
  )
35
35
  }
36
36
 
37
+ operation_type:
38
+ QUERY
39
+ | MUTATION
40
+ | SUBSCRIPTION
41
+
37
42
  operation_name_opt:
38
43
  /* none */ { return nil }
39
44
  | name
@@ -116,6 +121,9 @@ rule
116
121
  | FRAGMENT
117
122
  | TRUE
118
123
  | FALSE
124
+ | QUERY
125
+ | MUTATION
126
+ | SUBSCRIPTION
119
127
 
120
128
  arguments_opt:
121
129
  /* none */ { return [] }
@@ -25,8 +25,8 @@ module GraphQL
25
25
  return {} if operation.nil?
26
26
 
27
27
  op_type = operation.operation_type
28
- root_type = query.schema.public_send(op_type)
29
- execution_strategy_class = query.schema.public_send("#{op_type}_execution_strategy")
28
+ root_type = query.schema.root_type_for_operation(op_type)
29
+ execution_strategy_class = query.schema.execution_strategy_for_operation(op_type)
30
30
  execution_strategy = execution_strategy_class.new
31
31
 
32
32
  query.context.execution_strategy = execution_strategy
@@ -92,5 +92,31 @@ module GraphQL
92
92
  @interface_possible_types ||= GraphQL::Schema::PossibleTypes.new(self)
93
93
  @interface_possible_types.possible_types(type_defn)
94
94
  end
95
+
96
+ def root_type_for_operation(operation)
97
+ case operation
98
+ when "query"
99
+ query
100
+ when "mutation"
101
+ mutation
102
+ when "subscription"
103
+ subscription
104
+ else
105
+ raise ArgumentError, "unknown operation type: #{operation}"
106
+ end
107
+ end
108
+
109
+ def execution_strategy_for_operation(operation)
110
+ case operation
111
+ when "query"
112
+ query_execution_strategy
113
+ when "mutation"
114
+ mutation_execution_strategy
115
+ when "subscription"
116
+ subscription_execution_strategy
117
+ else
118
+ raise ArgumentError, "unknown operation type: #{operation}"
119
+ end
120
+ end
95
121
  end
96
122
  end
@@ -76,7 +76,7 @@ module GraphQL
76
76
  class OperationDefinitionStrategy
77
77
  def push(stack, node)
78
78
  # eg, QueryType, MutationType
79
- object_type = stack.schema.public_send(node.operation_type)
79
+ object_type = stack.schema.root_type_for_operation(node.operation_type)
80
80
  stack.object_types.push(object_type)
81
81
  end
82
82
 
@@ -1,3 +1,3 @@
1
1
  module GraphQL
2
- VERSION = "0.15.0"
2
+ VERSION = "0.15.1"
3
3
  end
data/readme.md CHANGED
@@ -123,6 +123,7 @@ If you're building a backend for [Relay](http://facebook.github.io/relay/), you'
123
123
  - Support type name for field types?
124
124
  - Add a complexity validator (reject queries if they're too big)
125
125
  - Add docs for shared behaviors & DRY code
126
+ - Proper error on unknown directive
126
127
  - __Subscriptions__
127
128
  - This is a good chance to make an `Operation` abstraction of which `query`, `mutation` and `subscription` are members
128
129
  - For a subscription, `graphql` would send an outbound message to the system (allow the host application to manage its own subscriptions via Pusher, ActionCable, whatever)
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.15.0
4
+ version: 0.15.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-06-11 00:00:00.000000000 Z
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter