Enforce use of resolving with a method and not the field resolve: keyword argument
About
Where our GraphQL fields have some custom resolving logic, we currently use one of two methods to do this.
1) the resolve: keyword argument:
field :foo, resolve: -> (obj, args, ctx) { ... }
2) or a method:
field :foo
def foo
# ...
end
Proposal
We enforce the use of the method. This is because:
- It would be nice to have consistency
- The
resolve:proc often ignores most of the arguments passed to it (we generally receive them as(obj, _args, _ctx))
We should:
- Convert all
resolve:keyword arguments to methods - Document this
- Add a cop to enforce this
Edited by 🤖 GitLab Bot 🤖