We have a lot of subgraphs, most of them pretty small where we make use of the entity unions / extending entities across subgraphs. However I have one small case where I am looking for a solution on how to do the same but in the same subgraph, is this even supported?
Here is my entity:
type Chat @key(fields: "id") {
id: ID!
listingId: String!
createdAt: DateTime!
updatedAt: DateTime!
participants: [Participant!]!
title: String!
}
I would like to be able to extend the above with:
id: ID!
chatId: String!
content: String!
createdAt: DateTime!
participant: Participant!
}
extend type Chat @key(fields: "id") {
id: ID!
messages: [Message!]!
}
The reason I want this is because I don’t want the messages always resolved in the resolver, only on demand. Is there a better solution other than moving the messages to it’s own subgraph?
I am using node.js apollo-server.