JosipSylo
By reading through previous questions and issues I converted my schemas from using a “many_to_many” to “has_many” and “belongs_to” in order to get the extra field from the join table. Now I’m a little bit stuck and not sure how to access it using Absinthe.
I have “users” and a “feedbacks”. It is a many to many relationship through the “users__feedbacks” table.
“users__feedbacks” table also has an extra field called “is_published”. How can I get that field in my graphql query?
These are my schemas:
schema "users" do
field :first_name, :string
has_many :users__feedbacks, App.Feedbacks.Users_Feedback
has_many :feedbacks_as_reviewer, through: [:users__feedbacks, :feedback]
timestamps()
end
schema "feedbacks" do
field :title, :string
has_many :users__feedbacks, App.Feedbacks.Users_Feedback
has_many :reviewers, through: [:users__feedbacks, :user]
timestamps()
end
schema "users__feedbacks" do
belongs_to :user, Accounts.User
belongs_to :feedback, Feedbacks.Feedback
field :is_published, :boolean
timestamps()
end
These are my graphql query types
object :user do
field :id, non_null(:id)
field :first_name, :string
field :feedbacks_as_reviewer, list_of(:feedback), resolve: dataloader(:db)
end
object :feedback do
field :id, non_null(:id)
field :title, non_null(:string)
field :reviewers, list_of(:user), resolve: dataloader(:db)
end
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
Hi @JosipSylo welcome!
I think your best option is to create an intermediate object with a name that reflects what’s going on. Based on your sketch of the domain, I think the
users__fedbackstable is really a “feedback_reviews” table. This doesn’t mean you need to rename it, but you can name your associations better, and expose GraphQL objects named that way:You can make your life easier by naming your ecto associations that way too, they don’t need to match the table name, you can do:
has_many :feedback_reviews, App.Feedbacks.Users_Feedback. and so on.JosipSylo
Thank you for the feedback @benwilson512 . I ended up restructuring things as you suggested and it made things a lot more readable.