Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Duplicate imports generated when overrides export an interface with the same name #340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

apalm
Copy link

@apalm apalm commented Dec 12, 2018

Currently, if two or more overrides each export an interface with the same name, duplicate imports are generated. I added a test that demonstrates this: https://github.com/prisma/graphqlgen/compare/master...apalm:override-model-dupes?expand=1#diff-f86c01cb4fc0fd4ae178ca2f4527a870R1767.

I have a (rough) fix for this locally, by aliasing the imports, but before iterating further, I wanted to confirm that overrides that export interfaces with the same name should be supported, and that the current behavior is a bug.

Currently, this causes code with duplicate imports to be generated.
@Weakky
Copy link
Contributor

Weakky commented Dec 18, 2018

Hey apalm 👋,

I can confirm this is a bug as we should at least throw an error if we didn't intend to allow several models with the same name!

The question is whether we want or don't want to allow such behavior. AFAIK, there may be valid use-cases where one would want to do that if files are used as "namespaces", and two models represent the same concept in two different contexts. eg: One could have several model Permission, all expressing different types of permissions in different contexts.

Therefore, unless someone disagrees, you're free to continue iterating on that if you still want 🙌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants