diff --git a/stores/locationsStore.ts b/stores/locationsStore.ts index e3364999..97206262 100644 --- a/stores/locationsStore.ts +++ b/stores/locationsStore.ts @@ -52,8 +52,8 @@ async function queryFacilities(): Promise { } satisfies FacilitySearchFilters } - const result = await gqlClient.request(searchFacilitiesQuery, searchFacilitiesData) - return result + const result = await gqlClient.request<{ facilities: Facility[] }>(searchFacilitiesQuery, searchFacilitiesData) + return result?.facilities ?? [] } catch (error) { console.log(`Error getting facilities for dropdown: ${JSON.stringify(error)}`) alert(`Error getting data! Please contact our support team by clicking the bottom right link on the page!`) diff --git a/stores/searchResultsStore.ts b/stores/searchResultsStore.ts index 316c1c27..ede1f3b3 100644 --- a/stores/searchResultsStore.ts +++ b/stores/searchResultsStore.ts @@ -89,9 +89,10 @@ async function queryProfessionals(searchSpecialty?: Specialty, searchLanguage?: } console.log('searching professionals') - const response = await gqlClient.request(searchProfessionalsQuery, searchProfessionalsData) - const professionalsSearchResult = (response ?? []) as HealthcareProfessional[] - console.log(`Fetched professionals: ${JSON.stringify(professionalsSearchResult)}`) + const response = await gqlClient.request<{ healthcareProfessionals: HealthcareProfessional[] }>(searchProfessionalsQuery, searchProfessionalsData) + console.log(`Fetched professionals: ${JSON.stringify(response)}`) + + const professionalsSearchResult = (response?.healthcareProfessionals ?? []) as HealthcareProfessional[] return professionalsSearchResult } catch (error) { console.log(`Error getting professionals: ${JSON.stringify(error)}`) @@ -119,9 +120,9 @@ async function queryFacilities(healthcareProfessionalIds: string[], searchCity?: } console.log('searching facilities') - const response = await gqlClient.request(searchFacilitiesQuery, searchFacilitiesData) - const facilitiesSearchResults = (response ?? []) as Facility[] - console.log(`Fetched facilities: ${JSON.stringify(facilitiesSearchResults)}`) + const response = await gqlClient.request<{ facilities: Facility[] }>(searchFacilitiesQuery, searchFacilitiesData) + console.log(`Fetched facilities: ${JSON.stringify(response)}`) + const facilitiesSearchResults = (response?.facilities ?? []) as Facility[] //filter the search results by location if a location is selected const locationFilteredSearchResults = searchCity