travis-r6s / gridsome-plugin-flexsearch

Add lightning fast search to Gridsome with FlexSearch
24 stars 7 forks source link

Using Gridsome-graphql-source with flexsearch not workin #62

Closed Hamdy closed 3 years ago

Hamdy commented 3 years ago

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 }}}}

travis-r6s commented 3 years ago

@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...

travis-r6s commented 3 years ago

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