Vovchikan
How to declare :map in Absinthe.Schema.Notation.object/3
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
First Post!
Vovchikan
Solution - Scalar Recipes · absinthe-graphql/absinthe Wiki · GitHub
Usage
defmodule MyApp.Schema.Types do
use Absinthe.Schema.Notation
...
import_types(MyApp.Schema.Types.Custom.JSON)
@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, :json)
end
end
easy ![]()
Popular in Questions
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
In Ruby, I can go:
User.find_by(email: "foobar@email.com").update(email: "hello@email.com")
How can I do something similar in Elixir? ...
New
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
Hello,
I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these
buyer = %{
id: ...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Other popular topics
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Hello!
tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability.
After spen...
New
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
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
I would like to know what is the best IDE for elixir development?
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New







