-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expanding fetching system for FBI to handle multiple urls
In that way we can change FBI graphql url depending on which query that is being executed. We need that because DDF wants to change profile name depending on which query that is being run.
- Loading branch information
Showing
5 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { QueryFunctionContext } from "react-query"; | ||
import { | ||
getServiceBaseUrl, | ||
serviceUrlKeys | ||
} from "../utils/reduxMiddleware/extractServiceBaseUrls"; | ||
|
||
const map = { | ||
searchWithPagination: serviceUrlKeys.fbiSearch, | ||
getMaterial: serviceUrlKeys.fbiMaterial, | ||
default: serviceUrlKeys.fbi | ||
} as const; | ||
|
||
const resolveBaseUrl = (query: string | null) => { | ||
if (!query) { | ||
return getServiceBaseUrl(map.default); | ||
} | ||
return getServiceBaseUrl(map[query as keyof typeof map] || map.default); | ||
}; | ||
|
||
export const getQueryUrlFromContext = ( | ||
context: QueryFunctionContext | undefined | ||
) => { | ||
// Get the default base url if no context. | ||
if (!context) { | ||
return resolveBaseUrl(null); | ||
} | ||
|
||
const { queryKey } = context; | ||
const [queryName] = queryKey; | ||
return resolveBaseUrl(queryName as string); | ||
}; | ||
|
||
export default {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters