Any way to make the generated graphql schema
notcreate specific types for re-used objects, or merge them in a union? Would be so nice to be able to actually re-use fragments without each being uniquely typed.
Right now, given a field that is a group:
const groupField: Field = { type: 'group', name; 'repeated', fields: [...]}
using
groupField
in different collections, say
User
and
Post
will yield
User_Group
and
Post_Group
types, and not being collected in a union type, I can't really reuse a fragment for it in my gql-queries.
I can't think of a way you could do this without some changes.
In what you described, we are doing this for graphQL blocks I believe, but it can't be copied for groups as they aren't re-used in a meaningful way. Suppose the Payload GraphQL schema generation tried to make types for every group it would be a mess of unnecessarily granular types. When names are the same as another group you'd either end up with a union of identical schemas repeated when fields are the same, or we'd need some way of comparing that the field names and types are in fact the same and iterating on the schema name.
This sounds quite messy to do well. The only way I can think to have it work would be to add a config option for the graphQL name to groups and named tabs which would make it both—
A) Provide a nice way for devs to name their composable schemas parts only when needed, and
B) Add intention so devs can either make it work or fall on their own sword if they mess it up with a duplicate name that actually has different fields.
It is an interesting question. If you think there is a path forward on how this might work, you could create a Github discussion to try and gain traction. If there is a will to build it from the community, that would help, but as it stands this isn't going to be prioritized by our team.