-
Notifications
You must be signed in to change notification settings - Fork 12
new: Add query sharing with params #1287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tonilastre
wants to merge
1
commit into
memgraph-3-3
Choose a base branch
from
new/add-lab-query-sharing-params
base: memgraph-3-3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,15 +17,15 @@ Here are the currently available sharing features: | |||||||||
|
||||||||||
- [Graph Style Script (GSS) sharing](#graph-style-script-sharing) – Share custom | ||||||||||
graph styling scripts among team members to maintain a consistent | ||||||||||
visualization style. | ||||||||||
visualization style. | ||||||||||
- [Query sharing](#query-sharing) – Create a shareable link for their Cypher | ||||||||||
query, Graph Style Script, and query parameters with a single click. | ||||||||||
|
||||||||||
[Remote storage](#remote-storage-1) is required to use both sharing features. | ||||||||||
|
||||||||||
<Callout type="info"> | ||||||||||
**Enterprise**: Sharing features require a Memgraph Enterprise license [configured on the Lab | ||||||||||
side](/memgraph-lab/configuration#adding-memgraph-enterprise-license). | ||||||||||
side](/memgraph-lab/configuration#adding-memgraph-enterprise-license). | ||||||||||
</Callout> | ||||||||||
|
||||||||||
<Callout type="info"> | ||||||||||
|
@@ -166,7 +166,8 @@ access logs for enhanced security and accountability. | |||||||||
|
||||||||||
Before using Query Sharing, make sure it’s properly [set up](#set-up-query-sharing). | ||||||||||
Once configured, you can learn how to: | ||||||||||
- [Create a query share](#create-a-query-share) | ||||||||||
- [Create a query share](#create-a-query-share) | ||||||||||
- [Create a parameterized query share using query params](#create-a-parameterized-query-share-using-query-params) | ||||||||||
- [View query share history](#view-query-share-history) | ||||||||||
- [Access and view a query share](#access-and-view-a-query-share) | ||||||||||
|
||||||||||
|
@@ -230,15 +231,96 @@ creator can also select which query results to show first. This is | |||||||||
particularly useful when sharing a multi-query that involves setup | ||||||||||
queries followed by a graph algorithm whose results are to be | ||||||||||
displayed first. | ||||||||||
The creator can also choose whether the query will auto-run when | ||||||||||
opened, or allow the viewer to decide whether to run the query, | ||||||||||
add it to a collection, or dismiss it. | ||||||||||
|
||||||||||
Upon creation, the user receives a URL that can be shared with other | ||||||||||
team members who have access to the same Lab and Memgraph instance. | ||||||||||
|
||||||||||
 | ||||||||||
 | ||||||||||
|
||||||||||
 | ||||||||||
 | ||||||||||
|
||||||||||
 | ||||||||||
 | ||||||||||
|
||||||||||
### Create a parameterized query share using query params | ||||||||||
|
||||||||||
Cypher query parameters are useful for creating a single query share | ||||||||||
that acts as a template. With this approach, you can change the values | ||||||||||
used in the query directly from the query share URL—without needing | ||||||||||
to create a separate query share for every combination of values. | ||||||||||
|
||||||||||
{<h4 className="custom-header">Example scenario</h4>} | ||||||||||
|
||||||||||
Let’s say you have a graph where one type of node is labeled `Country`. | ||||||||||
You might start with a basic query that returns neighboring nodes | ||||||||||
for a specific country and limits the number of results: | ||||||||||
|
||||||||||
``` | ||||||||||
MATCH (n)-[e]-(m) | ||||||||||
WHERE n.name = "France" | ||||||||||
RETURN n, e, m | ||||||||||
LIMIT 10; | ||||||||||
``` | ||||||||||
|
||||||||||
If you wanted to share a similar query for Germany or change the result | ||||||||||
limit, you'd traditionally need to create separate query shares, | ||||||||||
such as: | ||||||||||
|
||||||||||
* `http://<lab-domain>?shareId=100` (name: France, limit: 10) | ||||||||||
* `http://<lab-domain>?shareId=200` (name: Germany, limit: 100) | ||||||||||
* `http://<lab-domain>?shareId=300` (name: Spain, limit: 10) | ||||||||||
|
||||||||||
This leads to multiple shares for what is essentially the same query | ||||||||||
logic. | ||||||||||
|
||||||||||
{<h4 className="custom-header">Using query parameters</h4>} | ||||||||||
|
||||||||||
Instead, you can use Cypher parameters to generalize the query. | ||||||||||
Here’s a parameterized version using `name` and `limit`: | ||||||||||
|
||||||||||
``` | ||||||||||
// Cypher query: | ||||||||||
MATCH (n)-[e]-(m) | ||||||||||
WHERE n.name = $name | ||||||||||
RETURN n, e, m | ||||||||||
LIMIT toInteger($limit); | ||||||||||
|
||||||||||
// Params: { "name": "France", "limit": "10" } | ||||||||||
``` | ||||||||||
|
||||||||||
 | ||||||||||
|
||||||||||
 | ||||||||||
|
||||||||||
You can now share one query and pass values dynamically through | ||||||||||
the URL using the following format: | ||||||||||
Comment on lines
+297
to
+298
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
* `http://......&shareParams=<param>:<value>` | ||||||||||
|
||||||||||
For example: | ||||||||||
|
||||||||||
* `http://<lab-domain>?shareId=100&shareParams=name:France&shareParams=limit:10` (name: France, limit: 10) | ||||||||||
* `http://<lab-domain>?shareId=100&shareParams=name:Germany&shareParams=limit:100` (name: Germany, limit: 100) | ||||||||||
* `http://<lab-domain>?shareId=100&shareParams=name:Spain&shareParams=limit:10` (name: Spain, limit: 10) | ||||||||||
|
||||||||||
 | ||||||||||
|
||||||||||
Each link uses the same `shareId`, but overrides the parameters | ||||||||||
using the URL. If a parameter is not provided in the URL, the | ||||||||||
default value (as set during query creation) will be used. | ||||||||||
|
||||||||||
<Callout type="info"> | ||||||||||
|
||||||||||
All query parameters passed through the URL are interpreted as | ||||||||||
strings. If your query expects another type (like an integer), | ||||||||||
you must cast it appropriately. | ||||||||||
|
||||||||||
In the example above, we use `toInteger($limit)` to convert the | ||||||||||
limit parameter. | ||||||||||
|
||||||||||
</Callout> | ||||||||||
|
||||||||||
### View query share history | ||||||||||
|
||||||||||
|
Binary file removed
BIN
-53.7 KB
public/pages/data-visualization/lab-user-manual/query-sharing/2_sharequery_1.png
Binary file not shown.
Binary file removed
BIN
-69.5 KB
public/pages/data-visualization/lab-user-manual/query-sharing/3_sharequery_2.png
Binary file not shown.
Binary file removed
BIN
-66.6 KB
public/pages/data-visualization/lab-user-manual/query-sharing/4_sharequery_3.png
Binary file not shown.
Binary file added
BIN
+892 KB
.../data-visualization/lab-user-manual/query-sharing/query-share-configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+520 KB
...es/data-visualization/lab-user-manual/query-sharing/query-share-query-setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+485 KB
...ata-visualization/lab-user-manual/query-sharing/query-share-template-params.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+493 KB
...data-visualization/lab-user-manual/query-sharing/query-share-template-query.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1020 KB
...ges/data-visualization/lab-user-manual/query-sharing/query-share-url-params.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1010 KB
public/pages/data-visualization/lab-user-manual/query-sharing/query-share-url.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.