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

Unable to function with gridsome-source-graphql as a source #2

Open
thinkflo opened this issue Sep 22, 2020 · 1 comment
Open

Unable to function with gridsome-source-graphql as a source #2

thinkflo opened this issue Sep 22, 2020 · 1 comment

Comments

@thinkflo
Copy link

thinkflo commented Sep 22, 2020

When I try to use the gridsome-source-graphql source, the recommender plugin cannot find the specified option.typeName

The error message I receive is:

Gridsome v0.7.20

Initializing plugins...
gridsome-plugin-recommender: options.typeName 'craft' cannot be found - make sure the collection exists

I am using CraftCMS as a GraphQL data source. When I try to switch to the source-filesystem such as your example, then it does work, so I believe it's related to the async nature of retrieving the graphql data source and it not being loaded while the recommender loads in.

Here is an excerpt from my gridsome.config.js file which does not work.

  plugins: [
    {
      use: '@gridsome/source-graphql',
      options: {
        url: process.env.CRAFT_API_URL,
        fieldName: 'craft',
        typeName: 'craft',
        headers: {
          Authorization: `Bearer ${process.env.CRAFT_API_TOKEN}`,
        }
      }
    },
    {
      use: "gridsome-plugin-recommender",
      options: {
        enabled: true,
        typeName: 'craft',
        field: 'mainContent',
        relatedFieldName: 'related',
        minScore: 0.01,
        maxScore: 1,
        minRelations:3,
        maxRelations: 10,
        fillWithRandom:false,
        debug: false
      }
    },
@mklueh
Copy link
Owner

mklueh commented Sep 22, 2020

Hi @thinkflo , this is indeed a problem.

The GraphQL plugin bypasses the collection layer where the gridsome-plugin-recommender hooks in and works direktly on the GraphQL layer.

In order to make that work you´d need to implement the whole logic on top of Graphql instead of collections, not sure if that is practical, although there seems to be a way to modify GraphQL nodes in a transformer

https://gridsome.org/docs/transformer-api/#example

Unfortunally I have no idea how to work with transformers, the documentation insufficient for my Gridsome knowledge level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant