gatsby-firesource
Gatsby source plugin for building websites using Firestore as a data source.
Usage
- Get a private key for your Firebase project.
- Put that private key somewhere in your Gatsby project.
$ npm i gatsby-firesource
- Configure
gatsby-config.js
moduleexports = plugins: resolve: 'gatsby-firesource' options: credential: types: type: 'Book' collection: 'books' title: doctitle isbn: docisbn author___NODE: docauthorid type: 'Author' collection: 'authors' name: docname country: doccountry books___NODE: docbooks ;
- To query
{ allBooks { edges { node { title isbn author { name } } } }}
Configurations
Key | Description |
---|---|
credential | Require your private key here |
types | Array of types, which require the following 3 keys |
type | The type of the collection, which will be used in GraphQL queries. Eg, when type = Book , the GraphQL types are named book and allBook |
collection | The name of the collections in Firestore. Nested collections are not tested. |
map | A function to map your data in Firestore to Gatsby nodes, utilize the undocumented ___NODE to link between nodes |
Disclaimer
This project is created solely to suit our requirements, no maintenance/warranty are provided. Feel free to send in pull requests.