Skip to content
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

Add many-to-many fields on polymorphic interface types #94

Open
wants to merge 3 commits into
base: v5
Choose a base branch
from

Conversation

jvandermey
Copy link

@jvandermey jvandermey commented Dec 19, 2024

Most of this is just refactoring to prevent duplication when extending the fields . It also removes some inlining for clarity.

This will add GQL fields (this will be additive, so should not be breaking) for any schemas that include junction tables with polymorphic tables.

The final commit includes a test for polymorphic junctions to polymorphic union interfaces. The plugin doesn't currently support adding these relationship fields on the interface, but this is something that I hope to add in the future.

Josiah VanderMey added 3 commits December 19, 2024 12:44
Most of this is just refactoring to prevent duplication and remove
some inlining for clarity.
Comment on lines +63 to +84
-- TODO: At the moment, relationships do not include polymorphic interfaces.
-- As a result, the following annotations do not produce many-to-many relationships
-- on the Person interface.
COMMENT ON TYPE j.team_membership IS $$
@interface mode:union
@name TeamMembership
@behavior node
@ref member to:Person singular
@ref team to:Team singular
$$;

COMMENT ON TABLE j.internal_team_membership IS $$
@implements TeamMembership
@ref member via:(person_id)->j.internal_employee(id) singular
@ref team via:(team_id)->j.team(id) singular
$$;

COMMENT ON TABLE j.external_team_membership IS $$
@implements TeamMembership
@ref member via:(person_id)->j.external_person(id) singular
@ref team via:(team_id)->j.team(id) singular
$$;
Copy link
Author

Choose a reason for hiding this comment

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

@benjie , something like this is how I was envisioning that this would work for union interface types. Does this approach make sense to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant