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

Fix duplicate indentifiers in import statements #4186

Merged
merged 2 commits into from
Jun 8, 2020

Conversation

cahilfoley
Copy link
Contributor

@cahilfoley cahilfoley commented Jun 8, 2020

Related #3990

I had a look into issue #3990 as I was experiencing the same symptoms, the fix proposed in this comment did not work for me as the imports are generated in the visitor-plugin-common package.

In my case it seemed like duplicate fragment identifiers were only generated sometimes, for example I would get something like the below in my generated files (unfortunately it's an internal codebase that I'm not able to share - I believe this comment references a codebase that can reproduce the bug):

import {
  aFieldsFragment, // used multiple times in the queries, single import
  bFieldsFragment, // also used multiple times in the query, import duplicated belowk,,,,
  cFieldsFragment,
  bFieldsFragment,
  cFieldsFragment,
  dFieldsFragment,
} from '../../services/queries.generated'

This change deduplicates the list of import identifiers prior to being joined in the import statement. After making the change I get the expected, valid import statement generated.

dotansimha and others added 2 commits June 8, 2020 12:08
Any identical entries in the imports would be invalid code, converting to a set first resolves the issue.

Resolves dotansimha#3990
@dotansimha dotansimha force-pushed the master branch 3 times, most recently from 2aa2243 to 4a5af11 Compare June 8, 2020 12:41
@dotansimha
Copy link
Owner

Perfect :) thanks @cahilfoley !

@dotansimha dotansimha merged commit 2030312 into dotansimha:master Jun 8, 2020
@theguild-bot
Copy link
Collaborator

The latest changes of this PR are available as alpha in npm: 1.15.2-alpha-2030312e.0

Quickly update your package.json by running:

npx match-version @graphql-codegen 1.15.2-alpha-2030312e.0

@cahilfoley cahilfoley deleted the patch-1 branch June 9, 2020 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants