title: Creating a Firestore Plugin for GatsbyJS
body: <p>I am trying to create my own source plugin for Gatsby.  In this particular case, I am trying to create a firestore source plugin.  I know that there already exists source plugins for firestore, but I would like to learn how to create source-plugins myself in general and from a database in particular (I've already gone through the <a href="https://www.gatsbyjs.org/docs/pixabay-source-plugin-tutorial/" rel="nofollow noreferrer">fetch api source plugin tutorial</a> on the gatsby site).  </p>
  
  <p>With that said, the plugin is not working and I'm not sure what the problem is.  I have already done a console.log and I know that the data is being retrieved for firestore.  Also, there are no errors when I do a <code>gastby develop</code> in the console.  The site builds properly -- and I can access <code>graphiql</code>.  But, the data does not show up in graphiql.</p>
  
  <p>Here is the <code>gatsby-node.js</code> file in the plugin:</p>
  
  <pre><code>const firebase = require("firebase-admin")
  const firebaseCert = require("./firebase-adminsdk.json")
  
  exports.sourceNodes = async ({
    actions,
    createNodeId,
    createContentDigest,
  }) =&gt; {
    try {
      if (firebase.apps || !firebase.apps.length) {
        firebase.initializeApp({
          credential: firebase.credential.cert(firebaseCert),
        })
      }
    } catch (e) {
      report.warn("Could not initialize Firebase. Please check credentials")
      report.warn(e)
      return
    }
  
    const { createNode } = actions
  
    const db = firebase.firestore()
  
    db.collection("newsFeed")
      .get()
      .then(snapshot =&gt; {
        snapshot.docs.forEach(doc =&gt; {
          createNode({
            id: createNodeId(`feedly-feed-${doc.id}`),
            parent: null,
            children: [],
            internal: {
              type: `FeedlyFeeds`,
              content: JSON.stringify(doc.data()),
              contentDigest: createContentDigest(JSON.stringify(doc.data())),
            },
          })
        })
      })
  }
  </code></pre>
  
  <p>Any idea why this is not working -- and what I can do to get it to work?</p>