Enforce use of resolving with a method and not the field resolve:
keyword argument
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
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 🤖