Skip to content

Commit 46f5e68

Browse files
authored
Use /queries endpoint for openCypher (#705)
* Use /queries endpoint for %%oc * update changelog
1 parent 7f02355 commit 46f5e68

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd
44

55
## Upcoming
66

7+
- Updated `%%oc` to use the `/queries` endpoint for Neptune Analytics ([Link to PR](https://github.com/aws/graph-notebook/pull/705))
78
- Added experimental TinkerPop 4.0 support ([Link to PR](https://github.com/aws/graph-notebook/pull/704))
89
- Added documentation for group keys in `%%graph_notebook_vis_options` ([Link to PR](https://github.com/aws/graph-notebook/pull/703))
910
- Enabled `--query-timeout` on `%%oc explain` for Neptune Analytics ([Link to PR](https://github.com/aws/graph-notebook/pull/701))

src/graph_notebook/neptune/client.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,23 +541,31 @@ def opencypher_http(self, query: str, headers: dict = None, explain: str = None,
541541
if headers is None:
542542
headers = {}
543543

544-
url = f'{self._http_protocol}://{self.host}:{self.port}/'
544+
url = f'{self._http_protocol}://{self.host}'
545545

546546
if self.is_neptune_domain():
547-
if 'content-type' not in headers:
548-
headers['content-type'] = 'application/x-www-form-urlencoded'
549-
url += 'openCypher'
550547
data = {}
548+
if self.is_analytics_domain():
549+
url += f'/queries'
550+
data['language'] = 'opencypher'
551+
else:
552+
if 'content-type' not in headers:
553+
headers['content-type'] = 'application/x-www-form-urlencoded'
554+
url += f':{self.port}/openCypher'
551555
if plan_cache:
552556
if plan_cache not in OPENCYPHER_PLAN_CACHE_MODES:
553557
print('Invalid --plan-cache mode specified, defaulting to auto.')
554558
else:
555-
if self.is_analytics_domain():
556-
data['planCache'] = plan_cache
557-
elif plan_cache != 'auto':
558-
query = set_plan_cache_hint(query, plan_cache)
559+
if plan_cache != 'auto':
560+
if self.is_analytics_domain():
561+
data['planCache'] = plan_cache
562+
else:
563+
query = set_plan_cache_hint(query, plan_cache)
559564
data['query'] = query
560565
if explain:
566+
if self.is_analytics_domain():
567+
data['explain.mode'] = explain
568+
data['explain-mode'] = explain
561569
data['explain'] = explain
562570
headers['Accept'] = "text/html"
563571
if query_params:

0 commit comments

Comments
 (0)