`Ash.Type.NewType` defines multiple GraphQL types with the same name.
I have the following custom type
That is used in two resources
Also I've defined a Scalar and imported it to schema
9 Replies
When I try to run it I get the following message:
- When I use another custom type that does not use
NewType
everything works fine.
- When I remove my custom scalar there's one Location
less in the error log
- Before I've added def graphql_type, do: :day_of_week
, there was more errors with less Locations
per error
- Just to be sure I've added config :ash_graphql, :default_managed_relationship_type_name_template, :action_name
per some other issue here but it did not help in any way
Used Versions:
- Ash - 2.6.28
- Ash Graphql - 0.23.1Interesting…I think we’re missing an
Enum.uniq
somewhere
Will look into this later today.
So to double check
this issue persists even when you remove your manual type?
You shouldn't have to add that type, BTW, Ash will do the enum definitionNo, when I change this type to another custom type in resources attribute definition, that do not use
Ash.Type.NewType
it's working normally, so I think it's specific to Ash.Type.NewType
Well, what I'm getting at is removing this:
Yeah, colleague just reminded my about
Ash.Type.Enum
in the code review, so I've switched to that now
Removing that, for me removes just one of 5 Locations
from the warning🤔 very interesting
Okay I just released
0.23.2
that should fix the issue
Well, it might 😄Sadly this didn't fix it.
After some debugging I think it's because the NewType is being defined per resource as we can see in
resource.ex:2297
.
I've inserted IO.inspect
into get_auto_enums
and after resource.ex:2342
and when my type was based on Ash.Type.NewType
it was in these inspects, but when I've switched back to Ash.Type.Enum
it wasn't.
I'm guessing that it's being treated as "inline enum", so when you defined enum like this:
because in these inspects I see "types" that are defined like this, the main difference is that for those it has unique name per resource.
It would work without defining def graphql_input
, but for some reason to types defined like that the _input
postfix isn't added like to those "inline enums", so there are same atoms returned for type_name
and additional_type_name
in resource.ex:2304
.
When def graphql_input
is defined, it uses this name everywhere, so there are more Locations
with conflicts for Absinthe, as seen before.Ah, okay interesting. So I think what we need to do is basically not include that as an "auto enum" if it has a type name, and instead define those up front.
@Myrmyr I won't have time to fix this immediately, and using
Ash.Type.Enum
is a workaround, right? If so, would you mind opening an issue in ash_graphql
so we can track this/improve it later?I would say that using
Ash.Type.Enum
is the proper solution rather than a workaround but yeah, it works. Sure, I'm on it.