Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 15008c8

Browse files
committed
Extract an expand_options function
1 parent 06bea1a commit 15008c8

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/graphql/execution/executor.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,20 @@ defmodule GraphQL.Execution.Executor do
2424
@spec execute(GraphQL.Schema.t, GraphQL.Document.t, list) :: result_data | {:error, %{errors: list}}
2525
def execute(schema, document, opts \\ []) do
2626
schema = Schema.with_type_cache(schema)
27-
root_value = Keyword.get(opts, :root_value, %{})
28-
variable_values = Keyword.get(opts, :variable_values, %{})
29-
operation_name = Keyword.get(opts, :operation_name, nil)
27+
{root_value, variable_values, operation_name} = expand_options(opts)
3028
context = ExecutionContext.new(schema, document, root_value, variable_values, operation_name)
3129
case context.errors do
3230
[] -> execute_operation(context, context.operation, root_value)
3331
_ -> {:error, %{errors: Enum.dedup(context.errors)}}
3432
end
3533
end
3634

35+
defp expand_options(opts) do
36+
{Keyword.get(opts, :root_value, %{}),
37+
Keyword.get(opts, :variable_values, %{}),
38+
Keyword.get(opts, :operation_name, nil)}
39+
end
40+
3741
@spec execute_operation(ExecutionContext.t, Nodes.operation_node, map) :: result_data | {:error, String.t}
3842
defp execute_operation(context, operation, root_value) do
3943
type = Schema.operation_root_type(context.schema, operation)

0 commit comments

Comments
 (0)