@@ -12,21 +12,39 @@ defmodule Absinthe.Pipeline do
1212 * See `Absinthe.Schema` on adjusting the schema pipeline for schema manipulation.
1313 """
1414
15+ alias Absinthe.Blueprint.Continuation
1516 alias Absinthe.Phase
1617
1718 @ type data_t :: any
1819
20+ @ type run_result_t :: { :ok , data_t , [ Phase . t ( ) ] } | { :error , String . t ( ) , [ Phase . t ( ) ] }
21+
1922 @ type phase_config_t :: Phase . t ( ) | { Phase . t ( ) , Keyword . t ( ) }
2023
2124 @ type t :: [ phase_config_t | [ phase_config_t ] ]
2225
23- @ spec run ( data_t , t ) :: { :ok , data_t , [ Phase . t ( ) ] } | { :error , String . t ( ) , [ Phase . t ( ) ] }
26+ @ spec run ( data_t , t ) :: run_result_t
2427 def run ( input , pipeline ) do
2528 pipeline
2629 |> List . flatten ( )
2730 |> run_phase ( input )
2831 end
2932
33+ @ spec continue ( [ Continuation . t ( ) ] ) :: run_result_t
34+ def continue ( [ continuation | rest ] ) do
35+ result = run_phase ( continuation . pipeline , continuation . phase_input )
36+
37+ case result do
38+ { :ok , blueprint , phases } when rest == [ ] ->
39+ { :ok , blueprint , phases }
40+ { :ok , blueprint , phases } ->
41+ bp_result = Map . put ( blueprint . result , :continuation , rest )
42+ blueprint = Map . put ( blueprint , :result , bp_result )
43+ { :ok , blueprint , phases }
44+ error -> error
45+ end
46+ end
47+
3048 @ defaults [
3149 adapter: Absinthe.Adapter.LanguageConventions ,
3250 operation_name: nil ,
@@ -388,8 +406,8 @@ defmodule Absinthe.Pipeline do
388406 end )
389407 end
390408
391- @ spec run_phase ( t , data_t , [ Phase . t ( ) ] ) ::
392- { :ok , data_t , [ Phase . t ( ) ] } | { :error , String . t ( ) , [ Phase . t ( ) ] }
409+ @ spec run_phase ( t , data_t , [ Phase . t ( ) ] ) :: run_result_t
410+
393411 def run_phase ( pipeline , input , done \\ [ ] )
394412
395413 def run_phase ( [ ] , input , done ) do
0 commit comments