graphdb-intellij-plugin icon indicating copy to clipboard operation
graphdb-intellij-plugin copied to clipboard

Feature Request: Inject Format Variables for Query

Open andrewjroth opened this issue 2 years ago • 2 comments
trafficstars

I'm using version 0.6.1 of this plugin. Thanks for supporting it!

I'm not sure if the language injection mentioned in #29 was already added or not, but I am able to annotate text strings in Kotlin to be recognized as Cypher and have the context menu items to Execute/Explain/Profile the Query (although, I think that is always available for any highlighted text).

I'm wondering if it might be possible to format the string with variables prior to being run. Variables are frequently used in database queries (Graph or SQL) to parameterize the query and reuse the query string for multiple queries. It would be helpful to be able to do this variable injection or provide parameters for a query when doing the Execute/Explain/Profile.

For example, given the Kotlin code below:

    @Language("Cypher")
    val ADD_MOVIE = """
      MERGE (movie:Movie {title: ${'$'}movieTitle})
      WITH movie
      MATCH (actor:Actor)
        WHERE actor.name IN ${'$'}movieActorNames
      MERGE (actor)-[:ACTED_IN]->(movie)
    """
    // ... elsewhere in the code ...
    // Official Neo4j Java Driver is used for Kotlin
    // The Query string is expected to have `$name` for parameter names, with values injected at runtime.
    // See https://neo4j.com/developer/java/
    tx.run(
      ADD_MOVIE,
      Values.parameters(
        "movieTitle", movie.title,
        "movieActorNames", movite.actors.map { it.name }
      )

I would like a context aware action to "Run with Parameters" that will prompt me for the parameters before running it against a configured database connection.

I'm willing to contribute a PR to add this, but don't really know where to start with adding this to the plugin. If I could get a pointer in the right direction, maybe I can make it happen.

andrewjroth avatar Jul 07 '23 14:07 andrewjroth

Well, it's been over a year and I'm running into this same issue. I'd rather not have to change every parameterized request to a hard-coded one to test it from the IDE I'm working in, but to instead be able to inject the parameters somehow (outside the typical methods used through the package in the code).

Have you been updated outside of this thread on your original question or has this been as a forgotten request?

RogueFox avatar May 20 '25 21:05 RogueFox

Have you been updated outside of this thread on your original question or has this been as a forgotten request?

I have not seen any update.

andrewjroth avatar Jun 18 '25 20:06 andrewjroth