neo4j-devtools / neo4j-desktop

The Neo4j Graph Platform, on your desktop OS.
19 stars 1 forks source link

Neo4j Desktop 1.3.8 : Graph-App: InjectedAPI path variable points to wrong location #94

Closed mmopitz closed 3 years ago

mmopitz commented 3 years ago

Hi there, As requested I copied the ticket's content from https://github.com/neo4j/neo4j/issues/12611 to this tracker.

Description

For newly created databases a graph's path variable points to a wrong (outdated?) directory.

I read said path variable through the injectedAPI: https://neo4j.com/developer/graph-apps/building-a-graph-app/#_injected_api When I say path variable I mean following variable: neo4jDesktopApi.getContext().then(context=>context.projects[0].graphs[0].connection.configuration.path)

The problem occurs only for graphs that I created with Neo4j Desktop 1.3.8 . For graphs created with earlier versions the paths are correct.

Neo4j Desktop Version: 1.3.8 Operating System: Ubuntu 18.04 and Windows 10 Enterprise and MacOs API: GraphApp Injected API

Note: I show the problem in the 'App Developer Tool' by simply typing some commands into the the Developer Tool's Console.

Steps to reproduce

  1. Start Neo4j Desktop 1.3.8
  2. Create a new graph 'Test'
  3. Start a Database
  4. Enable Neo4j Desktop's 'Development Mode' : https://neo4j.com/developer/graph-apps/building-a-graph-app/#enable-dev-tools
  5. Start Neo4j Browser
  6. Open up Neo4j Browser's Developer Tools -> Console
  7. Print the paths of all graphs: `
    neo4jDesktopApi.getContext().then(context=>context.projects.forEach(p=>p.graphs.forEach(g=>console.log(p.name +':'+g.name+':'+g.connection.configuration.path))))
    //Outcome on my ubuntu machine:
    [...]
    My Project:Test:/home/mo/.config/Neo4j Desktop/Application/neo4jDatabases/database-26c48192-e0a8-4322-b5cc-bc84c18ac39c/installation-4.1.2
    [...]
    //expected (I obtained the correct path through Neo4j Desktop's 'Manage Graph'-> 'Open Folder'):
    [...]
    My Project:Test:/home/mo/.local/share/neo4j-relate/dbmss/dbms-d67d7c55-c15e-4c3e-8a8b-20abaddcbc67/
    [...]

    I guess that Neo4j now installs all new graphs to said location. But the path variable wasn't updated accordingly.

Some Background

Just as information: I want to access my graphs' plugin directories in my graph app to copy a jar file into said directory. Because the plugin dependency way described in the documentation is not an option for us. So I thought I could get the plugin directory by simply append '/plugin' to the connection.configuration.path variable.

nglgzz commented 3 years ago

Hey @mmopitz,

Did I understood correctly that you're expecting the DBMS path to be ~/.config/Neo4j Desktop/... but it's instead ~/.local/share/neo4j-relate/..., or is it the opposite?

From 1.3.8 all DBMS operations are managed by the Relate Framework, so that's why new DBMS installations are located in the new path containing neo4j-relate. If a DBMS was installed before 1.3.8, we create a symlink in the new location pointing to the old one, so depending on how Desktop is getting that path, it could be telling you the path to the symlink or the path to the original directory.

As a side note, from 1.3.9 (currently available in pre-release) we're making Relate's web API (both GraphQL and REST) available in Desktop, and going forward new features will be made available there instead of the injected API, so you might want to try that out. There is not much documentation about this integration, so feel free to comment here or create new issues if you need help with it.

mmopitz commented 3 years ago

Hi, thanks for the fast response. I'll try to clarify the issue.

Did I understood correctly that you're expecting the DBMS path to be ~/.config/Neo4j Desktop/... but it's instead ~/.local/share/neo4j-relate/..., or is it the opposite?

No. The opposite:

Just to be clear: This means that for graphs created with 1.3.8, path points to a not existing directory in ~/.config/Neo4j Desktop/...

As a side note, from 1.3.9 (currently available in pre-release) we're making Relate's web API (both GraphQL and REST) available in Desktop, and going forward new features will be made available there instead of the injected API, so you might want to try that out. There is not much documentation about this integration, so feel free to comment here or create new issues if you need help with it

That's very good know. The main problem for us is that we started using the injectedAPI about a year ago. And we do not know yet when or if we can migrate. But I guess that's just another point for making the transition at some point ;-)

I hope this clarifies the issue.

nglgzz commented 3 years ago

I just checked and you're right, the path returned by the injected API is always pointing to the old location. I'll create a PR to fix it, but it won't be available before the next release.

In the meantime, if you need that path you can get it through Relate's web API. Graph apps starting from Desktop 1.3.9 are launched with extra URL parameters to be able to access Relate's web API. You can see here the extra parameters.

mmopitz commented 3 years ago

Thanks a lot!

mmopitz commented 3 years ago

The issue was already fixed. Thx a lot!