Graphql-engine: Relay: Views are not exposed

Created on 10 Jun 2020  路  5Comments  路  Source: hasura/graphql-engine

Hey,

Not sure if this is a bug or just a not-yet-implemented feature.
I have a view called accounts_view, a view over accounts with some extra rich data joined in.
In the regular Hasura GraphQL endpoint, you can see that both are exposed:

image

However, in the Relay GraphQL endpoint, this view is missing:
image


This extends not just to root queries, but also when joining from objects.
Here's the Hasura endpoint:
image

And from Relay:
image

relay server easy

Most helpful comment

What about having a convention id being the primary key outputted from the view, or allowing the programmer to select a column to use as a primary key from the view?

All 5 comments

@Winwardo Current implementation of relay exposes only tables and relationships (whose tables) have primary key defined. So technically, views don't have a primary key. Hence views are not exposed in Relay schema. We need a primary key to identify a row of any table via the Node interface since primary key column values don't conflict. Given that, we can support views without view object type not implementing Node interface.

Our team needs the Relay API for cursor pagination, and we also need views as a workaround since we can't order by computed fields (see #4356). So until views get Relay support or until we can order by computed fields, we can't serve our home feed.

What about having a convention id being the primary key outputted from the view, or allowing the programmer to select a column to use as a primary key from the view?

This is a bit unfortunate, this render a lot of cases impossibles. 馃様 For example it is not possible to uses views to create different reading permissions rules on a similar dataset. The "_multiple column + row permission rules for the same role_" as described in the doc.

Are there any official plans to implement this feature?

Was this page helpful?
0 / 5 - 0 ratings