Skip to content

Remove ExplorerInjector and find a more idiomatic way to clear query cache on connection change #1646

@kmcginnes

Description

@kmcginnes

ExplorerInjector was originally added to inject the explorer instance into the query client meta field and clear the query cache when the explorer changed. Now that the explorer is pulled from the Jotai store (via getStore(meta) in connector/queries/helpers.ts), the store reference itself never changes — only the explorer atom value inside it does.

The only meaningful side effect ExplorerInjector performs is calling queryClient.clear() when the connection changes. It does this using a "set state during render" pattern to detect when defaultOptions changes, which is indirect and fragile (it already caused an infinite render loop when upgrading babel-plugin-react-compiler to 1.0.0).

We should investigate removing ExplorerInjector entirely and replacing the cache-clearing behavior with a more idiomatic React approach, such as:

  • Clearing the cache directly in the connection-switching logic (e.g., where the active connection atom is updated)
  • Using a key prop on a provider to force remounting and get a fresh query client

Relevant Code

  • packages/graph-explorer/src/core/ExplorerInjector.tsx — the component to remove
  • packages/graph-explorer/src/core/ExplorerInjector.test.tsx — associated tests
  • packages/graph-explorer/src/core/queryClient.tscreateDefaultOptions and createQueryClient
  • packages/graph-explorer/src/connector/queries/helpers.tsgetStore(meta) which reads the store from query meta

Important

If you are interested in working on this issue, please leave a comment.

Tip

Please use a 👍 reaction to provide a +1/vote. This helps the community and maintainers prioritize this request.

Metadata

Metadata

Assignees

Labels

connectionIssues related to database connection management or optionsreliabilityIssues relating to improvements in reliabilitytech debtIssues, typically tasks, that are mainly about cleaning up code that is problematic in some way

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions