Skip to content

Insights: Change the dashboard API grants data shape

Created by: vovakulikov

Background

At the moment the dashboard API grant field has the following shape

grants: {
  users: [id1 ...],
  organizations: [id2, id3 ...],
  global: true
}

This shape brings the fact that you have to carry about different fields if you change the visibility of the dashboard. Putting data in the different fields isn't always as simple as it should be. For different visibility levels, we have different shapes of data, for global, this is boolean for users and orgs this is lists of ids. I think instead of having different fields, it would be much better to have just a list with __typename, id, and title objects instead.

grants {
  nodes {
     ... on User {
        id: ID
        title: String
     }
     ... on Organization {
        id: ID
        title: String
     }
     ... on Account (or Instance) {
        id: ID
     }
  }
}

This unifies the work with dashboard grants on the frontend a lot. And also it gives us the possibility to expose more data about dashboard permissions. At the moment FE wants to know - What is the title of the entity that has the dashboard? Currently, we have only ids in the users, orgs fields. We have to link ids with organizations or users on the FE just to render titles of orgs. Which brings a lot of extra work.

Ideally in the GQL world, everything is nested and you have full access to all data in the query.