meilisearch / gatsby-plugin-meilisearch

A plugin to index your Gatsby content to Meilisearch based on graphQL queries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow multi queries on same index

bidoubiwa opened this issue · comments

After #15, the config file will look like this. You will be able to create multiple indexes with each their own graphQL query.

{
  "options" : {
    host: '...'
    // ...
    indexes: [
      {
        indexUid: 'my_blog'
        // ...
        query: ` ... `
      }
    ]
  }
}

This implies that for every index created in MeiliSearch you can provide one graphQL query.
As this seems a bit limitated since you can have multiple page structures but you'd like to add them all in the same index, we want to change query to queries. That would accept an array of queries.

So instead of for example:

query: `
  query MyQuery {
    allMdx {
      // ....  
    }
  }
`,

It becomes:

queries: [`
  query MyQuery {
    allMdx {
      // ....  
    }
  }
`],

This changes the code here:

// Prepare data for indexation
const transformedData = await queries.transformer(data)

Where you will have to iterate on the queries to fetch all data.

Closing this as we can simply add an other object to indexes to do the same thing 👍