-
Notifications
You must be signed in to change notification settings - Fork 190
Description
@rafalp and @patrys, I dropped a comment on #188 a couple of weeks ago, but I think it might have gone under the radar since that issue is closed, so I'm going to make a more formal proposal here.
I've already built a quick-and-dirty implementation for Relay connections, based on a decorator that wraps an ObjectType resolver that emits a Sequence. The implementation resolves the connection using graphql-relay-py. It works well, but its too specific to my case to be offered as a generalized implementation.
I agree with the assessment in #188 that the right path forward here is for there to be an independent ariadne-relay package. It seems reasonable to build it on top of graphql-relay-py so it is synchronised closely to the reference Relay codebase. I'm willing to take ownership of this project, but I want to introduce the approach I have in mind here for comment, prior to doing further work.
Proposed implementation:
ariadne-relay will provide aConnectionTypeclass, as a subclass ofariadne.ObjectType, which takes care of the boilerplate glue between an iterable/sliceable object returned by another resolver and graphql-relay-py. This class will have aset_count_resolver()method and acount_resolverdecorator to allow for control over how the count is derived.- ariadne-relay will provide a
NodeTypeclass, as a subclass ofAriadne.InterfaceType, which will help with the formation ofIDvalues, leveraging the methods in graphql-relay-py. This class will have aset_id_value_resolver()method and aid_value_resolverdecorator to allow for control over how ids are derived. - I haven't worked yet with
graphql_relay.mutationso I'm not sure how that might be leveraged, but at a glance it seems like it should be possible to do something useful here. - ariadne-relay will adhere to Ariadne's dev and coding standards, so it stays a close cousin.
Does this seems like a reasonable basic direction? It seems from #188 that you guys have put a bit of consideration into this already, so perhaps you have some insight that I'm missing?