Skip to content

Commit 32c1702

Browse files
authored
Execution test cleanup (#146)
* Use current operation in execution * No missing input stubs for deprecated fields * Restructure result tree, attach to operation * Clean out old execution, more type massaging * fix warnings * Fix introspection tests, add debug phase * Fix non-typeless inline fragment tests
1 parent 2367766 commit 32c1702

58 files changed

Lines changed: 412 additions & 2274 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/absinthe.ex

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,6 @@ defmodule Absinthe do
141141
defexception message: "execution failed"
142142
end
143143

144-
defmodule SyntaxError do
145-
@moduledoc """
146-
An error during parsing.
147-
"""
148-
defexception source: nil, location: nil, message: ""
149-
def message(exception) do
150-
"#{exception.message} on line #{exception.location.line}"
151-
end
152-
end
153-
154144
def parse(input) do
155145
Absinthe.Phase.Parse.run(input)
156146
end

lib/absinthe/blueprint.ex

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ defmodule Absinthe.Blueprint do
1212
# Added by phases
1313
flags: %{},
1414
errors: [],
15+
result: nil
1516
]
1617

1718
@type t :: %__MODULE__{
@@ -23,7 +24,8 @@ defmodule Absinthe.Blueprint do
2324
adapter: nil | Absinthe.Adapter.t,
2425
# Added by phases
2526
errors: [Blueprint.Phase.Error.t],
26-
flags: Blueprint.flags_t
27+
flags: Blueprint.flags_t,
28+
result: nil | map
2729
}
2830

2931
@type node_t ::
@@ -81,4 +83,26 @@ defmodule Absinthe.Blueprint do
8183
Map.has_key?(node.flags, flag)
8284
end
8385

86+
@doc """
87+
Get the currently selected operation.
88+
"""
89+
@spec current_operation(t) :: nil | Blueprint.Operation.t
90+
def current_operation(blueprint) do
91+
Enum.find(blueprint.operations, &(&1.current == true))
92+
end
93+
94+
@doc """
95+
Update the current operation.
96+
"""
97+
@spec update_current(t, (Blueprint.Operation.t -> Blueprint.Operation.t)) :: t
98+
def update_current(blueprint, change) do
99+
ops = Enum.map(blueprint.operations, fn
100+
%{current: true} = op ->
101+
change.(op)
102+
other ->
103+
other
104+
end)
105+
%{blueprint | operations: ops}
106+
end
107+
84108
end

lib/absinthe/blueprint/document/operation.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ defmodule Absinthe.Blueprint.Document.Operation do
1717
flags: %{},
1818
schema_node: nil,
1919
provided_values: %{},
20+
resolution: nil,
2021
fields: [],
2122
errors: [],
2223
]
@@ -33,6 +34,7 @@ defmodule Absinthe.Blueprint.Document.Operation do
3334
source_location: nil | Blueprint.Document.SourceLocation.t,
3435
schema_node: nil | Absinthe.Type.Object.t,
3536
provided_values: %{String.t => nil | Blueprint.Input.t},
37+
resolution: nil | Blueprint.Document.Result.Object.t,
3638
flags: Blueprint.flags_t,
3739
fields: [Blueprint.Document.Field.t],
3840
errors: [Absinthe.Phase.Error.t],
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule Absinthe.Blueprint.Document.Result.Leaf do
2+
3+
@enforce_keys [:name, :value]
4+
defstruct [
5+
:name,
6+
:value
7+
]
8+
9+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule Absinthe.Blueprint.Document.Result.List do
2+
3+
@enforce_keys [:name, :values]
4+
defstruct [
5+
:name,
6+
:values
7+
]
8+
9+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule Absinthe.Blueprint.Document.Result.Object do
2+
3+
@enforce_keys [:name, :fields]
4+
defstruct [
5+
:name,
6+
:fields,
7+
]
8+
9+
end

lib/absinthe/execution.ex

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

0 commit comments

Comments
 (0)