When started, Memgraph will automatically attempt to load the query modules
*.py files it finds in the default
/usr/lib/memgraph/query_modules directory. The
*.so modules are written
using the C API and the
*.py modules are written using the Python API. Each
file corresponds to one query module. The names of these files will be mapped to
the query module names. For example,
nxalg.py will be mapped to
in the Cypher query language.
If you want to change the directory in which Memgraph searches for query
modules, just change the
--query-modules-directory flag in the main
configuration file (
/etc/memgraph/memgraph.conf) or supply it as a
command-line parameter (e.g. when using Docker).
Query procedures that allow the users to gain more insight into other query
modules and their procedures are written under the utility query module named
This module offers three procedures with the following signatures:
mg.procedures() :: (name :: STRING, signature :: STRING): Lists loaded procedures and their signatures.
mg.load(module_name :: STRING) :: (): Loads or reloads the given module.
mg.load_all() :: (): Loads or reloads all query modules.
For example, invoking
mg.procedures() with Cypher looks like this:
The result will be similar to the following:
In this case, we can see that Memgraph has successfully loaded all the procedures implemented in query modules including the utility query procedures.
To load a module (named e.g.
hello) that wasn't loaded on startup (perhaps
because it was added to Memgraph's query modules directory afterwards), we
can simply invoke:
If we wish to reload an existing module, say the
graph_analyzer module above, we
again use the same procedure:
Lastly, if we wish to reload all existing modules and load any newly added ones we can use: