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

[Suggestion] SubGraph-specific context type with subgraph plugin #1208

Open
AndrewIngram opened this issue May 30, 2024 · 1 comment
Open
Labels
enhancement New feature or request needs-api-design

Comments

@AndrewIngram
Copy link

We're trying out the subgraph plugin, as we have two schemas. They actually have different context shapes (not drastically so, but enough that we've given them different TypeScript types), at the moment I'm supporting this by having the Pothos context type being a union of the two, but this leaves me having to manually write discriminator code in resolvers to determine which is applicable. It'd be useful if we could define the context type per subgraph, such that the context arg is as narrow as possible.

@hayes
Copy link
Owner

hayes commented May 30, 2024

Unfortunately this isn't easy to do from a technical perspective. Plugins don't have an easy way to affect resolver types without creating custom methods.

The scope-auth plugin can change contexts but it does it through one of 2 methods:

Using a t.withAuth({ ...scopes }).field or t.authField to define fields with changed contexts. We could potentially copy that pattern, but just doing it automatically on normal field definitions isn't possible

@hayes hayes added enhancement New feature or request needs-api-design labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-api-design
Projects
None yet
Development

No branches or pull requests

2 participants