orlowdev / gatsby-source-notion-api

Gatsby plugin for Notion API
https://gatsby-source-notion-api-demo.netlify.app
BSD Zero Clause License
61 stars 17 forks source link

Add support for querying multiple databases available to the Integration #3

Open orlowdev opened 3 years ago

orlowdev commented 3 years ago

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.

jessrezac commented 2 years ago

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.

orlowdev commented 2 years ago

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

LandonSchropp commented 2 years ago

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.

viteinfinite commented 1 year ago

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