Packages
absinthe_relay
1.5.2
1.6.0
1.5.2
1.5.1
1.5.0
1.5.0-rc.0
1.5.0-beta.0
1.5.0-alpha.0
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.4.0-rc.1
1.4.0-rc.0
1.3.6
1.3.5
1.3.4
1.3.3
1.3.2
1.3.1
1.3.0
1.3.0-rc.0
1.3.0-beta.1
1.3.0-beta.0
1.2.0
1.2.0-alpha0
1.2.0-alpha.3
1.2.0-alpha.2
1.2.0-alpha.1
0.9.4
0.9.3
0.9.2
0.9.1
0.9.0
0.8.1
0.8.0
Relay framework support for Absinthe
Current section
Files
Jump to
Current section
Files
lib/absinthe/relay/mutation.ex
defmodule Absinthe.Relay.Mutation do
@moduledoc """
Middleware to support the macros located in:
- For Relay Modern: `Absinthe.Relay.Mutation.Notation.Modern`
- For Relay Classic: `Absinthe.Relay.Mutation.Notation.Classic`
Please see those modules for specific instructions.
"""
@doc false
# System resolver to extract values from the input and return the
# client mutation ID (the latter for Relay Classic only) as part of the response.
def call(%{state: :unresolved} = res, _) do
case res.arguments do
%{input: %{client_mutation_id: mut_id} = input} ->
%{
res
| arguments: input,
private:
Map.merge(res.private, %{__client_mutation_id: mut_id, __parse_ids_root: :input}),
middleware: res.middleware ++ [__MODULE__]
}
%{input: input} ->
%{
res
| arguments: input,
private: Map.merge(res.private, %{__parse_ids_root: :input}),
middleware: res.middleware ++ [__MODULE__]
}
_ ->
res
end
end
def call(%{state: :resolved, value: value} = res, _) when is_map(value) do
mut_id = res.private[:__client_mutation_id]
%{res | value: Map.put(value, :client_mutation_id, mut_id)}
end
def call(res, _) do
res
end
end