Skip to content
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

Menus API (support query, dashboard and sub-menus) #3981

Merged
merged 2 commits into from
Nov 22, 2023
Merged

Conversation

IvanIvanoff
Copy link
Member

@IvanIvanoff IvanIvanoff commented Nov 14, 2023

Changes

Create a new menu

mutation{
  createMenu(name: "MyMenu", description: "MyDescription")
}
Response
{
  "data": {
    "createMenu": {
      "description": "MyDescription",
      "entityId": 35,
      "menuItemId": null,
      "menuItems": [],
      "name": "MyMenu",
      "entityType": "menu"
    }
  }
}

Update a menu

mutation{
  updateMenu(id: 35, name: "NewName", description: "NewDescription")
}
Response
{
  "data": {
    "updateMenu": {
      "description": "NewDescription",
      "entityId": 35,
      "menuItemId": null,
      "menuItems": [],
      "name": "NewName",
      "entityType": "menu"
    }
  }
}

Delete a menu

mutation{
  deleteMenu(id: 35)
}
Response
{
  "data": {
    "deleteMenu": {
      "description": "NewDescription",
      "entityId": 35,
      "menuItemId": null,
      "menuItems": [],
      "name": "NewName",
      "entityType": "menu"
    }
  }
}

Create an entity that we'll add as a menu item. In this case, a query.

mutation{
  createSqlQuery(name: "MyQuery" sqlQueryText: "SELECT now()" sqlQueryParameters:"{}"){
    id
  }
}
Response
{
  "data": {
    "createSqlQuery": {
      "id": 97
    }
  }
}

Add a new menu item (poitning to an existing entity!) to the menu we created earlier.

mutation{
  createMenuItem(parentId: 35 entity: {queryId: 97} position: 1)
}
Response
{
  "data": {
    "createMenuItem": {
      "description": "MyDescription",
      "entityId": 35,
      "menuItemId": null,
      "menuItems": [
        {
          "description": null,
          "entityId": 97,
          "menuItemId": 52,
          "name": "MyQuery",
          "position": 1,
          "entityType": "query"
        }
      ],
      "name": "MyMenu",
      "entityType": "menu"
    }
  }
}

Update a menu item. The position can be updated to provide re-ordering capabilities.
The parentId can also be updated

mutation{
  updateMenuItem(id: 53 position: 2 parentId: 34)
}
Response
{
  "data": {
    "updateMenuItem": {
      "description": null,
      "entityId": 34,
      "menuItemId": null,
      "menuItems": [
        {
          "description": null,
          "entityId": 97,
          "menuItemId": 53,
          "name": "MyQuery",
          "position": 2,
          "entityType": "query"
        }
      ],
      "name": "MyMeny",
      "entityType": "menu"
    }
  }
}

Delete a menu item.

mutation{
  deleteMenuItem(id: 53)
}
Response
{
  "data": {
    "deleteMenuItem": {
      "description": null,
      "entityId": 34,
      "menuItemId": null,
      "menuItems": [],
      "name": "MyMeny",
      "entityType": "menu"
    }
  }
}

Ticket

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have tried to find clearer solution before commenting hard-to-understand parts of code
  • I have added tests that prove my fix is effective or that my feature works

@IvanIvanoff IvanIvanoff changed the title Queries menu Menus API (support query, dashboard and sub-menus) Nov 15, 2023
@IvanIvanoff IvanIvanoff force-pushed the queries-menu branch 4 times, most recently from bfb9c9e to 0a468e8 Compare November 22, 2023 13:00
@IvanIvanoff IvanIvanoff force-pushed the queries-menu branch 2 times, most recently from e5f2a10 to 3fb1d26 Compare November 22, 2023 15:55
@IvanIvanoff IvanIvanoff merged commit 14ce617 into master Nov 22, 2023
1 check passed
@delete-merged-branch delete-merged-branch bot deleted the queries-menu branch November 22, 2023 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant