Views, materialized views, and foreign tables can be exposed with pg_graphql.
Primary Keys (Required)
A primary key is required for an entity to be reflected in the GraphQL schema. Tables can define primary keys with SQL DDL, but primary keys are not available for views, materialized views, or foreign tables. For those entities, you can set a "fake" primary key with a comment directive.
tells pg_graphql to treat "Person".id as the primary key for the Person entity resulting in the following GraphQL type:
12345
typePerson{
nodeId: ID!
id: Int!
name: String!}
Warning
Values of the primary key column/s must be unique within the table. If they are not unique, you will experience inconsistent behavior with ID! types, sorting, and pagination.
Updatable views are reflected in the Query and Mutation types identically to tables. Non-updatable views are read-only and accessible via the Query type only.
Relationships
pg_graphql identifies relationships among entities by inspecting foreign keys. Views, materialized views, and foreign tables do not support foreign keys. For this reason, relationships can also be defined in comment directive using the structure: