zar1978

zar1978

Dynamo ExAws read table with complex field - inclassparameter is NULL

Good morning. I have the following problem. I should read the contents of the following Dynamo table through the ExAws library:

{
  "actorengine": "HOT-TCM",
  "actortype": "BUSINESS_ACTOR",
  "actorversionclass": 1,
  "classified": "UNCLASSIFIED",
  "creatorclass": "ivan.casiraghi@gmail.com",
  "datadeploy": "2019-02-11 16:55:13",
  "encryption": "NOENCRYPTION",
  "id": "1234567890",
  "inclassparameters": [
    {
      "id": "1222",
      "keyspace": "eyspace"
    }
  ],
  "keyspace": "it0125maxwellgroup",
  "linknamemodel": "https://s3-eu-west.amazonaws.com/maxwell-abe-deploy/actor/it0125maxwellgroup/prova01_1.0.json",
  "name": "prova01",
  "security": "PUBLIC",
  "statedeploy": "ACTIVE"
}

This is my module:

defmodule ElixirCrudWeb.Resolver.Resolver do
  @moduledoc false


  alias ExAws.Dynamo


  defmodule InClassParameter do
    @derive [ExAws.Dynamo.Encodable]
    defstruct [:keyspace, :id]
  end



  defmodule ActorClassBusiness do
        @derive [ExAws.Dynamo.Encodable]
        defstruct [:id, :actorversionclass, :actorengine, :actortype, :classified, :creatorclass, :datadeploy,
          :encryption, :keyspace, :linknamemodel, :name,  :security, :statedeploy,
          inClassParameter: [%InClassParameter{},]
        ]
      end
 def select_one(_parent, %{id: id}, _resolution)  do
    item = Dynamo.get_item("actorClassBusiness", %{id: id}) |> ExAws.request!
    wrap_result(id, item)
  end


  defp wrap_result(key, map) when map == %{} do
    {:error, "actorClassBusiness ID #{key} not found"}
  end

  defp wrap_result(_, map) do
    IO.puts("Ecco i dati  #{inspect(map)}")
    item = Dynamo.decode_item(map, as: ActorClassBusiness)
    {:ok, item}
  end

end

If I run the query from GraphiQl:

query read{
  selectOne(id: "14c41f17-38b8-41db-af8b-111f6165932a"){
    id
    actorengine
  actortype
  actorversionclass
  classified
  creatorclass
  datadeploy
  encryption
    statedeploy
    inclassparameters{
      id
      keyspace
    }
  }
}

I get the following:

{
  "data": {
    "selectOne": {
      "actorengine": "HOT-TCM",
      "actortype": "BUSINESS_ACTOR",
      "actorversionclass": 1,
      "classified": "UNCLASSIFIED",
      "creatorclass": "ascanio.casiraghi@gmail.com",
      "datadeploy": "2019-03-18 01:48:59",
      "encryption": "NOENCRYPTION",
      "id": "14c41f17-38b8-41db-af8b-111f6165932a",
      "inclassparameters": null,
      "statedeploy": "ACTIVE"
    }
  }
}

inclassparameter is NULL. Where am I wrong?
Thank you

First Post!

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

If you’re also using GraphQL can you show the definitions?

Last Post!

zar1978

zar1978

Nobody can help me?

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement