sezaru
I have a field in a resource that can be an union of two embedded resources. One of these resources have no attributes:
defmodule Core.Marketplace.Payments.Product.Types.Metadata do
@moduledoc false
alias Core.Marketplace.Payments.Product.Types
use AshGraphql.Type
use Ash.Type.NewType,
subtype_of: :union,
constraints: [
types: [
credits: [type: Types.Credits, tag: :type, tag_value: :credits],
one_time_use: [type: Types.OneTimeUse, tag: :type, tag_value: :one_time_use]
]
]
def graphql_type(_), do: :payments_product_metadata
end
defmodule Core.Marketplace.Payments.Product.Types.Credits do
@moduledoc false
use Ash.Resource,
data_layer: :embedded,
extensions: [AshGraphql.Resource]
attributes do
attribute :skip_trace, :integer do
allow_nil? false
public? true
default 0
constraints min: 0
end
attribute :export, :integer do
allow_nil? false
public? true
default 0
constraints min: 0
end
end
graphql do
type :payments_product_credits
end
end
defmodule Core.Marketplace.Payments.Product.Types.OneTimeUse do
@moduledoc false
use Ash.Resource,
data_layer: :embedded,
extensions: [AshGraphql.Resource]
attributes do
end
graphql do
type :payments_product_one_time_use
end
end
As you can see, OneTimeUse doesn’t have any fields, without AshGraphQL it works fine, but when I add the AshGraphql.Resource to it, I get this error:
== Compilation error in file lib/core/graphql/schema.ex ==
** (RuntimeError) The resource Core.Marketplace.Payments.Product.Types.OneTimeUse does not have any visible fields in GraphQL.
This typically means that there are no public fields on the resource in question.
(ash_graphql 1.8.3) lib/resource/resource.ex:4155: AshGraphql.Resource.type_definition/5
(ash_graphql 1.8.3) lib/ash_graphql.ex:1089: anonymous fn/3 in AshGraphql.get_embedded_types/4
(elixir 1.18.4) lib/enum.ex:4442: Enum.flat_map_list/2
(elixir 1.18.4) lib/enum.ex:4446: Enum.flat_map_list/2
(ash_graphql 1.8.3) lib/ash_graphql.ex:1085: AshGraphql.get_embedded_types/4
(core 1.230.2) deps/ash_graphql/lib/ash_graphql.ex:285: Core.Marketplace.Dispositions.AshTypes.run/2
(absinthe 1.7.10) lib/absinthe/pipeline.ex:408: Absinthe.Pipeline.run_phase/3
(absinthe 1.7.10) lib/absinthe/schema.ex:408: Absinthe.Schema.__after_compile__/2
(stdlib 6.2.2.2) lists.erl:2146: :lists.foldl/3
(elixir 1.18.4) lib/kernel/parallel_compiler.ex:423: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8
Compiling 18 files (.ex)
Compiling lib/core/marketplace/ap/appointment.ex (it's taking more than 10s)
Compiling lib/core/marketplace/accounts/user.ex (it's taking more than 10s)
The error is clear, but can’t I workaround it somehow? Adding fields to that resource doesn’t make sense in this context as the struct itself already has enough information for my case.
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zachdaniel
:one_time_usefor example?sezaru
I can do that, but I would prefer it to be a struct to make my functions matches more “consise”
Is there any technical reason for AshGraphql not support empty embedded resources? Without AshGraphql it works just fine.
zachdaniel
I think its not possible to make that type in GraphQL unfortunately.