How to Edit, Run, and Share a GSQL Query

The GSQL Editor provides a feature-rich environment for writing, modifying, and executing GSQL queries. With the GSQL Editor, you can leverage the syntax highlighting, auto-complete, and error checking features to write efficient and accurate GSQL queries.

By executing queries in the GSQL Editor you can then visualize the results, making it easier to iterate and refine your analysis.

GSQL is a powerful graph query language that enables you to express complex graph traversal and analysis operations. For more information about GSQL please visit GSQL Query Language

Edit GSQL Query

To start writing your first GSQL query:
  1. Click on the GSQL Query from the + menu.

    Screenshot 2024 04 18 at 10.12.15 AM

    The opened files will be listed on the top tabs on the code edit folder

    Screenshot 2024 04 18 at 10.12.40 AM

    Schema based GSQL autocomplete is not yet supported.

Run GSQL Query

To run a GSQL Query, start by:
  1. Select an active workspace to run the GSQL Query.

    Screenshot 2024 04 18 at 10.13.20 AM
  2. To run a query, there are two options available: Run All and Run Selected.

    Screenshot 2024 04 18 at 10.13.47 AM
    • Run All: The Run All option executes the entire GSQL script or query that is currently open in the GSQL Editor. When you click the Run All button, it triggers all the GSQL statements in the script from top to bottom.

      This is useful when you want to run the entire GSQL script or when you have multiple queries in the script that need to be run together.

      • Shortcut: You can also use the shortcut to RUN All: Command + Enter/ Control + Enter.

    • Run Selected: The Run Selected option allows you to run only a specific portion of the GSQL query. To use this option, you need to select the desired portion of the GSQL code within the GSQL Query Editor. Once you’ve made the selection, clicking the Run Selected button will run only the selected portion of the code.

      This is helpful when you want to run a specific query or a subset of queries within a larger script.

      • Shortcut: You can also use the shortcut to Run Selected: Command + Shift + Enter/ Control + Shift + Enter

Share GSQL Files

You can share GSQL files with your colleagues, enabling seamless collaboration on query development and analysis.

Collaboration is essential for efficient graph analysis.

This promotes knowledge sharing, accelerates development, and ensures consistency in query execution across the team.

You can select the Share button from the file menu.

Screenshot 2024 04 18 at 10.14.24 AM

You can only share a GSQL file if you are the file owner.

Screenshot 2024 04 18 at 10.14.54 AM

In TigerGraph Cloud, GSQL files have Viewer and Editor permissions that can be assigned to individual users or shared with the entire organization.

Screenshot 2024 04 18 at 10.15.25 AM
  • Viewer Permission: The Viewer permission allows users to view the content of a GSQL file. Users with Viewer permission can open the file in the GSQL Editor, read the GSQL code, and review the query logic, and run the GSQL file. However, they cannot make any changes or modifications to the file.

    Viewer permission is suitable for users who need to review and understand the GSQL code but do not require editing capabilities.

  • Editor Permission: The Editor permission grants users the ability to view and edit the content of a GSQL file. Users with Editor permission can open the file in the GSQL Editor, make changes to the GSQL code, and save those modifications. They have full control over the file and can update query logic, add new queries, or remove existing ones.

    Editor permission is typically given to users who need to actively modify and maintain the GSQL code.

When assigning permissions to GSQL files, you can specify individual users within your organization or share the file with the entire organization. This allows you to control access and collaborate effectively. By assigning Viewer or Editor permissions to specific users, you can ensure that only authorized individuals can view or edit the GSQL files.

Sharing with the entire organization can be useful when you want to provide broad access to GSQL files for collaboration and knowledge sharing within your organization.

Next Steps

Next, learn to Explore Graph.

Or return to the Overview page for a different topic.