Skip to content

Commit

Permalink
Use /queries endpoint for openCypher (#705)
Browse files Browse the repository at this point in the history
* Use /queries endpoint for %%oc

* update changelog
  • Loading branch information
michaelnchin authored Oct 1, 2024
1 parent 7f02355 commit 46f5e68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd

## Upcoming

- Updated `%%oc` to use the `/queries` endpoint for Neptune Analytics ([Link to PR](https://github.com/aws/graph-notebook/pull/705))
- Added experimental TinkerPop 4.0 support ([Link to PR](https://github.com/aws/graph-notebook/pull/704))
- Added documentation for group keys in `%%graph_notebook_vis_options` ([Link to PR](https://github.com/aws/graph-notebook/pull/703))
- Enabled `--query-timeout` on `%%oc explain` for Neptune Analytics ([Link to PR](https://github.com/aws/graph-notebook/pull/701))
Expand Down
24 changes: 16 additions & 8 deletions src/graph_notebook/neptune/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,23 +541,31 @@ def opencypher_http(self, query: str, headers: dict = None, explain: str = None,
if headers is None:
headers = {}

url = f'{self._http_protocol}://{self.host}:{self.port}/'
url = f'{self._http_protocol}://{self.host}'

if self.is_neptune_domain():
if 'content-type' not in headers:
headers['content-type'] = 'application/x-www-form-urlencoded'
url += 'openCypher'
data = {}
if self.is_analytics_domain():
url += f'/queries'
data['language'] = 'opencypher'
else:
if 'content-type' not in headers:
headers['content-type'] = 'application/x-www-form-urlencoded'
url += f':{self.port}/openCypher'
if plan_cache:
if plan_cache not in OPENCYPHER_PLAN_CACHE_MODES:
print('Invalid --plan-cache mode specified, defaulting to auto.')
else:
if self.is_analytics_domain():
data['planCache'] = plan_cache
elif plan_cache != 'auto':
query = set_plan_cache_hint(query, plan_cache)
if plan_cache != 'auto':
if self.is_analytics_domain():
data['planCache'] = plan_cache
else:
query = set_plan_cache_hint(query, plan_cache)
data['query'] = query
if explain:
if self.is_analytics_domain():
data['explain.mode'] = explain
data['explain-mode'] = explain
data['explain'] = explain
headers['Accept'] = "text/html"
if query_params:
Expand Down

0 comments on commit 46f5e68

Please sign in to comment.