Absinthe result has all null values

Hi,

I’m totally new to Elixir, Phoenix, and Absinthe…so go easy on me. :slightly_smiling_face:

I’m experimenting with a graph database called Dgraph using a library called Dlex. I’ve written a simple query designed to look up and return a list of users (I only have two users at the moment):

def list_users() do
  query = """
    {
      users(func: type(User)) {
        uid
        email
        name
      }
    }
  """

  {:ok, %{"users" => result}} = Dlex.query(:dlex, query)

  IO.inspect(result)

  {:ok, result}
end

The output from IO.inspect(result) is precisely what I expect and want—a list of my two users:

[
  %{"email" => "rob@example.com", "name" => "Rob", "uid" => "0x1"},
  %{"email" => "bridget@example.com", "name" => "Bridget", "uid" => "0x2"}
]

However, when I run this query with GraphiQL, all the values in the result are null for some reason:

{
  "data": {
    "users": [
      {
        "email": null,
        "name": null,
        "uid": null
      },
      {
        "email": null,
        "name": null,
        "uid": null
      }
    ]
  }
}

Any idea what I’m doing wrong?

Hey @tron. Absinthe by default expects that you’ll be returning atom keyed maps from its resolvers. To have it look for string keys, alter the default middleware: https://hexdocs.pm/absinthe/Absinthe.Schema.html#replace_default/4

1 Like

Thank you, @benwilson512! That solved the problem for me.