Skip to content

Commit

Permalink
Only send queryId when using proxy server (#529)
Browse files Browse the repository at this point in the history
* Only send queryId when using proxy server

* Update changelog
  • Loading branch information
kmcginnes authored Aug 1, 2024
1 parent 23280f0 commit 79aa7f0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ a more pleasant experience, especially for users with larger databases.
- **Fixed** some SPARQL endpoints by using `application/sparql-results+json`
accept header for SPARQL requests
([#499](https://github.com/aws/graph-explorer/pull/499))
- **Fixed** CORS issue for some SPARQL and Gremlin endpoints due to `queryId` in
the request headers ([#529](https://github.com/aws/graph-explorer/pull/529))
([#499](https://github.com/aws/graph-explorer/pull/499))
- **Fixed** text wrapping for labels in edge styling sidebar
([#499](https://github.com/aws/graph-explorer/pull/499))
- **Fixed** potential error when the request body is very large by increasing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function _gremlinFetch(connection: ConnectionConfig, options: any) {
"Content-Type": "application/json",
Accept: "application/vnd.gremlin-v3.0+json",
};
if (options?.queryId && connection?.proxyConnection === true) {
if (options?.queryId && connection.proxyConnection === true) {
headers.queryId = options.queryId;
}

Expand Down
21 changes: 11 additions & 10 deletions packages/graph-explorer/src/connector/sparql/sparqlExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,17 @@ function _sparqlFetch(connection: ConnectionConfig, options?: any) {
return async (queryTemplate: string) => {
logger.debug(queryTemplate);
const body = `query=${encodeURIComponent(queryTemplate)}`;
const headers = options?.queryId
? {
accept: "application/sparql-results+json",
"Content-Type": "application/x-www-form-urlencoded",
queryId: options.queryId,
}
: {
accept: "application/sparql-results+json",
"Content-Type": "application/x-www-form-urlencoded",
};
const headers =
options?.queryId && connection.proxyConnection === true
? {
accept: "application/sparql-results+json",
"Content-Type": "application/x-www-form-urlencoded",
queryId: options.queryId,
}
: {
accept: "application/sparql-results+json",
"Content-Type": "application/x-www-form-urlencoded",
};
return fetchDatabaseRequest(connection, `${connection.url}/sparql`, {
method: "POST",
headers,
Expand Down

0 comments on commit 79aa7f0

Please sign in to comment.