Configure settings at gatsby-config.js
, for example:
module.exports = {
plugins: [
{
resolve: `gatsby-source-firebase-collections`,
options: {
credential: require(`./credentials.json`),
appConfig: {
apiKey: 'api-key',
authDomain: 'project-id.firebaseapp.com',
databaseURL: 'https://project-id.firebaseio.com',
projectId: 'project-id',
storageBucket: 'project-id.appspot.com',
messagingSenderId: 'sender-id',
appID: 'app-id',
},
types: [
{
type: `Book`,
collection: `books`,
map: (doc) => ({
title: doc.title,
isbn: doc.isbn,
author___NODE: doc.author.id,
}),
},
{
type: `Author`,
collection: `authors`,
map: (doc) => ({
name: doc.name,
country: doc.country,
books___NODE: doc.books.map((book) => book.id),
}),
},
],
},
},
],
};
Note that you will need to have books
and authors
in Firestore matching
this schema before Gatsby can query correctly, e.g books__NODE
on author
needs to be an array with books
as a key of reference types to book
documents.