amplify push gives error "Unknown type" when using union or interface in schema - amplify-cli

Describe the bug I defined a schema with a query that returns a type that contains an array of a union object. (see sample below). Everything works when testing locally, no errors. When I run amplify push, everything seems just fine, I get a few minutes of messages about updating things, until the very end, and then:

Unknown type EnrollmentStats for field items. Did you forget to add the @model directive
An error occurred during the push operation: Unknown type EnrollmentStats for field items. Did you forget to add the @model directive

The funny thing is, it does update the stack... I've tried using an interface instead of a union, and the same thing happens.

Amplify CLI Version 4.38.2

To Reproduce some of my schema

type Query {
    filter: ModelEnrollmentStatsFilterInput!
  ): ModelEnrollmentStatsConnection @function(name: "myfunction")

type ModelEnrollmentStatsConnection {
  items: [EnrollmentStats]

union EnrollmentStats =
  | LocationEnrollmentStats

Expected behavior If it works, it shouldn't give me an error message, it's very disconcerting. I'm worried that something failed to update that I don't know about yet.

Asked Oct 04 '21 00:10
avatar estyh

2 Answer:

Hi closing this as a dupe and a feature request for the GraphQL transformer v2.

Answered Feb 05 '21 at 00:02
avatar  of renebrandel

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

Answered May 25 '21 at 05:15
avatar  of github-actions[bot]