Closed
Description
Description
If a type has a property of an interface (InterfaceTypeDefinition), the Zod (have not tried others) schema generation will fail.
interface Animal {
}
type Dog implements Animal {
}
type Cat implements Animal {
}
type Something {
animal: Animal
}
Workaround
The current workaround is adding the interface as a scalar
scalarSchemas:
Animal: z.unknown()
Another workaround is modifying the GQL schema (not preferred):
- Animal being a superclass
- Using unions of all the Animal types instead.
Suggestion
Same logic as ZodSchemaVisitor.ObjectTypeDefinition
but remove the addition of __typename (since an interface has no typename)
Metadata
Metadata
Assignees
Labels
No labels