useLazyQuery in useFffect Hook
Use useLazyQuery
hook1 to query for books based on user selected genre
const [genre, setGenre] = useState('all genres')const [booksList, setBooksList] = useState([])const [loadBooksList, { data }] = useLazyQuery(BOOKS_BY_GENRE, { variables: { genre: genre } })const booksResults = useQuery(ALL_BOOKS)useEffect(() => { if(genre === 'all genres') { if(booksResults.data) { setBooksList(booksResults.data.allBooks) } } else { loadBooksList() if(data) { setBooksList(data.allBooks) } }}, [loadBooksList, data, booksResults.data, genre])