Skip to content

GraphServer #

Bases: object

A class for defining and running a Raphtory GraphQL server

Parameters:

Name Type Description Default
work_dir str | PathLike

the working directory for the server

required
cache_capacity int

the maximum number of graphs to keep in memory at once

required
cache_tti_seconds int

the inactive time in seconds after which a graph is evicted from the cache

required
log_level str

the log level for the server

required
tracing bool

whether tracing should be enabled

required
tracing_level str

tracing verbosity (e.g. "ERROR", "WARN", "INFO", "DEBUG", "TRACE").

required
otlp_agent_host str

OTLP agent host for tracing

required
otlp_agent_port str

OTLP agent port for tracing

required
otlp_tracing_service_name str

The OTLP tracing service name

required
config_path str | PathLike

Path to the config file

required
auth_public_key str

Base64-encoded public key used to verify bearer tokens

required
require_auth_for_reads bool

Require auth tokens for read queries

required
create_index bool

Build a search index on startup

required
heavy_query_limit int

Maximum number of expensive traversal queries (outComponent, inComponent, edges, outEdges, inEdges, neighbours, outNeighbours, inNeighbours) allowed to run simultaneously. Extra queries are parked on a semaphore.

required
exclusive_writes bool

If True, ingestion/write operations run one at a time and block reads until complete.

required
disable_batching bool

If True, batched GraphQL requests are rejected. Prevents bypassing per-request depth/complexity limits.

required
max_batch_size int

Caps the number of queries accepted in a single batched request.

required
disable_lists bool

If True, bulk list endpoints on collections are disabled. Clients must use page instead.

required
max_page_size int

Maximum page size allowed on paged collection queries.

required
max_query_depth int

Maximum nesting depth of a query.

required
max_query_complexity int

Maximum estimated cost of a query, based on the number of fields selected.

required
max_recursive_depth int

Internal safety limit to prevent stack overflows from pathologically structured queries (async-graphql default is 32).

required
max_directives_per_field int

Maximum number of directives on any single field.

required
disable_introspection bool

If True, schema introspection is disabled entirely.

required
permissions_store_path str | PathLike

Path to the permissions store (used by the optional auth extension).

required

__new__(work_dir, cache_capacity=None, log_level=None, tracing=None, tracing_level=None, otlp_agent_host=None, otlp_agent_port=None, otlp_tracing_service_name=None, auth_public_key=None, require_auth_for_reads=None, config_path=None, create_index=None, heavy_query_limit=None, exclusive_writes=None, disable_batching=None, max_batch_size=None, disable_lists=None, max_page_size=None, max_query_depth=None, max_query_complexity=None, max_recursive_depth=None, max_directives_per_field=None, disable_introspection=None, permissions_store_path=None) #

Create and return a new object. See help(type) for accurate signature.

run(port=None, timeout_ms=180000) #

Run the server until completion.

Parameters:

Name Type Description Default
port int

The port to use. If not specified, tries 1736 by default and if that is not available starts on an arbitrary port. If specified and the port is in use, the server will fail to start.

None
timeout_ms int

Timeout for waiting for the server to start. Defaults to 180000.

180000

Returns:

Type Description
None

start(port=None, timeout_ms=5000) #

Start the server and return a handle to it.

Parameters:

Name Type Description Default
port int

the port to use. If not specified, tries 1736 by default and if that is not available starts on an arbitrary port. If specified and the port is in use, the server will fail to start.

None
timeout_ms int

wait for server to be online. Defaults to 5000.

5000

The server is stopped if not online within timeout_ms but manages to come online as soon as timeout_ms finishes!

Returns:

Type Description
RunningGraphServer

The running server

turn_off_index() #

Turn off index for all graphs.

Returns:

Type Description
None

vectorise_all_graphs(embeddings, nodes=True, edges=True) #

Vectorise all graphs in the server working directory.

Parameters:

Name Type Description Default
embeddings OpenAIEmbeddings

the embeddings to use

required
nodes bool | str

if nodes have to be embedded or not or the custom template to use if a str is provided. Defaults to True.

True
edges bool | str

if edges have to be embedded or not or the custom template to use if a str is provided. Defaults to True.

True

Returns:

Type Description
None

vectorise_graph(name, embeddings, nodes=True, edges=True) #

Vectorise the graph name in the server working directory.

Parameters:

Name Type Description Default
name list[str]

the name of the graph to vectorise.

required
embeddings OpenAIEmbeddings

the embeddings to use

required
nodes bool | str

if nodes have to be embedded or not or the custom template to use if a str is provided. Defaults to True.

True
edges bool | str

if edges have to be embedded or not or the custom template to use if a str is provided. Defaults to True.

True

Returns:

Type Description
None