Skip to content

Commit b5e0ae4

Browse files
committed
refactor(Execution) put back stuff I didn't use
1 parent fa60bb9 commit b5e0ae4

File tree

8 files changed

+41
-44
lines changed

8 files changed

+41
-44
lines changed

lib/graphql/execution.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require "graphql/execution/context"
21
require "graphql/execution/deferred_execution"
32
require "graphql/execution/selection_on_type"
43
require "graphql/execution/resolve_type"

lib/graphql/execution/context.rb

Lines changed: 0 additions & 29 deletions
This file was deleted.

lib/graphql/query/serial_execution.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
require "graphql/query/serial_execution/execution_context"
2+
require "graphql/query/serial_execution/value_resolution"
3+
require "graphql/query/serial_execution/field_resolution"
4+
require "graphql/query/serial_execution/operation_resolution"
5+
require "graphql/query/serial_execution/selection_resolution"
6+
17
module GraphQL
28
class Query
39
class SerialExecution
@@ -13,7 +19,7 @@ def execute(ast_operation, root_type, query_obj)
1319
operation_resolution.new(
1420
ast_operation,
1521
root_type,
16-
GraphQL::Execution::Context.new(query_obj, self)
22+
ExecutionContext.new(query_obj, self)
1723
).result
1824
end
1925

@@ -31,8 +37,3 @@ def selection_resolution
3137
end
3238
end
3339
end
34-
35-
require "graphql/query/serial_execution/value_resolution"
36-
require "graphql/query/serial_execution/field_resolution"
37-
require "graphql/query/serial_execution/operation_resolution"
38-
require "graphql/query/serial_execution/selection_resolution"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module GraphQL
2+
class Query
3+
class SerialExecution
4+
class ExecutionContext
5+
attr_reader :query, :schema, :strategy
6+
7+
def initialize(query, strategy)
8+
@query = query
9+
@schema = query.schema
10+
@strategy = strategy
11+
end
12+
13+
def get_type(type)
14+
@schema.types[type]
15+
end
16+
17+
def get_fragment(name)
18+
@query.fragments[name]
19+
end
20+
21+
def get_field(type, name)
22+
@schema.get_field(type, name)
23+
end
24+
25+
def add_error(err)
26+
@query.context.errors << err
27+
end
28+
end
29+
end
30+
end
31+
end

spec/graphql/execution_error_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
id, flavor
2626
}
2727
|}
28-
2928
it "the error is inserted into the errors key and the rest of the query is fulfilled" do
3029
expected_result = {
3130
"data"=>{

spec/graphql/introspection/type_type_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
{"name"=>"GOAT", "isDeprecated"=> false },
2727
{"name"=>"SHEEP", "isDeprecated"=> false },
2828
]}
29-
3029
it "exposes metadata about types" do
3130
expected = {"data"=> {
3231
"cheeseType" => {

spec/graphql/execution/context_spec.rb renamed to spec/graphql/query/serial_execution/execution_context_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "spec_helper"
22

3-
describe GraphQL::Execution::Context do
3+
describe GraphQL::Query::SerialExecution::ExecutionContext do
44
let(:query_string) { %|
55
query getFlavor($cheeseId: Int!) {
66
brie: cheese(id: 1) { ...cheeseFields, taste: flavor }
@@ -17,7 +17,7 @@
1717
operation_name: operation_name,
1818
)}
1919
let(:execution_context) {
20-
GraphQL::Execution::Context.new(query, nil)
20+
GraphQL::Query::SerialExecution::ExecutionContext.new(query, nil)
2121
}
2222

2323
describe "add_error" do

spec/graphql/query/serial_execution/value_resolution_spec.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
require "spec_helper"
2-
#
3-
# TODO port tests to new module
4-
#
5-
#
2+
63
describe GraphQL::Query::SerialExecution::ValueResolution do
74
let(:query_root) {
85
day_of_week_enum = GraphQL::EnumType.define do

0 commit comments

Comments
 (0)