-
Notifications
You must be signed in to change notification settings - Fork 112
Description
Today embedding is done by checking if a schema.FieldValidator (or fallback validator stored within a resource's index) type asserts to &schema.Resource or &schema.Connection. This makes it hard to write custom reference Validators and have them work just as well as the default ones. This could sometimes be useful when you have very application specific validation requirements for linked resources.
One solution to this, cold be to let schema.Resource and schema.Connection implement an interface each that let's you lookup the linked resource. E.g.
type ReferenceType interface {
LinkedResource() query.Resource
}
type ConnectionType interface {
LinkedResource() (field string, query.Resource)
}An alternate (and faster) implementation would be to return the Path instead of the query.Resource, but that might be less flexible, e.g. if we wanted to support exotic use-cases such as "external resources".