Closed gottfrois closed 7 years ago
@gottfrois is an interesting suggestion but I think It would need to break the current API, since argument
already can take a block: https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/argument.rb#L98.
@pabloh thanks for the quick response, that's a shame, what's the purpose of this block exactly?
It's part of graphql-ruby's definitions DSL to be able to define properties using a block instead of plain ruby method arguments.
Anyway, you could probably handle this use case by defining an inline InputObjectType
for your :filter
argument's type.
@pabloh sounds promising, can you paste some code sample please? not sure how that would look like
Types::PostType = GraphQL::ObjectType.define do
field :posts, Types::PostType do
argument :filter, GraphQL::InputObjectType.define {
argument :published, types.Boolea
}
end
end
@gottfrois, I think you should close this there's already a lot of other issues opened...
Would be nice to be able to define an argument object type without explicitely having to create a type for it.
Consider the following example:
Which makes the following query possible:
Now, I run into some usecases where the
filter
definition is coupled to the field. For example I could allow to filter againstpublished
in this case but not in another case.I'm thinking it would be easier to manage those filters if we could pass an anonymous block to the
argument
:What do you think?