Server#

class raphtory.graphql.RaphtoryServer(graphs=None, graph_dir=None)#

Bases: object

A class for defining and running a Raphtory GraphQL server

Methods:

run([port, log_level])

Run the server until completion.

start([port, log_level])

Start the server and return a handle to it.

with_document_search_function(name, input, ...)

Register a function in the GraphQL schema for document search over a graph.

with_global_search_function(name, input, ...)

Register a function in the GraphQL schema for document search among all the graphs.

with_vectorised(cache[, graph_names, ...])

Vectorise a subset of the graphs of the server.

run(port=1736, log_level=...)#

Run the server until completion.

Parameters:

port (*) – the port to use (defaults to 1736).

start(port=1736, log_level=...)#

Start the server and return a handle to it.

Parameters:

port (*) – the port to use (defaults to 1736).

with_document_search_function(name, input, function)#

Register a function in the GraphQL schema for document search over a graph.

The function needs to take a VectorisedGraph as the first argument followed by a pre-defined set of keyword arguments. Supported types are str, int, and float. They have to be specified using the input parameter as a dict where the keys are the names of the parameters and the values are the types, expressed as strings.

Parameters:
  • name (*) – the name of the function in the GraphQL schema.

  • input (*) – the keyword arguments expected by the function.

  • function (*) – the function to run.

Returns:

A new server object containing the vectorised graphs.

with_global_search_function(name, input, function)#

Register a function in the GraphQL schema for document search among all the graphs.

The function needs to take a GraphqlGraphs object as the first argument followed by a pre-defined set of keyword arguments. Supported types are str, int, and float. They have to be specified using the input parameter as a dict where the keys are the names of the parameters and the values are the types, expressed as strings.

Parameters:
  • name (*) – the name of the function in the GraphQL schema.

  • input (*) – the keyword arguments expected by the function.

  • function (*) – the function to run.

Returns:

A new server object containing the vectorised graphs.

with_vectorised(cache, graph_names=None, embedding=None, graph_document=None, node_document=None, edge_document=None)#

Vectorise a subset of the graphs of the server.

Note

If no embedding function is provided, the server will attempt to use the OpenAI API embedding model, which will only work if the env variable OPENAI_API_KEY is set appropriately

Parameters:
  • graph_names (*) – the names of the graphs to vectorise. All by default.

  • cache (*) – the directory to use as cache for the embeddings.

  • embedding (*) – the embedding function to translate documents to embeddings.

  • node_document (*) – the property name to use as the source for the documents on nodes.

  • edge_document (*) – the property name to use as the source for the documents on edges.

Returns:

A new server object containing the vectorised graphs.