When I create a Logical Model, I can create a field and type it with another Logical Model.
If I then try to use my Logical Model as return type of a Native Query, I get an Unexpected Logical Model error.
What is the expected behaviour?
Either (prefered): I should be able to use a Logical Model as described above as return type of a Native Query, without errors.
Or: It should not be able to create a Logical Model and type a field with another Logical Model.
How to reproduce the issue?
Start with an new Hasura instance v2.35.1 connected to a Postgres DB
Connect to the DB with the PG_DATABASE_URL Environment variable
Apply the Many to Many Template from the Template Gallery
Create a Logical Model named child with the fields:
aid: integer
tag_id: integer
title: text
author_name: text
Create a Logical Model named parent with the fields:
id: integer
name: text
children: child (the Logical Model from Step 4)
Create a Native Query with the Native Query Statement:
WITH article_cte AS (
SELECT a.id AS aid, at.tag_id, a.title, a.author_name FROM _manytomany.article AS a
JOIN _manytomany.article_tag AS at ON at.article_id = a.id
)
SELECT
id,
name,
COALESCE(JSON_AGG(DISTINCT article_cte.*) FILTER ( WHERE _manytomany.tag.id IS NOT NULL ), '[]') as children
FROM _manytomany.tag, article_cte
WHERE _manytomany.tag.id = article_cte.tag_id
GROUP BY
_manytomany.tag.id,
_manytomany.tag.name;
Please provide any traces or logs that could help here.
We support LMs inside LMs but not intended for Native Query return types (built for complex data modelling required for MongoDB support).
We have plans to support this soon in Hasura V3.
Version Information
Server Version: v2.35.1
Environment
OSS
What is the current behaviour?
When I create a Logical Model, I can create a field and type it with another Logical Model. If I then try to use my Logical Model as return type of a Native Query, I get an
Unexpected Logical Model
error.What is the expected behaviour?
Either (prefered): I should be able to use a Logical Model as described above as return type of a Native Query, without errors. Or: It should not be able to create a Logical Model and type a field with another Logical Model.
How to reproduce the issue?
Please provide any traces or logs that could help here.
Keywords
Hasura, Native Query, Logical Model, Nested, json_agg