Skip to content

Allow embedding to rely on an interface #138

@smyrman

Description

@smyrman

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".

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions