12.1.3 Preloading a Graph

You can configure the graph server (PGX) to preload graphs in memory at startup-time. This can be useful when you want the graph server (PGX) to startup automatically and have a graph (or multiple graphs) ready for its users. For example, deploying the graph server (PGX) on Kubernetes can be one such scenario.

The configuration for this is done through the preload_graphs configuration field in the graph server (PGX) configuration file.

The following is an example for preloading a graph using the graph configuration file:

{ 
  "preload_graphs": [
    {
      "path": "<path-to-graph-config>",
      "name": "my-graph"      
    }
  ],
  "authorization": [{
    "pgx_role": "GRAPH_DEVELOPER",
    "pgx_permissions": [{
      "preloaded_graph": "my-graph",
      "grant": "read"
    }]
  },	
	....
  ]
}

You can access a preloaded graph by its name using the getGraph() method of the session object.

PgxGraph g = session.getGraph("my-graph");