travis-r6s / gridsome-plugin-flexsearch

Add lightning fast search to Gridsome with FlexSearch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using Gridsome-graphql-source with flexsearch not workin

Hamdy opened this issue · comments

commented

Hi my use case is like the following

{
    use: 'gridsome-source-graphql',
    options: {
      url: 'http://gridsome_graphql_server',
      fieldName: 'FieldName',
      typeName: '',
    },
  },
{
    use: 'gridsome-plugin-flexsearch',
    options: {
       
        searchFields: ['title'],
        collections: [
          {
            query: `
            {
              allBlog{edges{
                  node{
                    id
                    path
                    content
                    excerpt
                    title
                    tags{
                      title
                    }
                  }
                }
              }
            }
            `,
            path: 'allBlog.edges',
            indexName: 'Blog'
          },
}

now the above does not work, because path: 'allBlog.edges', this is a list of edges where each edge contains a property called node which actually is the actual node
I had to do something here https://github.com/thetre97/gridsome-plugin-flexsearch/blob/main/gridsome.server.js#L107

return nodes.map(item => {
      const node = item.node

my question is this a bug, or is there a way through path property to make this work?
the example in the documentation

 query: `{ wordpress { posts { nodes { id, title, uri, excerpt, description, featuredImage { altText, sourceUrl } } } } }`,

is not a standard way for a graphql server where the query usually uses
{posts {edges {node{ id title path blah }}}}

@Hamdy Sorry for the delay, but no, I'm afraid it doesn't support that yet.
I've been making some updates recently, so I'll look into that...

I'm stopping support for the remote schema option, so closing this.