0

I have a view that I'm tracking in Hasura. I essentially query one table and left-join additional data from other tables onto it:

CREATE
OR REPLACE VIEW "public"."user_summary" AS
SELECT
  u.id AS user_id,
  u.display_name AS user_display_name,
  s.display_name AS subscription_display_name
FROM
  user u 
    LEFT JOIN subscription s ON (u.id = s.user_id)
        

However, the GraphQL schema that Hasura generates for this view looks like this:

type userSummary {
  user_id: Int
  user_display_name: String
  subscription_display_name: String
}

Specifically, all of the types are optional. It might make sense for subscription_display_name to be missing — I'm using a left join because not all users have subscriptions — but a user ID and display name are always present and don't show up as optional in the types Hasura generates for them.

Is it possible to provide better types to Hasura for this view? Or separately, is there something I'm missing that causes all of these properties to be marked as optional?

Salem
  • 1,122
  • 4
  • 19
  • 30
  • 1
    https://github.com/hasura/graphql-engine/issues/1965 – Bergi Jan 07 '22 at 00:14
  • ah, you hate to see a github issue with the feature you've asked for. Thanks for pointing me in the right direction @Bergi – Salem Jan 12 '22 at 00:29

0 Answers0