Last active
October 25, 2017 23:51
-
-
Save phuochau/afcbcc565fe7ae04307b634461960bcf to your computer and use it in GitHub Desktop.
Absinthe Helper for Elixir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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