Hi,
I found two problems with fragments for the Angular template. This is an extract of the generated code:
const InvoiceCheckResultFragment = gql`
fragment InvoiceCheckResult on InvoiceCheckResult {
rowsWithUnknownProductCodes
unknownShippings {
...InvoiceShipping
}
shippingsThatWereChargedMultipleTimes
shippings {
...InvoiceShipping
}
}
${InvoiceShippingFragment}
${InvoiceShippingFragment}
`;
...
const InvoiceShippingFragment = gql`
fragment InvoiceShipping on InvoiceShipping {
rowsWithUnknownProductCodes
invoiceNumber
....
The first one is the same one that you have fixed in #591 for react (fragment definition order). TypeScript spits out the error
error TS2448: Block-scoped variable 'InvoiceShippingFragment' used before its declaration.
The second problem is that fragments that are referenced twice are included twice in the gql-string. In this case, this is InvoiceShippingFragment.
@kamilkisiela
duplicated fragments (test + fix): https://github.com/dotansimha/graphql-code-generator/pull/614
wrong order of fragments (test + fix): https://github.com/dotansimha/graphql-code-generator/pull/615
I didn't use a getter function because it doesn't fix an issue with TypeScript screaming about the order of declarations. I create dependency graph to resolve them in the proper order.
About duplicated fragments, now it checks if it was declared and skips it.
Fixed in 0.12.3 :)
v0.12.3 is out
Tested it -> fixed :-)
Thanks a lot!
Most helpful comment
Tested it -> fixed :-)
Thanks a lot!