From 397ff0bd220c14c674ddae8ae7f0e13313ecd3c9 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Mon, 16 Sep 2024 04:17:30 -0400 Subject: [PATCH] feat(schema): add ReferenceType interface (#21692) Co-authored-by: cool-developer <51834436+cool-develope@users.noreply.github.com> --- schema/enum.go | 3 ++- schema/type.go | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/schema/enum.go b/schema/enum.go index 4783ccff6f..b52b01e1a5 100644 --- a/schema/enum.go +++ b/schema/enum.go @@ -41,7 +41,8 @@ func (e EnumType) TypeName() string { return e.Name } -func (EnumType) isType() {} +func (EnumType) isType() {} +func (EnumType) isReferenceType() {} // Validate validates the enum definition. func (e EnumType) Validate(TypeSet) error { diff --git a/schema/type.go b/schema/type.go index 9728675cd8..a1205ad722 100644 --- a/schema/type.go +++ b/schema/type.go @@ -13,6 +13,15 @@ type Type interface { isType() } +// ReferenceType is a marker interface that all types that can be the target of Field.ReferencedType implement. +// Currently, this is only EnumType. +type ReferenceType interface { + Type + + // IsReferenceType is implemented if this is a reference type. + isReferenceType() +} + // TypeSet represents something that has types and allows them to be looked up by name. // Currently, the only implementation is ModuleSchema. type TypeSet interface {