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

Pruning unused declarations after mutation #839

Open
goto-bus-stop opened this issue Mar 6, 2024 · 1 comment
Open

Pruning unused declarations after mutation #839

goto-bus-stop opened this issue Mar 6, 2024 · 1 comment
Labels
apollo-compiler issues/PRs pertaining to semantic analysis & validation

Comments

@goto-bus-stop
Copy link
Member

When you mutate an executable document, fragments or variables that were previously in use may become unused. Currently the user is responsible for tracking this and pruning the now-unused definitions, otherwise the mutated document is invalid. It's not that trivial to do given that usages may occur anywhere in the document. I think it would be better if apollo-rs can do this. It may just have to be something like document.prune_unused() at the minimum, but maybe we can figure out something more ergonomic (eg. combining validation and pruning into a single method, since you would normally want to do this at the point where you finish mutating and turn your document into a Valid<ExecutableDocument>)

@SimonSapin
Copy link
Contributor

DocumentBuilder in crates/apollo-compiler/src/execution/introspection_split.rs does something similar, but intertwined with traversing/filtering a document and creating another.

@goto-bus-stop goto-bus-stop added the apollo-compiler issues/PRs pertaining to semantic analysis & validation label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apollo-compiler issues/PRs pertaining to semantic analysis & validation
Projects
None yet
Development

No branches or pull requests

2 participants