Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use different key for tool reference getters #299

Merged
merged 2 commits into from
Oct 24, 2024

Conversation

tylerslaton
Copy link
Contributor

@tylerslaton tylerslaton commented Oct 24, 2024

This is a workaround to make the SWR caching work nicely with the getToolReferences function. The reason we do this is because otherwise the SWR cache will not be invalidated between the two function calls and thus break type safety since types in TypeScript are erased at runtime. as-map=true does not exist in the API.

In addition, this PR also updates the ToolGrid to use the same getter as the ToolCatalog.

#292

This is a workaround to make the SWR caching work
nicely with the getToolReferences function. The reason we do this
is because otherwise the SWR cache will not be invalidated between
the two function calls and thus break type safety since types in
TypeScript are erased at runtime. as-map=true does not exist in
the API.

Signed-off-by: tylerslaton <[email protected]>
// the two function calls and thus break type safety since types in
// TypeScript are erased at runtime. as-map=true does not exist in
// the API.
url: ApiRoutes.toolReferences.base({ type }).path + "?as-map=true",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of modifying the url, can you just add another property (i.e. responseType: 'map' or modifier: 'as-map')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not even think about that haha, good call.

@ryanhopperlowe
Copy link
Contributor

1 nit, but other than that LGTM!

@tylerslaton tylerslaton force-pushed the fix-292 branch 2 times, most recently from ead6d2f to 309c5cc Compare October 24, 2024 14:39
@tylerslaton tylerslaton merged commit fc20c75 into obot-platform:main Oct 24, 2024
1 check passed
@tylerslaton tylerslaton deleted the fix-292 branch October 24, 2024 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants