Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiproject data data source #51

Open
Simply007 opened this issue Feb 25, 2019 · 1 comment
Open

Multiproject data data source #51

Simply007 opened this issue Feb 25, 2019 · 1 comment
Labels
enhancement New feature or request groomed hacktoberfest help wanted Extra attention is needed source-plugin Marking issues related to @kentico/gatsby-source-kontent. up-for-grabs

Comments

@Simply007
Copy link
Contributor

Simply007 commented Feb 25, 2019

Motivation

Allow users to load data from more than one project.

Proposed solution

Extend a configuration object by the project identification property that would create the project-specific prefix for created Nodes.

Configuration example:

       {
      resolve: `gatsby-source-kentico-cloud`,
      options: {
        project1: {
          deliveryClientConfig: {
            projectId: `firstProjectGuid`,
          },
          languageCodenames: [
            `en-US`,
            `es-ES`,
          ]
        },
        project2: {
          deliveryClientConfig: {
            projectId: `secondProjectId`,
          },
          languageCodenames: [
            `en-US`,
          ]
        }
      }
    }

Possible workaround

Using Kontent Delivery API directly (or using JS SDK) without the GraphQL layer might work as a workaround:
https://www.gatsbyjs.com/docs/how-to/querying-data/using-gatsby-without-graphql/

@Simply007 Simply007 added enhancement New feature or request help wanted Extra attention is needed groomed up-for-grabs labels Feb 25, 2019
@Simply007 Simply007 added the source-plugin Marking issues related to @kentico/gatsby-source-kontent. label May 18, 2020
@Simply007
Copy link
Contributor Author

Simply007 commented May 27, 2021

Note:

I have tested out a 🚩 really HACKY 🚩 thing with the source plugin and it is definitely not recommended to use it like that in production, but registering the plugin twice with different configurations works if the types are two distinct sets.

gatsby.config.js

[
    // ...
    {
      resolve: '@kentico/gatsby-source-kontent',
      options: {
        projectId: "FIRST_PROJECT", // Fill in your Project ID
        languageCodenames: ["default"]
      },
    },
    {
      resolve: '@kentico/gatsby-source-kontent',
      options: {
        projectId: "SECOND_PROJECT", // Fill in your Project ID
        languageCodenames: ["default"]
      },
    }
    // ...
]

The only thing is this error

A field extension with the name `kontent_item_language_link` has already been registered.

But this might be another approach to implement it - allow registering source plugin multiple times like i.e. gatsby-source-filesystem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request groomed hacktoberfest help wanted Extra attention is needed source-plugin Marking issues related to @kentico/gatsby-source-kontent. up-for-grabs
Projects
None yet
Development

No branches or pull requests

2 participants