Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously only the files that were processed were kept in memory in a
Set
, to prevent circular dependencies. However, it can happen that a file gets imported two or more times, with different imports. To fix this, instead of only keeping track of the processed files, it now also keeps track of which specific imports from the processed files are used.The new test I added illustrates this use-case. This might seem like a far stretch, but if you use Prisma and have separated files, e.g. "user.graphql" and "restaurant.graphql", and use each file to import specific types from "generated/prisma.graphql", you'll walk into this.
It cost me three hours to finally end up with a solution that is less code than before, so I'm very happy with that if I may say so 😅.
An explanation with examples
This is the use-case I'm fixing:
schema.graphql
restaurant.graphql
# import Query.restaurant, Mutation.createRestaurant from "./prisma.graphql"
user.graphql
# import Query.user, Mutation.createUser from "./prisma.graphql"
Actual result
Only
Query.restaurant
andMutation.createRestaurant
get imported,Query.user
andMutation.createUser
are ignored.Expected result
Query.restaurant
,Mutation.createRestaurant
,Query.user
andMutation.createUser
are imported.