Strange behaviour with fragment dependencies
znkode opened this issue · 1 comments
znkode commented
Describe the bug
The provided example has three fragment. The first fragment is used inside the second fragment. The third fragment is completely unrelated. Adding an empty array as the fragment dependencies of the first fragment creates the following error in the second fragment: Unknown fragment "CountryFragment1". ts(52001)
. If an empty array is added to the third fragment as well, the error goes away.
Reproduction
https://codesandbox.io/p/github/pascal-zinke/gql-tada-issue/main
gql.tada version
gql.tada 1.2.1
Validations
- I can confirm that this is a bug report, and not a feature request, RFC, question, or discussion, for which GitHub Discussions should be used
- Read the docs.
- Follow our Code of Conduct
znkode commented
I just noticed this happens when the first fragments dependencies is either an empty array
const CountryFragment1 = graphql(
/* GraphQL */ `
fragment CountryFragment1 on Country {
code
}
`,
[]
);
or an array with an imported fragment
import { ImportedCountryFragment } from "./country";
const CountryFragment1 = graphql(
/* GraphQL */ `
fragment CountryFragment1 on Country {
code
...ImportedCountryFragment
}
`,
[ImportedCountryFragment]
);
Again, adding []
to the last fragment fixes all errors.