You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

Graph

Graph

Search results for "Graph"

to_graph_object()

Tries to convert given object or collection containing graph objects into a graph object. If an element in the source can not be converted to a graph object, it is ignored. Graph objects can be used in repeaters for example and thus it can be useful to create custom graph objects for iteration in such contexts. The optional view parameter can be used to select the view representation of the entity. If no view is given, the public view is used. The optional depth parameter defines at which depth the conversion stops. If no depth is given, the default value of 3 is used.

to_graph_object(source [, view = 'public' [, depth = 3]])

Why Structr?

Structr accelerates many processes of modern software development because of its unique approach: Storing the definition of the app as a Graph. A graph is a network of objects (nodes), connected by edges (relationships).

Storing application information in form of a graph allows developers to modify the parts of the app at any time and directly run the software off the graph.

This type-awareness is also available for the remote properties of the entities in the graph database. Entities (or nodes in the graph database) can be linked in the table by clicking on the “+” icon in the cells and selecting the node that should be linked.

Graph-based permission resolution

Structr provides graph-based permission resolution to control access rights for non-admin users based on a domain security model. By setting rules for how access rights are propagated over relationships in the graph, the effective access permissions can be controlled.

Troubleshooting

If you experience problems connecting to a Neo4j instance that runs inside of Neo4j Desktop, please review the following settings.

  • For Structr versions <4.x, Neo4j Graph version must be 3.5.x.
  • Connection URL / port (in Neo4j Desktop -> Graph: go to Manage and review Bolt port (7687))
  • Windows Firewall

Permission Grants

The SECURITY relationship can have different combinations of permissions in its allowed attribute:

read The user has access to the node and can read the node from the database.
write The user can alter the node in the database. This permission is also necessary for linking or unlinking the node to other nodes in the graph.
delete The user can delete the node from the database. If a node has relationships to other nodes in the database, the user has to have write permissions on those connected nodes, because delete one node in the graph will affect all neighboring nodes.
accessControl The user can grant access to other users and user groups.

Nested Objects

One of the most important and powerful functions of the Structr REST API is the ability to transform nested JSON objects into graph structures, and vice-versa. The transformation is based on contextual properties in the data model, which encapsulate the relationships between nodes in the graph.

GraphQLServlet

graphqlservlet.defaultview Default view to use when no view is given in the URL.
graphqlservlet.outputdepth Maximum nesting depth of JSON output.

Database Connections

Name The name of this connection, to allow you to easily distinguish multiple configured connections.
Driver Database driver, either Neo4j or Memgraph DB.
Connection URL URL to the remote database.
Database Name Database name to use (available from v4.1). Defaults to neo4j (if the installation start with an earlier version of neo4j, graph.db will be the correct value)
Username Username to login to the database.
Password Password to login to the database.
Connect immediately Controlls if a connection should be established immediately or manually.

Log messages

WARN  o.s.core.graph.search.SearchCommand - Non-indexed property key Paragraph.content is used in query. This can lead to performance problems in large databases.

Simple Data Model

Changing the schema definition, like in this example by creating a new type, triggers a so-called schema recompilation. A message is displayed that blocks the screen and indicates that the schema is being compiled. Under the hood, the definition graph of the data model is modified, source code is generated from it and validated against the existing schema. When the compilation process is finished, the updated schema definition is available in all parts of the entire application without delay and any further deployment steps.

Output Depth of result

If a view is created on multiple node types and contains remote node objects, then the output depth of the result JSON is restricted to the level of 3 by default. This is to prevent the whole graph from being rendered, which could happen in some scenarios like trees for examples.

With the query paramteter _outputNestingDepth (outputNestingDepth for Structr versions < 4.x) the output depth of the result JSON can be adjusted to the desired level.

Log messages

The reason for this is that, since version 4.1-SNAPSHOT, structr supports connecting to different neo4j databases. The database name has to be configured though. By default the database name is set to “neo4j” (because that is the default database name since neo4j 4.x). If your application started with an older version of neo4j, then the database name might be “graph.db”. If you have configured a different name, then that name has to be used.

The configuration for this is done in structr.conf. A new configuration line has to be added to the existing configuration.

Let us assume the configuration looks like this:

XXXXXXXXXX.database.connection.name = <a name for your connection>
XXXXXXXXXX.database.connection.password = <your database user password>
XXXXXXXXXX.database.connection.url = <your connection string>
XXXXXXXXXX.database.connection.username = <your database username>

XXXXXXXXXX is the custom prefix in your settings.

The new line would need to match the XXXXXXXXXX and look like this:

XXXXXXXXXX.database.connection.databasename =

Neo4j Upgrade

If the version upgrade is from below Neo4j v4, then it is possible that the default database is called “graph.db” instead of the newer “neo4j” in version 4 and up. Since v4.1 Structr supports selecting a database (if supported by the Neo4j installation it is connecting to). The default database it connects to is the “neo4j” database - if the migration happened from an older version, the correct database name needs to be configured via structr.conf file using the “xxxx.database.connection.databasename” setting as shown in the following example in line 4.

User Interface

A Structr page is a tree-like structure of nested HTML elements, stored in the graph database, so the representation in the database corresponds exactly to the structure of the HTML output. In the rendering process, a page behaves like a declarative “program” that combines context information, access control and script expressions to create a dynamic HTML document.

About Structr

The About Structr section lists the information about the current Structr system and the installed license.

Version The installed version of the Structr software. The format is release build-commit build-time.
Edition The installed edition of Structr (Community or Enterprise).
Modules The available modules of the installed license. When the edition is Community the base modules core, rest and ui are enabled by default.
Licensee The licensee of the active license.
Host ID The unique ID of the hardware system the Structr software runs on. The host ID is used to restrict a license to one system. It is calculated by different hardware-specific information like the enabled network interfaces. The host ID will change if the hardware configuration changes and invalidate the license. In this case, you need to obtain a new license for the new host ID.
License Start Date Start date of the active license.
License End Date End date of the active license.
Database Driver Currently supported databases include Neo4j Bolt, In-Memory and Memgraph.

Accessing the Data

Structr automatically creates REST endpoints from the data model that allow you to read and write data as JSON documents. You can send a JSON document to an endpoint, and Structr automatically creates the corresponding object structure in the database, based on the schema definition in the data model. This works in both directions, so Structr is essentially a document database extension on a graph database.

Rendering Engine

You can see this DOM structure in every page in the Pages area. This is not just a visual development aid, but reflects the actual data in the database. More precisely, a page is literally stored as the structure of its DOM tree inside the graph database, i.e. each node in the DOM tree is stored as an individual node in the database, connected by edges expressing their parent-child relationships.

Template Expressions

For complex processes within a template JavaScript can be used, because there are no directives or extra flow control elements in Structr templates unlike in Freemarker. Structr offers a very similar concept, show conditions, which are discussed in more detail in the “Visibility” paragraph below.

Widgets

Widgets can also contain Cypher statements to create or modify graph objects on database level.