-
Notifications
You must be signed in to change notification settings - Fork 48
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
Export and import graph #781
base: main
Are you sure you want to change the base?
Conversation
0d1a225
to
5989d93
Compare
packages/graph-explorer/src/modules/GraphViewer/ImportGraphButton.tsx
Outdated
Show resolved
Hide resolved
if (matchingByUrlAndQueryEngine.length > 0) { | ||
const matchingConnection = matchingByUrlAndQueryEngine[0]; | ||
return { | ||
message: `The graph file requires switching to connection ${matchingConnection.displayLabel}.`, |
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.
Out of scope for this PR but has there been consideration to adding a prompt to allow the user to switch the active connection when this scenario is encountered?
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.
Yes, but it depends on all the plumbing for restoring a graph on refresh so I'm doing that first.
5989d93
to
c972212
Compare
c972212
to
a8f7de2
Compare
<PanelHeaderActionButton | ||
icon={<SaveIcon />} | ||
label="Save graph to file" | ||
onActionClick={() => exportGraph("graph-export.json")} |
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.
Is it possible for the default file name to be less generic so that the user doesn't have to change the default file name to avoid overwriting existing exports? Personally when I am saving a file from a site I like to have the default name be descriptive and unique enough so I don't have to rename it myself.
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.
It's possible, but what would you want it to be?
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.
Personal preference would be to add context about the database being extracted (ie. connection detail) but will leave it up to your discretion to make the ultimate decision.
LGTM |
Description
Adds the ability to save and load a graph to and from a file. This requires the user to be in the same connection. We define "the same" as:
The file contains a minimal set of information needed to reconstruct the graph:
During import, the file will be validated with Zod, then sent to the vertex and edge details queries to load the data. When all those queries return back it will render the graph.
The export path will attempt to use the new file system APIs that are not widely supported across browsers. As of today, Chrome and Edge will properly show the native OS save file dialog. The fallback behavior for Firefox and Safari is to save the file to the user's download folder, just like any other download.
Future optimizations
Today, the details queries run per node and edge, so this can be quite expensive for large graphs. There are likely some optimizations to make to batch up set of nodes and edges to reduce the amount of queries.
Validation
Save.and.load.a.rendered.graph.mp4
Related Issues
Check List
license.
pnpm checks
to ensure code compiles and meets standards.pnpm test
to check if all tests are passing.Changelog.md
.