I’m trying to impelent GraphQL API in my project. I’m new in GraphQL, only read one article. I don’t understand how to convert :map
field from Ecto.Schema to Types for GraphQL Schema. How i can declare field :locales
in Absinthe.Schema.Notation.object/3
?
My Ecto.Schema is
defmodule Msg
@primary_key {:id, MsgidType, autogenerate: false}
typed_schema "messages" do
field(:text, :string)
field(:domain, :string)
field(:locales, :map, default: %{})
timestamps()
end
end
Example of %Msg{}
%Msg{
id: "test_update_msg_id",
text: "Update test",
domain: "test",
locales: %{
"en" => "Check update",
"ru" => "Proverka update",
"uz" => "Imtihon update"
}
}
My Absinthe.Schema.Notation
@desc "Message for sms and ussd"
object :message do
field(:id, non_null(:string), description: "Hardcoded id")
field(:text, non_null(:string), description: "Default text")
field(:domain, :string)
field(:locales, ???)
end