Migrate entities and attribute values stores - #2049
Merged
Merged
Conversation
axelboc
force-pushed
the
react-query-cont-1
branch
2 times, most recently
from
September 4, 2026 09:22
62c9697 to
5489879
Compare
axelboc
commented
Sep 4, 2026
axelboc
force-pushed
the
react-query-cont-1
branch
from
September 7, 2026 07:22
5489879 to
6b69c6a
Compare
loichuder
approved these changes
Sep 8, 2026
loichuder
left a comment
Member
There was a problem hiding this comment.
Cool !
We can discuss the ignoreValue thingy later if you wish.
axelboc
force-pushed
the
react-query-cont-1
branch
from
September 10, 2026 08:17
6b69c6a to
8264dc3
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For the simplest example usage of the new
queries.entity(path), seeuseEntityanduseDatasetsinpackages/app/src/hooks.ts(useEntityis called in the explorer and the metadata viewer;useDatasetsis used only in Hibou). Those are already both hooks and they both calledentitiesStore.get()directly without any conditions, so migrating touseSuspenseQuery(ies)was trivial.For the simplest example usage of the new
queries.attrValues(entity), see the metadata viewer'sAttributesInfocomponent — it calledattrValuesStore.get()directly and unconditionally, so trivial also.The more challenging cases are when
store.get()is called conditionally, sometimes deep inside a stack of synchronous functions...Let's take
useNxData, which is used by all the NeXus vis containers:findSignalDatasetfindSignalDatasetchecks if the NXdata group has a "signal" attributeattrValuesStore.get(group)["signal"](viagetAttributeValue).And that's just one of the many attribute values that
useNxDatarequests, conditionally or not, but always a few functions deep.At this point it's good to remind ourselves why we request attribute values conditionally: we want to avoid making unnecessary requests to remote providers like h5grove. So removing the conditions and turning every function into a custom hook so we can call
useSuspenseQuery(queries.attrValues())deep into the call stack is not an option. For the same reason, we also can't retrieve all the attribute values inuseNxDataand pass them down.The only option is to call
useSuspenseQueryfromuseNxData. But then how do we replace the calls toattrValuesStore.get()within nested functions likegetAttributeValue?Fortunately, Tanstack Query provides a way to invoke a query without
useSuspenseQuery: it's calledqueryClient.query()(very recently renamed fromfetchQuery).The problem is that it's async so it means that every function has to be made async (
asynckeyword,Promisereturn type, andawaitat call site). This is what most of the diff is about.The other similar case to
useNxDatais theresolvePathfunction that is called from theVisualizerto find the supported visualization for a given entity.Finally, there are the few intermediate cases where it's not quite clear whether a new dedicated query like "nxData" or "resolution" is needed or not, and whether efforts should be put into trying not to trigger the query when possible (with
useSuspenseQueriesand an empty queries array).Hopefully, this gives a good overview. For the remaining explanations, I'll comment inline.