Skip to content

insights: add mutation for creating a dashboard

Administrator requested to merge insights/api/create-dashboard into main

Created by: CristinaBirkel

Closes #22818

Description

This adds a mutation to create a dashboard.

Also:

  • I added a temporary column to the dashboard table called save that, if true, persists this dashboard when the settings migration script clears out the rest. This is automatically applied to dashboards created via the API.
  • Made a few more naming consistency edits InsightDashboard -> InsightsDashboard

Testing Steps

You can create a dashboard locally via the API with a query like this. You can replace the ids in the grants with whatever you have locally.

mutation {
  createInsightsDashboard(input: {
    title: "New dashboard created through the API!!"
    grants: {
      users: ["VXNlcjox"],
      organizations: ["T3JnOjE="],
      global: true
    }
  })
  {
    dashboard {
      id
    }
  }
}

Then you can check that it shows up in the database, and/or query for it to confirm that it's been created. You'll have to check the database to see that the grants are there.

query insightsDashboards {
	insightsDashboards(first: 10) {
		nodes {
			id, title
    }
  }
}

After you've created a dashboard, restart the service to make sure it's still there after the settings migration job is run.

Merge request reports

Loading