I am building an app using Dgraph Cloud and found unexpected behaviour when using fragments. I am not able to use duplicate fragments for a query.
For example I have three different types of banners, and they each use a description. So I have the three types of banners as fragments, and each including a description fragment.
const fragment = graphql`
fragment EntryBanner_entry on Entry {
...EntryBannerWithPoster_entry
...EntryBannerWithBanner_entry
...EntryBannerWithText_entry
}
${EntryBannerWithBannerFragment}
${EntryBannerWithPosterFragment}
${EntryBannerWithTextFragment}
`;
//here is an example of EntryBannerWithTextFragment (note each banner fragment has the description fragment
const fragment = graphql`
fragment EntryBannerWithText_entry on Entry {
title
releaseYear
movieLength
...EntryDescription_entry
}
${EntryDescriptionFragment}
`;
However, since multiple fragments are being joined in EntryBanner_entry
, it causes this error:
There can be only one fragment named "EntryDescription_entry".: {"response":{"errors":[{"message":"There can be only one fragment named \"EntryDescription_entry\".",...}
Having fragments attached to re-usable components is considered a good practice so I am unsure why the query response is erroring.