-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Makes PageInfo and Edge public to make custom connections easier #107
Makes PageInfo and Edge public to make custom connections easier #107
Conversation
No huge downsides - this pattern follows the relay's pagination spec, which seems pretty stable and well-known. That said, making these public does increase our public API surface area. Could you explain your use case a little more? Are you reaching for these types because |
My main motivation is to create custom connections and edges with additional fields, but still be able to leverage some of the Graphiti connections code. For example, I'd like a connection to have a As for edges, I could see a use case like described here Some of the slicing related code code could also be useful to be public, but I started with the minimal amount. |
It's possible there's a better way to do this without exposing more of the API. There are other issues with the connections implementation too, such as you can't do a connection of a interfaces or union. I've gotten around this by creating a wrapper type to serve as the Node, but this is not ideal long term. In summary, it would be useful if connections allowed more customization and also allowed protocols as the node. |
Another example of custom connections is the Github GraphQL API. They tend to add extra fields for most of their connections and edges. The thing is though the slicing and cursor logic would still be the same as the default connection type. Same with the PageInfo type. @NeedleInAJayStack what are your thoughts on this? |
@cshadek Cool, thanks for the info. I just worked through some of the details of supporting custom fields on these types and yeah, I think we'll probably want to expose these as public. Connections have been under-tested and under-documented in this package, so I'll be adding more of that soon. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also make the edges
and pageInfo
properties on Connection
public?
Co-authored-by: Jay Herron <30518755+NeedleInAJayStack@users.noreply.github.com>
@NeedleInAJayStack I added your suggestions. I think it should be ready to merge. |
This is a really small change, but it makes several Connection related types public including PageInfo, Edgeable, and Edge, so they can be used in custom connections.
My main concern is
PageInfo
because I want to create a custom connection, and right nowPageInfo
is internal and gets added to the schema automatically when using the default connections. I figuredEdgeable
andEdge
may be useful too. It's possible much more of the Connection API could be made public as well.Are there any downsides to doing this?