0

getting below error during amplify publish . Unknown type FieldUnion for field fields. Did you forget to add the @model directive the code:

FieldUnion = KeyValueField | AnotherFieldType

type MyObject {
  id: ID!
  fields: [FieldUnion !]
}
interface Field { its definition here}

type KeyValueField  implements Field {
  name: String!
  value: String
}

type AnotherFieldType implements Field {
  label: String!
  content: String!
}

There is a single schema.grapghql file . All Resolvers return __typename with some concrete type of union. This union is never used as input in any mutation. amplify cli version was upgraded to 12.14.4 after which this started coming . we dont use @model anywhere . We have AppSync setup that uses Lambda resolvers and no DynamoDB used behind. Lambda talks to DB.

1 Answer 1

0

Can you try basic graphql schema like below

issue can be at The union FieldUnion = KeyValueField | AnotherFieldType which likely must come after the types it references

interface Field {
  # Add your field definition here
}

type KeyValueField implements Field {
  name: String!
  value: String
}

type AnotherFieldType implements Field {
  label: String!
  content: String!
}

union FieldUnion = KeyValueField | AnotherFieldType

type MyObject {
  id: ID!
  fields: [FieldUnion!]
}

This will be resolves the "Unknown type FieldUnion" error and it will check for ensuring proper GraphQL type definition order that Amplify CLI this now strictly checks the syntax

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.