Hi!, is loads: in argument are only available from mutation classes?. because right now I'm using it in input objects and I'm getting an error of unknown keyword: loads. Thanks for the help. 馃槃
Yeah, it's currently only implemented for mutations. It could be added for input objects probably, with a bit of work.
Hey, @rmosolgo any work/progress on this? I don't mind working on a PR for this. I have just encountered a similar situation at work, trying to use the loads argument in the input object type.
I assume that the work involved here would be to reimplement the loads logic in the resolvers class for input objects -
Let me know if you had better ideas. 馃槃
Hi! No, I haven't done any work on it, I'd be happy to review a PR sometime though!
Sweet! I created a PR https://github.com/rmosolgo/graphql-ruby/pull/2080
I welcome any early feedback on the initial refactor... Thanks
Hey @lemuelbarango, what happened to close the PR?
@duderamos I've reopened the PR. was a mistake
No worries @lemuelbarango. I don't know if it helps, but I tested a scenario on my end and using prepare param seems enough:
https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/schema/argument.rb#L31
In my case, I have something like this:
module Foo
class UpdateBarAttributes < Types::BaseInputObject
argument :my_object_id, ID, required: true, prepare: :load_object
end
end
module Types
class BaseInputObject < GraphQL::Schema::InputObject
def load_object(encoded_id)
MySchema.object_from_id(encoded_id)
end
end
end
So I just need to append prepare: :load_object to my ID arguments.
@duderamos Yeah, I didn't know there was a prepare param on the InputObject. That's good to know.
Most helpful comment
Yeah, it's currently only implemented for mutations. It could be added for input objects probably, with a bit of work.