Skip to content

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
wants to merge 1 commit into
base: memgraph-3-3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pages/memgraph-lab/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ valid Memgraph Enterprise license are available only in a Docker environment.
| `STORAGE_MG_USERNAME` | `(Enterprise only)` Memgraph username for the Lab remote storage | `string` | |
| `STORAGE_MG_PASSWORD` | `(Enterprise only)` Memgraph password for the Lab remote storage | `string` | |
| `STORAGE_MG_CONNECT_TIMEOUT_MS` | `(Enterprise only)` Connection timeout in milliseconds for remote storage | `integer` | `10000` |
| `STORAGE_MG_CONNECT_RETRY_MAX_COUNT` | `(Enterprise only)` The maximum number of retries allowed for a successful connection during Lab startup | `integer` | `5` |
| `STREAM_NAME_MAX_LEN` | Max length of the stream name | `integer` | `500` |
| `STREAM_VALIDATION_IS_ENABLED` | State of stream validation | `boolean` | `false` |

Expand Down
94 changes: 88 additions & 6 deletions pages/memgraph-lab/features/sharing-features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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.

![](/pages/data-visualization/lab-user-manual/query-sharing/2_sharequery_1.png)
![](/pages/data-visualization/lab-user-manual/query-sharing/query-share-query-setup.png)

![](/pages/data-visualization/lab-user-manual/query-sharing/3_sharequery_2.png)
![](/pages/data-visualization/lab-user-manual/query-sharing/query-share-configuration.png)

![](/pages/data-visualization/lab-user-manual/query-sharing/4_sharequery_3.png)
![](/pages/data-visualization/lab-user-manual/query-sharing/query-share-url.png)

### Create a parameterized query share using query params
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Create a parameterized query share using query params
### Create a parameterized query share using query parameters


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" }
```

![](/pages/data-visualization/lab-user-manual/query-sharing/query-share-template-query.png)

![](/pages/data-visualization/lab-user-manual/query-sharing/query-share-template-params.png)

You can now share one query and pass values dynamically through
the URL using the following format:
Comment on lines +297 to +298
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can now share one query and pass values dynamically through
the URL using the following format:
You can now share one query and parameter values dynamically through
the URL using the following format:


* `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)

![](/pages/data-visualization/lab-user-manual/query-sharing/query-share-url-params.png)

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

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.