[As community content, this post reflects the views and opinions of the particular author and does not necessarily reflect the official stance of Neo4j.]Many developers mostly stay in their integrated development environments (IDEs) when working on software. That’s why it’s useful if the IDE has database tooling built in that allows you to query your database and validate and complete your statements.
Out of the box you can find:
Support for the Cypher graph query language is, without any doubt, the most useful (and most used!) plugin feature. It saves quite a lot of effort every time I need to write a larger Cypher query.
Syntax Highlighting and Error Reporting
This is a simple one. As you might expect, Cypher syntax is properly highlighted. Labels, relationship types, properties, functions, procedures, parameters – all elements have their own coloring that you can also configure.
And error reporting is there as well, with helpful error messages that describe what’s wrong, not only when you execute the query but also while you’re typing.
If a Cypher query is written in the Data Source editor (we will take a look at them a bit later), then you also might notice various warnings that are coming directly from the database.
Probably one of the most used features is autocompletion. Here is the list of what the plugin collects from existing queries and database metadata for autocompletion:
- Relationship types
- Property keys
- Built-in functions
- User-defined procedures and functions
User-defined functions and procedures include not only their name, but also information about their signature and return type.
Tired of copy-pasting new identifier names all over the place, then running your query and realizing that there is still one place where the identifier has its old name?
This is exactly a situation where refactoring feature will be very handy.
One can easily rename:
- Relationship types
- Identifier names
- Property keys
The plugin support for Cypher code reformatting is based on the official openCypher style guide, with some nice additions like aligning patterns or map keys and values to each other.
User-Defined Functions and Procedures
When it comes to working with user-defined functions and procedures, the plugin is able to offer a number of features:
- Show parameter information
- Validate that the number of passed arguments is correct (with respect to default values)
- Type checks
You can see parameter information without switching to a browser window with docs to verify what arguments a function expects. Note how the current argument under the cursor is highlighted; that’s also quite useful!
Parameter Count Validation
Another simple but useful feature is parameter count validation. If there are not enough arguments, or too many of them, then an error will be shown in the editor.
Here comes a more advanced feature. The JetBrains IDE plugin is smart enough to detect expression types and – based on those – verify that the arguments passed to a function have valid types.
Types that can be inferred include:
- Number (both Float and Integer)
The JetBrains IDE plugin provides the ability to view documentation for functions and procedures inline.
The documentation for built-in functions is the same that you can find in Neo4j’s own documentation. This means that it has everything you are looking for, including proper description and example query.
Documentation for user-defined functions and stored procedures is auto-generated. So, there will be information about signature and return type. The description is also included if there is one present.
JetBrains IDEs have a feature called language injections. Simply speaking, it allows you to “inject” support for languages like HTML, SQL or CSS (and others) into a string literal in any other programming language. And Cypher is not an exception here!
On top of that, the graph database support plugin is smart enough to automatically inject Cypher for all official Neo4j API and language drivers and for some of the most widely used and popular community drivers:
If the great Cypher support is the face of the plugin, then data sources are the body. They allow you to:
- Manage connection to a database
- Use data source specific editor
- Explore all database metadata
- Perform several useful interactions
Currently only Neo4j 3.0 and higher is supported (via Bolt protocol) but that’s what you should be using anyway. If you’re interested in support for previous versions, please let us know.
One nice feature that the data sources aspect provides is the query editor. It can be accessed by double-clicking on a data source (or via its context menu).
While it’s quite simple, it allows you to:
- Write queries without creating extra files in a project
- Note: The editor content is persisted across IDE restarts
- Benefit from the fact that the plugin knows that this editor is bound to a specific data source and enables several useful features (like
- Run queries directly against desired data source
Enriched Cypher Experience
When a data source for a Neo4j graph database is created, the plugin automatically retrieves the metadata of the database to make Cypher editing even more powerful than before. It extracts information like:
- Node labels
- Relationship types
- Property keys
- User-defined procedures
- User-defined functions
User-defined procedures and functions also will have information about parameters and return values that will be visible in autocompletion (and documentation!).
Whenever a query is executed, all information about the execution process and results can be found in the console at the bottom of your IDE.
Anything that happens in the plugin will have information in a log, including:
- Query execution
- Data source metadata refresh
- Parameter parsing errors
Graph and Table Result Views
When a query is executed it returns results. Results, however, need to be viewed somehow. This plugin offers two ways of working with query results:
The graph view is what graph databases are all about: viewing your data as connected entities.
Available interactions in the graph view include:
- Click on a node or relationship to view entity information
- Zoom in and out using the mouse wheel
- Double left click on the mouse to center the graph
- Drag nodes to place them better than our layout algorithm
- Click and drag the canvas to change the view position
If graph view is not working for you for any reason, table view is right there. Nothing much to say here. Tables are tables, and they’re everywhere.
Analyze Cypher Queries
Whenever a Cypher query is executed with an
PROFILEkeyword, a new tab is added to the console with a query execution plan.
In that extra tab, you’ll find:
- A query plan in a tree format
- Execution details for each plan node
- Information about the Cypher version, planner and execution runtime
Using parameters in your queries? Now there is no need to replace parameters with desired values, just to test out how a query works.
You can specify parameters in the corresponding tab in a JSON format. When a query will be executed, the plugin will automatically pick up the parameters that are needed.
15 – months that the JetBrains IDE plugin has been in the wild.
16000+ – total lifetime plugin downloads
400+ – graphistas are using it every (working) day
If you like what we are doing, then feel free to star us on GitHub and spread the word. In case of any bug, issue, question or feature request – please raise an issue on GitHub.