How to re-use a resource as an argument type inside {:array, ...} ?
This does not work:
And the only constraint I can see that affects the items inside is nil_items?
If I use a custom type I need to wrap it one extra layer so that isnt the same as this..
Anyone got any ideas?
Solution:Jump to solution
You can make a map type and set
graphql_define_type?
to false, and graphql_input_type
to something like {:list, :some_input}
22 Replies
ohhh
I knew it tickled my memory
not implemented in ash_graphql apparently 😄

do you think its feasible to get that implemented? if you had to guess an effort level 1-10
I could take a crack at it
I have a bunch of these bulk manual actions where we just want to make changesets and validate them as a preprocess step
oh
no thats never really going to work
you'll need to make a custom map type w/ the inputs you want
yeah
Is there a way to just re-use the existing graphql type as an input for a generic action? like I could type it as :map and it would work, but I want the action to have the type signature of the ArchitecturalElementInput that the create action already made
there seems to be a gap here where you can make custom types and use them, but you cant re-use types across actions I think
I am not understanding how to do it with current escape hatches
if you can give a good dsl suggestion I can do the implementation
I was thinking
then you can just return :map and we can resolve as-is
maybe return_type_override
(this comes from not being able to make bulk create mappings for :create btw)
or, partially, I still need the generic for the bulk validate step
Input types and types are not the same thing
Accepting the result of a create action doesn't really make sense
You want to accept some input to a create action.
yeah sorry that was a brainfart, we need it somewhere in the argument dsl
is there a way in spark to have one plugin adjust another thing by giving it more options?
Solution
You can make a map type and set
graphql_define_type?
to false, and graphql_input_type
to something like {:list, :some_input}
On my phone so can't type it out
ahhh, that works
so basically just set a bogus type that is empty
and then reuse the generated type
trying that right now
is there a setting to not have ash validate the type btw? so that it doesn't go boom if I send data through it
what?
😆
haha
ahhh lol
if you dont put fields in constraints
it wont validate anything but it being a map
thats where my disconnect was
I am having this conversation at the same time I am making sure my two year old doesn't die from climbing the couch :p
brb, making
ash_child_care
hahaha
I'll be alpha tester
I'll pr up a blurb about this workaround in the graphql docs on using your own types
the docs are almost there, just missing some pieces
Its also not really ideal because it only works if you define that type in your GraphQL API somewhere
its very brittle
I cant just specify the one that is generated?
what would be better is to be able to use something like
{:action_input, Resource, :action}
you can
but what I'm saying is that if you were to then go and remove the create/update action or w/e that you're usingyeah then it goes back to jsonstring
then this workaround would break
Everything worked as a charm
I could also metaprogram this with ash resource info I guess
probably yes