Allow to pass file uploads to AbsintheHelpers.graphql_query/2
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
ecfcc4fe83
commit
52fe274c5a
@ -28,14 +28,24 @@ defmodule Mobilizon.GraphQL.AbsintheHelpers do
|
|||||||
@spec graphql_query(Conn.t(), Keyword.t()) :: map | no_return
|
@spec graphql_query(Conn.t(), Keyword.t()) :: map | no_return
|
||||||
def graphql_query(conn, options) do
|
def graphql_query(conn, options) do
|
||||||
conn
|
conn
|
||||||
|> post("/api", build_query(options[:query], Keyword.get(options, :variables, %{})))
|
|> post(
|
||||||
|
"/api",
|
||||||
|
build_query(
|
||||||
|
options[:query],
|
||||||
|
Keyword.get(options, :variables, %{}),
|
||||||
|
Keyword.get(options, :uploads, %{})
|
||||||
|
)
|
||||||
|
)
|
||||||
|> json_response(200)
|
|> json_response(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp build_query(query, variables) do
|
defp build_query(query, variables, uploads) do
|
||||||
%{
|
Map.merge(
|
||||||
"query" => query,
|
%{
|
||||||
"variables" => variables
|
"query" => query,
|
||||||
}
|
"variables" => variables
|
||||||
|
},
|
||||||
|
uploads
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user