Graphql-code-generator: [near-operation-file-preset] not deduping fragment imports on 1.5.0

Created on 14 Aug 2019  路  9Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug
Using near-operation-file-preset with the option dedupeOperationSuffix: true is not deduping imported fragments. The generated fragment is deduped allright, only the import is wrong.

To Reproduce
https://codesandbox.io/s/graphql-codegen-issue-template-ezsqb
Check the UserQuery.generated.tsx file to see the bug in action.

bug plugins waiting-for-release

All 9 comments

I think #2371 will fix it;
I tried it with the canary version; 1.5.1-alpha-932d25c7.46+932d25c7
https://codesandbox.io/s/graphql-codegen-issue-template-e7qf7

Fixed in 1.6.0

Hi! First let me tell you you are doing an awesome job here. I love this project.

Please let me revive this issue. I am still reproducing it at 1.12.1

To Reproduce
https://codesandbox.io/s/dedupefragmentissue-h2ewr
Check the file getUser.generated.ts

I second that, dedupeOperationSuffix not generating the correct import statement with near-operation-file-preset at 1.12.2

Confirmed. Reopened :)

I managed to fix that in: https://github.com/dotansimha/graphql-code-generator/pull/3487

Note: You need to move dedupeOperationSuffix flag upper in the config hierarchy, otherwise the preset won't be able to know it's set.

Tested in your sandbox with latest alpha (1.12.3-alpha-06631dad.18) and updated config (https://codesandbox.io/s/dedupefragmentissue-ck18z) and it seems to work. The generated file is now:

import * as Types from './src/types';

import { UserFragmentDoc, UserFragment } from './userFragment.generated';


export type UserQueryVariables = {};


export type UserQuery = (
  { __typename?: 'Query' }
  & { user: (
    { __typename?: 'User' }
    & UserFragment
  ) }
);

@wassim-k
@CarlosGines

Thanks @dotansimha for the quick fix!

Fixed in v1.13.0

Was this page helpful?
0 / 5 - 0 ratings