Open doomsower opened 3 years ago
Thank you for reporting this @doomsower . Can you please share a live reproduction of that issue?
So I think I have been running into the same issue. The key here is we have a union type that we spread/use within a fragment. This generates a new fragment type that ends up being not exported. @dotansimha I've created a simple reproduction (probably could be reduced more, but this matches my usecase). https://github.com/pachuka/graphql-union-exports
Basically I have a fragment that spreads a union type of PersonalLinesCustomer
and BusinessLinesCustomer
and you can see in the client.ts
that the generated CustomerBusinessLinesCustomerFragment
and CustomerPersonalLinesCustomerFragment
are not exported so they can't be used explicitly when using discriminating unions.
NOTE: the fact that I'm using an existing fragment definition inside my spread doesn't seem to matter much, which is also interesting, but can reproduce this scenario without that as well.
In certain scenarios I know its only going to be one of the implementations so I want to be able to cast it explicitly as that (even though arguably that's unsafe), but since those generated fragment types are not exported, I am unable to do that.
@dotansimha Any updates on that?
Describe the bug
I have a monorepo in which I define schema and common fragments in one package `@myorg/schema`, and then use the schema and these fragments in other packages. The schema contains interface, implementing types and a fragment on this interface (see below). Generated fragment in `@myorg/schema` packages produces following code: ```ts type TimestampedMeta_Media_Fragment = { __typename?: 'Media'; createdAt?: Types.Maybe@myorg/schema
):This fragment is defined in
@myorg/schema
packageThis query is defined in
@myorg/clients
packagecodegen.yml
config file:Expected behavior
I expect types like
TimestampedMeta_Media_Fragment
to be exported, so that I can consume them in another package.Environment:
Additional context