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

Allow override of federation directives #1126

Merged
merged 3 commits into from
Jan 28, 2024

Conversation

TimboTambo
Copy link
Contributor

See issue 1125.

Copy link

changeset-bot bot commented Jan 7, 2024

🦋 Changeset detected

Latest commit: 69ae78c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@pothos/plugin-federation Minor
@pothos-examples/prisma-federation Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jan 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pothos ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2024 10:10am

Copy link
Owner

@hayes hayes left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I think in general this makes sense, but I think this would be a good time to make things a little more consistent between features (right now composeDirective and interfaceObject are treated differently without any specific reason

'@authenticated',
'@policy',
'@requiresScopes',
...federationDirectives,
options.composeDirectives ? '@composeDirective' : null,
hasInterfaceObjects ? '@interfaceObject' : null,
Copy link
Owner

Choose a reason for hiding this comment

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

I think potentially it might make more sense to have authenticated, requiresScopes, and policy, and maybe even all the directives work like composeDirective and interfaceObject where they are only imported when used. I think being able to explicitly add your own directives is good, but I think we should potentially just auto-import any directive that gets used through a plugin feature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, makes sense - is there a simple way to derive at this point which of these directives have been used, either via (e.g.) the requiresScopes option or the directives array on each query/ mutation/ enum/ etc...?

Copy link
Owner

Choose a reason for hiding this comment

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

Not yet, I can try to find some time in the next few days to add something like that. I think it would probably be easiest to track that as the directives are added into the schema in the plugin class

@hayes hayes merged commit 953f0db into hayes:main Jan 28, 2024
4 checks passed
@hayes
Copy link
Owner

hayes commented Jan 28, 2024

Added some logic to track what directives are used, and defaulted the imported directives to only import what is used

@@ -265,7 +264,7 @@ builder.asEntity(Media, {

See federation documentation for more details on `interfaceObject`s

### composeDirective
### composeDirective =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this = a typo?

Copy link
Owner

Choose a reason for hiding this comment

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

Yup, not sure where that come from

Copy link
Owner

Choose a reason for hiding this comment

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

Looks like it was already in the Readme, which I copied here to keep it in sync

@TimboTambo
Copy link
Contributor Author

Added some logic to track what directives are used, and defaulted the imported directives to only import what is used

Awesome! Going to be using this straight away. Thanks.

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.

2 participants