I am trying to build Algolia search functionality into an existing project. The first step is to populate the Algolia indices with the data from the project. I am trying to do this via a GraphQL query that transmits the queried data to Algolia upon running yarn rw build
.
I have done this before using GatsbyJS by putting the query into a page titled Search
… I tried the same thing with Redwood and when that did not work I am thinking perhaps I need to use a Cell instead…
The GraphQL docs state that if you want to use useQuery
(which I think I do ) it is best to use a cell. So, I ran
yarn rw g cell Search
to build a Search Cell
and when I open the file I see that it built import type { FindSearchQuery } from 'types/graphql'
at the top. However, the linter does not like it and the error message reads:
import FindSearchQuery
Module '"types/graphql"' has no exported member 'FindSearchQuery'.
When I run yarn rw dev
I get this error:
Generating TypeScript definitions and GraphQL schemas...
gen | GraphQL Document Validation failed with 2 errors;
gen | Error 0: GraphQLDocumentError: Unknown type "Int".
gen | at /Users/isaactait/Desktop/Web_Dev/cadhub/app/web/src/components/SearchCell
gen | /SearchCell.tsx:2:30
gen |
gen | Error 1: GraphQLDocumentError: Cannot query field "search" on type "Query".
gen | at /Users/isaactait/Desktop/Web_Dev/cadhub/app/web/src/components/SearchCell
gen | /SearchCell.tsx:3:5
gen | GraphQL Document Validation failed with 2 errors;
gen | Error 0: GraphQLDocumentError: Unknown type "Int".
gen | at /Users/isaactait/Desktop/Web_Dev/cadhub/app/web/src/components/SearchCell
gen | /SearchCell.tsx:2:30
gen |
gen | Error 1: GraphQLDocumentError: Cannot query field "search" on type "Query".
gen | at /Users/isaactait/Desktop/Web_Dev/cadhub/app/web/src/components/SearchCell
gen | /SearchCell.tsx:3:5
gen |
gen | Error: Could not generate GraphQL type definitions (web)
So, my first question. What is going on here with all the errors right off the bat?
My second question is do I need a plural or singular cell for a search query?
My last question is (and perhaps the most pertinent one) does this even make sense? Am I on the right track? I am learning a lot of new things all at once (RW heart and soul, GraphQL, Apollo, Algolia) and it is entirely possible that I am not putting them together in the correct way to build Algolia search into the project.
Any help would be greatly appreciated! Thank you