A couple suggestions...
Create some transformation logic that flattens the data in memory, i.e. in the Typescript of your application, use as
type assertion. https://www.typescriptlang.org/docs/handbook/interfaces.html.
create a view in Hasura that combines the user
columns and organization_users
columns. So organization_users_view
may be defined as
select user.id as id, users.email as email, organization_users.role as role
from organization_users
join users
on organization_users.user_id = users.id;
So the query then looks like...
export const GET_USERS = gql `
query GetUsers {
organization_users_view {
id
email
role
}
}
`;
Which is closer with less code, but double check you retain the benefits of Apollo cache in hydrating other parts of your application, which heavily depends on id and resource "type". It also requires some overhead of defining and/or modifying the view every time you need more columns (can use, users.* and organization_users.* as needed). A benefit, however, is that this will play nicely with type and component generation... so you don't have to define the interface by hand.