Server#

This module contains helper functions and classes for working with the GraphQL server for Raphtory. Calling the run_server function will start the GraphQL server. If run in the background, this will return a GraphQLServer object that can be used to run queries.

Classes:

GraphQLServer(port)

A helper class that can be used to query the Raphtory GraphQL server.

Functions:

run_server([graphs, graph_dir, port, daemon])

Runs the Raphtory GraphQL server.

class raphtory.graphqlserver.GraphQLServer(port)[source]#

Bases: object

A helper class that can be used to query the Raphtory GraphQL server.

Methods:

query(query)

Runs a GraphQL query on the server.

wait_for_online()

Waits for the server to be online.

query(query)[source]#

Runs a GraphQL query on the server.

Parameters:

query(str) – The GraphQL query to run.

Raises:

Exception – If the query fails to run.

Returns:

Returns the json-encoded content of a response, if any.

wait_for_online()[source]#

Waits for the server to be online. This is called automatically when run_server is called.

raphtory.graphqlserver.run_server(graphs=None, graph_dir=None, port=1736, daemon=False)[source]#

Runs the Raphtory GraphQL server.

Parameters:
  • graphs (dict, optional) – A dictionary of graphs to load into the server. Default is None.

  • graph_dir (str, optional) – The directory to load graphs from. Default is None.

  • port (int, optional) – The port to run the server on. Default is 1736.

  • daemon (bool, optional) – Whether to run the server in the background. Default is False.

Returns:

A GraphQLServer object that can be used to query the server. (Only if daemon is True)

Return type:

GraphQLServer