-
-
Notifications
You must be signed in to change notification settings - Fork 823
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
PruneSchema does not prune unused implementations of a returned interface #4819
Comments
As for a solution, that's a tough one. The culprit of this issue is this line in This was introduced in #4442, however, I am not sure why that line exists at all. Could someone please provide an explanation for it? Can't really understand if from the comment alone. |
What if |
Maybe its harder to understand as a simple example like this, but in our real world usage, the type is indeed never used, but does not get pruned, let me find a better example perhaps |
Let's imagine the following original schema: type Query {
getCart: Cart
getExtensions: [Extension!]!
}
type Cart implements Versioned {
price: Int!
id: String!
version: Int!
created_at: String!
last_modified_at: String!
created_by: ID!
last_modified_by: ID!
}
type Extension implements Versioned {
name: String!
id: String!
version: Int!
created_at: String!
last_modified_at: String!
created_by: ID!
last_modified_by: ID!
}
interface Versioned {
id: String!
version: Int!
created_at: String!
last_modified_at: String!
created_by: ID!
last_modified_by: ID!
} now lets imagine that I only want the query I now understand that in some cases, it could lead to breaking the app, thank you, but in this case it would never happen and it is not desirable to filter the unwanted types as there are literally thousands of them, maybe its not a bug and maybe a feature request? Hopefully you can understand, thank you. |
maybe one way of doing this would be to have an option called something like |
This is not the same. If a field returns an interface, that means it can return any type implementing that interface so if we prune a type that is not referenced anywhere else, this would break. |
Ah got it, that makes sense thank you, would it then be possible to achieve the example above using something else or do we have to filter these unwanted types manually? |
@NullScope Sorry for the late response but my answer is yes. Unwanted types should be filtered manually. |
No problem, thank you for the reply |
Issue workflow progress
Progress of the issue based on the Contributor Workflow
Describe the bug
The
PruneSchema
utility function, and consequently, thePruneSchema
transform, does not prune unused types that implement interfaces that are returned from an operation or used as field types.To Reproduce
Steps to reproduce the behavior:
Here is a unit test for
prune.test.ts
:Expected behavior
Unused types should be pruned.
Environment:
@graphql-tools/utils
: 9.0.1Additional context
This is very important for this project, as the schema that is being transformed and then pruned has literally thousands of types, most of which (around 60%) is unused
The text was updated successfully, but these errors were encountered: