title: How to accept JSON in Absinthe GraphQL requests
body: <p>I'm attempting to receive a string of JSON in my graphql implementation but keep getting errors with the custom scalar I've defined to handle the JSON. </p>
  
  <p>I've defined a custom scalar to properly serialize the JSON to an elixir map. I'm getting errors that I have invalid data types before my code reaches the parsing stage of the custom scalar. I'm attempting to use <a href="https://github.com/absinthe-graphql/absinthe/wiki/Scalar-Recipes#json-using-jason" rel="nofollow noreferrer">https://github.com/absinthe-graphql/absinthe/wiki/Scalar-Recipes#json-using-jason</a> to create the scalar however I've modified to use Poison instead of Jason.</p>
  
  <p>My absinthe mutator using the :json scalar type I created.  </p>
  
  <pre><code>@desc "Update user"
  field :update_user, type: :user do
    arg(:email, :string)
    arg(:password, :string)
    arg(:first_name, :string)
    arg(:last_name, :string)
    arg(:age, :integer)
    arg(:client_store, :json)
  
    resolve(handle_errors(&amp;Resolvers.User_Resolver.update_user/3))
  end
  </code></pre>
  
  <p>My scalar definition and graphql schema definition</p>
  
  <pre><code>    scalar :json, name: "Json" do
          description("""
          The `Json` scalar type represents arbitrary json string data, represented as UTF-8
          character sequences. The Json type is most often used to represent a free-form
          human-readable json string.
          """)
          serialize(&amp;encode/1)
          parse(&amp;decode/1)
      end
  
      # @spec decode(Absinthe.Blueprint.Input.String.t) :: {:ok, :string} | :error
      # @spec decode(Absinthe.Blueprint.Input.Null.t) :: {:ok, nil}
      defp decode(%Absinthe.Blueprint.Input.String{value: value}) do
          Logger.info "decoded input value:"
          case Poison.decode(value) do
          {:ok, result} -&gt; {:ok, result}
          _ -&gt; :error
          end
      end
  
      defp decode(%Absinthe.Blueprint.Input.Null{}) do
          {:ok, nil}
      end
  
      defp decode(_) do
          :error
      end
  
      defp encode(value), do: value
  
      object :user do
          field(:id, :id)
          field(:email, :string)
          field(:password, :string)
          field(:first_name, :string)
          field(:last_name, :string)
          field(:age, :integer)
          field(:client_store, :json)
      end
  </code></pre>
  
  <p>when sending the following queries:</p>
  
  <pre><code>    mutation updateUser{
        updateUser(client_store: "{"key":"value"}"){
          id
        }
      }
  </code></pre>
  
  <p>I receive a <code>syntax error before: \"\\\":\\\"\"</code></p>
  
  <pre><code>    mutation updateUser{
        updateUser(client_store: "hello"){
          id
        }
      }
  </code></pre>
  
  <p>I receive a <code>"Argument \"client_store\" has invalid value \"hello\"</code></p>
  
  <p>Sending the GraphQL query through a unit test via <code>Phoenix.ConnTest</code></p>
  
  <pre><code>query = """
      mutation updateUser{
        updateUser(client_store: "{\"key\":\"value\"}"){
          id
        }
      }
    """
  
  res =
    context.conn
    |&gt; put_req_header("content-type", "text")
    |&gt; put_req_header("authorization", token)
    |&gt; post("/api", query)
  </code></pre>