Gatsby source plugin for Firestore
npm install @Skil3e/gatsby-source-firestore
- Generate credentials from Firebase > Settings > Service accounts > "Generate new private key".
- Configure settings at
gatsby-config.js
, for example:
module.exports = {
{
resolve: `skil3e-source-firestore`,
options: {
credential: require(`./credentials.json`),
collections: [
{
type: "Collection", // Graphql name
name: "collection", // Firebase name (can also be a path for a specific subcollection eg: "collection/documentID/subCollection")
// Use map if you want to rename data or load only partial data
map?: doc => {
value: doc.value
}
subCollections?: [
{
type: "Subcollection", // Graphql name
name: "subcollection", // Firebase name
makeNode?: false // if true will create top level node
}
]
}
]
},
}
}
{
allCollection {
edges {
node {
value
childrenSubcollection {
value
}
}
}
}
""" Will also make this """
allSubcollection {
edges {
node {
value
}
}
}
}