Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Conversation

@brennemankyle
Copy link
Collaborator

allow subclassing Connection without having to instantiate abstract constants in an abstract subclass
aka Connection > SqlConnection > UserConnection (don't require SqlConnection to have to instantiate TNode)

Also make TNode abstract type enforceable

*
* This should be the Hack class over which you want to paginate.
*/
<<__Enforceable>>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be enforceable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's not enforceable I cannot do this in SqlConnection class $node as this::TNode
https://slack-github.com/slack/webapp/pull/128988/files#diff-eeef89f255be1dec860c0b1f779fe2eba85adfebf64bfe7e7c70ab8fef4a8703R47

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don’t follow. Looking at that code you shared, $node as this::TNode will explode whenever this::TNode != this::TSqlNode and is a no-op whenever this::Node == this::TSqlNode. No?

$rc = new \ReflectionClass($class->getName());
if (
\is_subclass_of($class->getName(), \Slack\GraphQL\Pagination\Connection::class) &&
$rc->getAttributeClass(\Slack\GraphQL\ObjectType::class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Should we get a test that this works? E.g., add a FooConnection abstract class subclassing Connection, and a BarConnection concrete class subclassing FooConnection and annotated with ObjectType?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yeah not really sure where/ how to add this to a test? I added a fixture with sublcassing, but what file do I test it in?

Copy link
Collaborator

@ianhoffman ianhoffman Feb 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking that the codegen looks correct should be fine!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm how do I do that? sorry not familiar with out this sort of testing works

Copy link
Collaborator

@ianhoffman ianhoffman Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically:

  • Add the appropriate connection classes to tests/Fixtures.
  • Run tests using make test. This will do the codegen.
  • Look at the generated files and confirm they look correct. E.g., if you declared an abstract FooConnection and a concrete BarConnection, we should end up with one generated class in a BarConnection.hack.

Also happy to pair!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also have failing tests... we'll need to annotate UserConnection.hack with the ObjectType attribute, and ideally look at that attribute in Generator::getConnectionObjects. Again, happy to pair.

* @see https://relay.dev/graphql/connections.htm for more information about GraphQL pagination.
* @see src/playground/UserConnection.hack for an example.
*/
<<GraphQL\ObjectType('Connection', 'Connection')>>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually realize this isn't necessary. We don't generate a GQL object for Connection so we don't need to tag the class with this attribute.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Kyle Brenneman seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants