Support Firestore sub-collections
See original GitHub issueIs your feature request related to a problem? Please describe.
It is unclear at this time how to use firestore subcollections with @gqlify/firestore.
Describe the solution you’d like I imagine creating the type like so:
type Book @GQLifyModel(dataSource: "firestore", key: "books") {
id: ID! @unique @autoGen
title: String!
author: Author!
}
type Author @GQLifyModel(dataSource: "firestore", key: "books/*/authors") {
id: ID! @unique @autoGen
name: String!
}
and then updating or creating a field requires a where params list like so:
type AuthorWhereUniqueInupt {
bookId: ID!
authorId: ID!
}
or could we use a Firestore sub-collection specific where param where the id field is the document path? Eg:
type AuthorWhereUniqueInupt {
parentPath: String!
authorId: ID!
}
where the parentPath is more like the current path usage in Firestore SDK:
variables = {
parentPath: `books/${someBookId}`
}
Issues with this solution:
- how do we query sub-collections?
- what syntax do we use to represent the document in the collection/document/collection path key? That is, does
books/*/authorswork well enough?
Describe alternatives you’ve considered Using root-level Firestore collections is a viable alternative since relationships/foreign-keys are already supported. There are performance implications with doing so though where sub-collections would be desirable.
Additional context Just starting a discussion of the idea 😄
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
@jthegedus We’re always glad to hear thoughts from the community 😄
Please don’t hesitate to share your thoughts.
Hope to hear more from you when we release
Canner v3in a few days later.@wwwy3y3 I agree completely, just wanted to raise the thoughts.
I think
createSubResource(path: string, input: Input)is a great solution should it become a heavily requested feature.