-
Notifications
You must be signed in to change notification settings - Fork 344
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
Bug: FilterSchema does't remove type when all fields filtered (Unit tests is incorrect) #1474
Comments
@yaacovCR Should we remove the type when it has no fields on it? Or do you have any suggestion for this error? |
If you decide not to remove the type by default. I would suggest either:
|
@ntziolis We just need to decide if we should remove empty types or remove them explicitly in another transform. |
You can use pruneSchema after filterSchema. |
@ntziolis Did you try to filter the type itself instead of emptying it? filterSchema:
- !Mutation |
Available in |
Wow, you guys are fast. I can confirm that its now working as excepted. Thank you. @ardatan Not sure if it still matters, but yes I think we did try |
Making sure this is not an unintended side effect:
The mesh starts correctly and I think this would also be the desired behavior. However when:
This seems like it could be source of surprises for people. Out of curiosity: Somewhat related to: |
The idea is to remove empty types so the fields and arguments that use this type when it is removed.
The second one looks like a different bug. Could you share a reproduction for the second one so we can decide if the issue is on Mesh side or
https://github.com/Urigo/graphql-mesh/blob/master/packages/transforms/filter-schema/src/index.ts#L39 |
This test description implies that a type should be filtered out when all fields of the type are filtered out.
https://github.com/Urigo/graphql-mesh/blob/21643d748cac4ed95663f4f41f536aec4dcce02c/packages/transforms/filter-schema/test/transform.spec.ts#L68
However in the string the unit tests checks against the type still does exist:
https://github.com/Urigo/graphql-mesh/blob/21643d748cac4ed95663f4f41f536aec4dcce02c/packages/transforms/filter-schema/test/transform.spec.ts#L97
In our case we want to filter out ALL mutations. However because the Mutation type is "left-over" we get the following error:
Error: Type Mutation must define one or more fields.
When leaving at least one field within the Mutation type everything works as expected.
What we expected would happen is that the entire Mutation type would be removed. If this is not the expected behavior, how could we achieve this?
Our setup:
The text was updated successfully, but these errors were encountered: