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
feat: refactor cache handling, move storage out of generated #238
feat: refactor cache handling, move storage out of generated #238
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
docs-website/src/pages/docs/wundergraph-config-ts-reference/configure-introspection.md
Outdated
Show resolved
Hide resolved
96efdba
to
bdbd5f9
Compare
Made the requested changed and rebased |
4b16bc6
to
56eed6a
Compare
One thing I'd add is to set all "introspection" configs to automatically refresh each cache item every 5 seconds if not otherwise configured. So, by default, all introspections should be cached and refreshed after 5 seconds of waiting. This will give the most pleasent DX as it will be fast and (almost) always up to date if a datasource changes. @StarpTech opinion? |
56eed6a
to
5c2243e
Compare
So basically making |
It can always default to 5s, not just for "up", because when using "start", we don't introspect. |
Assumption: Most people integrate a ready API. They don't need to refresh it so often. If so, they can configure it. For me, it makes more sense to opt in. It produces fewer errors and logs. |
ok, makes sense |
@StarpTech GH says there's one remaining change requested from you, but then it links to a resolved one. Can we dismiss it? |
@StarpTech if you're ok, please approve |
I'd like to test it once locally. |
5079604
to
687bd27
Compare
Once the implementation is done, the docs need updates as well: |
Always try to hit the cache first. Once a result is retrieved, populate the cache as long as it's not disabled. Make the cache enabled by default, but toggleable via WG_DISABLE_INTROSPECTION_CACHE.
This way we can eventually place more items into a cache using the hierarchy below $WGD/cache
wunderctl generate was not propertly initializing it. Instead of making commands that might end up using the cache initialize the directory, make the TS side initialize it lazily when needed.
Instead of testing for file existence, try to read it and handle the potential errors.
- New --cache flag enables caching, which otherwise is always disabled by default - --cache is implemented globally for all commands, although it doesn't have any effect for some of them - TS side honors this via WG_ENABLE_INTROSPECTION_CACHE environment variable
- Enable cache by default - During wunderctl generate, fail if there's a cache miss - Add --cache-fallback flag to wunderctl generate, which allows falling back onto introspection - Pass WG_ENABLE_INTROSPECTION_CACHE explicitely instead of setting it globally - Clear the cache by default during wunderctl up startup - Add a configurable time interval to clear the cache during wunderctl up, with a 5 seconds default
Let the TS side do the refreshes when polling is enabled
Always clear it up during startup
The UI ends up much more intuitive this way
Make it clear that the error is because offline mode is enabled, include details of the introspection that failed
As discussed with Dustin, this is useful for generating a cache from a known and cold state, to reuse it later (e.g. for CI runs)
Added to both .gitignore and .prettierignore, as well as testsapps and examples
7c12868
to
2e5e190
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
0e97054
to
46f1b21
Compare
5 minutes is too slow for testapps/default in CI, it ends up being cancelled. Investigate this a bit further, because it shouldn't take this long.
46f1b21
to
1592765
Compare
Checklist
make test