Skip to content

Proposal: ariadne-relay #374

@markedwards

Description

@markedwards

@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 a ConnectionType class, as a subclass of ariadne.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 a set_count_resolver() method and a count_resolver decorator to allow for control over how the count is derived.
  • ariadne-relay will provide a NodeType class, as a subclass of Ariadne.InterfaceType, which will help with the formation of ID values, leveraging the methods in graphql-relay-py. This class will have a set_id_value_resolver() method and a id_value_resolver decorator to allow for control over how ids are derived.
  • I haven't worked yet with graphql_relay.mutation so 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions