Skip to content

Instantly share code, notes, and snippets.

@phuochau
Last active October 25, 2017 23:51
Show Gist options
  • Save phuochau/afcbcc565fe7ae04307b634461960bcf to your computer and use it in GitHub Desktop.
Save phuochau/afcbcc565fe7ae04307b634461960bcf to your computer and use it in GitHub Desktop.
Absinthe Helper for Elixir
defmodule Test.Support.AbsintheHelper do
def mutation_skeleton(query) do
%{
"operationName" => "",
"query" => "#{query}",
"variables" => ""
}
end
def query_skeleton(query, query_name) do
%{
"operationName" => "#{query_name}",
"query" => "query #{query_name} #{query}",
"variables" => "{}"
}
end
def gen_multipart(files, boundary \\ "12412asdafag") do
Enum.reduce(files, "", fn (%{name: name, content: content, filename: filename, content_type: content_type}, acc) -> acc <> """
------#{boundary}\r
Content-Disposition: form-data; name=\"#{name}\"; filename=\"#{filename}\"\r
Content-Type: #{content_type}
\r
#{content}\r
""" end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment