gatsby-source-notion-api icon indicating copy to clipboard operation
gatsby-source-notion-api copied to clipboard

Add support for querying multiple databases available to the Integration

Open orlowdev opened this issue 3 years ago • 4 comments

Currently, a databaseId option is required. gatsby-source-notion-api only allows fetching data from the database provided via that option. Technically, it is possible for a Notion integration to have access to multiple databases. In this case, you could choose which pages to pull from which database.

orlowdev avatar May 18 '21 11:05 orlowdev

I'm playing around with a fix on this issue for my own purposes but went ahead and tagged the issue in my PR on my fork (figured I'd spend the time writing out a future PR now). I'll comment back when I'm finished tinkering with it if you're interested in taking a look.

jessrezac avatar Oct 19 '21 20:10 jessrezac

Thank you, I'm excited to see it! If you have any questions, don't hesitate to reach out.

orlowdev avatar Oct 20 '21 06:10 orlowdev

Instead of modifying the plugin to take in multiple database IDs, another approach might be to use multiple plugins in gatsby-config.js. I believe gatsby-source-graphql uses this approach (unless I've misunderstood their example).

module.exports = {
  plugins: [
    {
      resolve: "gatsby-source-graphql",
      options: {
        typeName: "SWAPI",
        ...
      },
    },
    {
      resolve: "gatsby-source-graphql",
      options: {
        typeName: "GitHub",
        ...
      },
    }
  ],
}

I tried this approach with this plugin and it seems to be fetching both results. In order to make this work, I think you'd only need a parameter that lets you specify the query node name for the result. Currently, it's set to allNotion, but if you could specify it for each configuration, that might solve the problem.

LandonSchropp avatar Jan 03 '22 21:01 LandonSchropp

Thanks @LandonSchropp. That was indeed the simplest solution 👍. Here's the PR related to this: https://github.com/orlowdev/gatsby-source-notion-api/pull/24

viteinfinite avatar Dec 31 '22 13:12 viteinfinite