Apollo codegen duplicating nested fragment imports

475 Views Asked by At

I'm using reusable fragments in .gql files but the resulting query will declare the fragments multiple times when using codegen. A simplified example:

# ImagesInfos.gql
fragment ImageInfos {
  url
  alt
}
#Post.gql
#import './ImageInfos.gql'

fragment Post {
  title
  image {
    ... ImageInfos
  }
  user {
    ... UserInfos
  }

}
#User.gql
#import './ImageInfos.gql'

fragment User {
  name
  image {
    ... ImageInfos
  }
}

But this will result in multiple occurence of the declaration of ImageInfos fragment. How can I avoid this?

0

There are 0 best solutions below