Skip to content

insights: add mutation for updating a dashboard

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

Created by: CristinaBirkel

Closes #25652 (closed)

Description

This adds a mutation to update a dashboard. A few things to call out:

  • I chose to keep the updatable dashboard fields nullable. This seems like it would give the client a bit more flexibility in what to send, but I don't have a strong opinion about it. Let me know if we'd prefer requiring those fields.
  • I refactored the create resolver a little by adding a parseDashboardGrants helper function so that I could reuse that logic in the update resolver. The diff is displaying that a bit weird.
  • The title is currently the only piece of the actual dashboard that is updatable, so I passed it in as its own argument into UpdateDashboard. This won't scale if we get more arguments, but I'm not sure we have a plan to add more metadata? And I figure that we can add some DashboardUpdate or DashboardFields object or something if need be, with nullable metadata fields to pass in.
  • I added a scanDashboardGrants function because I needed it for the tests, and it seems like it will come in handy for allowing users to edit dashboard grants, (because we'll need to expose them via the API for that.)

Testing Steps

You can run a query similar to:

mutation {
  updateInsightsDashboard(
    id:"ZGFzaGJvYXJkOnsiSWRUeXBlIjoiY3VzdG9tIiwiQXJnIjoxMjF9"
    input: {
      title: "Updated title!",
      grants: {
	global:true
      }
    }
  )
  {
    dashboard {
      id, title, views {nodes {id}}
    }
  }
}

You can verify the updates in the database. Try out some different combinations of grants/title. Note that if you update the grants and they do not include global:true, you won't see a return value because permissions are not included yet. (I think #25708 (closed) will fix that.)

Merge request reports

Loading