executeQuery method

Future<ExecuteQueryOutput> executeQuery({
  1. required String graphIdentifier,
  2. required QueryLanguage language,
  3. required String queryString,
  4. ExplainMode? explainMode,
  5. Map<String, Document>? parameters,
  6. PlanCacheType? planCache,
  7. int? queryTimeoutMilliseconds,
})

Execute an openCypher query.

When invoking this operation in a Neptune Analytics cluster, the IAM user or role making the request must have a policy attached that allows one of the following IAM actions in that cluster, depending on the query:

  • neptune-graph:ReadDataViaQuery
  • neptune-graph:WriteDataViaQuery
  • neptune-graph:DeleteDataViaQuery

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ThrottlingException. May throw UnprocessableException. May throw ValidationException.

Parameter graphIdentifier : The unique identifier of the Neptune Analytics graph.

Parameter language : The query language the query is written in. Currently only openCypher is supported.

Parameter queryString : The query string to be executed.

Parameter explainMode : The explain mode parameter returns a query explain instead of the actual query results. A query explain can be used to gather insights about the query execution such as planning decisions, time spent on each operator, solutions flowing etc.

Parameter parameters : The data parameters the query can use in JSON format. For example: {"name": "john", "age": 20}. (optional)

Parameter planCache : Query plan cache is a feature that saves the query plan and reuses it on successive executions of the same query. This reduces query latency, and works for both READ and UPDATE queries. The plan cache is an LRU cache with a 5 minute TTL and a capacity of 1000.

Parameter queryTimeoutMilliseconds : Specifies the query timeout duration, in milliseconds. (optional)

Implementation

Future<ExecuteQueryOutput> executeQuery({
  required String graphIdentifier,
  required QueryLanguage language,
  required String queryString,
  ExplainMode? explainMode,
  Map<String, Document>? parameters,
  PlanCacheType? planCache,
  int? queryTimeoutMilliseconds,
}) async {
  final headers = <String, String>{
    'graphIdentifier': graphIdentifier.toString(),
  };
  final $payload = <String, dynamic>{
    'language': language.value,
    'query': queryString,
    if (explainMode != null) 'explain': explainMode.value,
    if (parameters != null) 'parameters': parameters,
    if (planCache != null) 'planCache': planCache.value,
    if (queryTimeoutMilliseconds != null)
      'queryTimeoutMilliseconds': queryTimeoutMilliseconds,
  };
  final response = await _protocol.sendRaw(
    payload: $payload,
    method: 'POST',
    requestUri: '/queries',
    headers: headers,
    endpoint: _resolveEndpoint(
      apiType: 'DataPlane',
    ),
    hostPrefix: '${graphIdentifier}.',
    exceptionFnMap: _exceptionFns,
  );
  return ExecuteQueryOutput(
    payload: await response.stream.toBytes(),
  );
}