3

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?

rayfranco
  • 3,630
  • 3
  • 26
  • 38

0 Answers0