The JetBrains IDE Plugin for Graph Database Developers [Community Post]


[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.

When writing Neo4j-related code, that means extensively supporting Cypher as a first-class query language in your IDE. Today I would like to present to you the Graph Database Support plugin for all JetBrains IDEs. So if you write Ruby, Java, Python, C# or JavaScript code, we got you covered.

Graph database support plugin for JetBrains IDE


Out of the box you can find:
    • Full Cypher language support
    • Support for Neo4j 3.0 and higher (via the binary Bolt protocol)
    • Ability to not only write and validate, but also to execute queries
    • And a lot of other features that are meant to make you happy
So, if you are using any of the JetBrains IDEs, feel free to check the installation instructions on how to get the plugin to enhance your Neo4j developer experience!

Cypher


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.

Cypher syntax highlighting in the JetBrains IDE plugin


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.

Cypher error reporting in the JetBrains IDE plugin


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.

Cypher label error reporting in the JetBrains IDE plugin


Autocompletion

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:
    • Labels
    • Relationship types
    • Property keys
    • Keywords
    • Identifiers
    • Built-in functions
    • User-defined procedures and functions
Cypher autocomplete in the graph database support plugin


User-defined functions and procedures include not only their name, but also information about their signature and return type.

Cypher support for user-defined functions and procedures


Refactoring

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.

Cypher variable refactoring in the JetBrains IDE plugin


One can easily rename:
    • Labels
    • Relationship types
    • Identifier names
    • Property keys
Reformatting

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.

Learn all about the JetBrains IDE plugin offering graph database support for Neo4j, Cypher and more


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
Let’s explore each of the above features in detail.

Parameter Information

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 information for user-defined functions and procedures


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.

Parameter count validation for user-defined functions and procedures in Neo4j


Type Checks

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:
    • Node
    • Relationship
    • Path
    • Map
    • List
    • String
    • Number (both Float and Integer)
    • Boolean
    • Null
Note: There are situations when it is not possible to detect the type (yet). In such cases, the type validation is not performed.

Type checks for user-defined functions and procedures


Documentation

The JetBrains IDE plugin provides the ability to view documentation for functions and procedures inline.

In-line documentation for Neo4j user-defined functions and procedures


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.

Language Injection

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!

Programming language injection for the JetBrains IDE plugin


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:

Data Sources


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
Data source management for the graph database support plugin


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.

Query Editor

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).

Cypher query editor for the JetBrains IDE plugin


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 EXPLAIN-based inspections)
    • 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
All this information becomes available for autocompletion while writing Cypher queries.

User-defined procedures and functions also will have information about parameters and return values that will be visible in autocompletion (and documentation!).

Console


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.

Log

Anything that happens in the plugin will have information in a log, including:
    • Query execution
    • Data source metadata refresh
    • Parameter parsing errors
The console log for the JetBrains IDE plugin


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:
    • Graph
    • Table
Graph

The graph view is what graph databases are all about: viewing your data as connected entities.

Graph data result view for the JetBrains plugin


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
Table

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.

Table data results view in the JetBrains IDE plugin


Analyze Cypher Queries

Whenever a Cypher query is executed with an EXPLAIN or PROFILE keyword, a new tab is added to the console with a query execution plan.

Cypher query analyzer using EXPLAIN or PROFILE


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
Parameters

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.

Cypher query parameters in the JetBrains IDE plugin


Numbers!


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

Conclusion


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.


Want to learn more about graph databases and Neo4j? Click below to register for our online training class, Introduction to Graph Databases and master the world of graph technology in no time.

Sign Me Up