-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow embedding to rely on an interface #138
Comments
As an example of the latter use-case, and "external resource" could be a resource (e.g. "users") that should be fetched from a different REST-API that we have somehow managed to wrap into a query.Resource compatible type. |
Sounds like a good idea. |
There is one challenge I don't know how to solve (with or without this change) and that is how to support embedding if a "x": {
Validator: &schema.Dict{
ValuesValidator: &schema.Reference{},
},
},
"y": {
Validator: &schema.Array{
ValuesValidator: &schema.Reference{},
},
}, Today I believe it only works for subschemas via the
With regards to #77 that's probably not the best way to deal with this. Maybe another interface to inform about children? type NestedType interface {
Children() schema.Fields
} Sub-schemas (i.e. schema.Object) would simply returns it's Fields instance, where as Arrays and Dicts would use a wildchar "*" maybe. For types without Fields (e.g. schema.Dict and schema.Array), a field could be created ad-hock, or the validators could actually change to replace the This would make the REST embedding syntax for nested "arbitrary fields" function like this:
What about GraphQL? |
Should probably deprecate
|
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
andschema.Connection
implement an interface each that let's you lookup the linked resource. E.g.An alternate (and faster) implementation would be to return the
Path
instead of thequery.Resource
, but that might be less flexible, e.g. if we wanted to support exotic use-cases such as "external resources".The text was updated successfully, but these errors were encountered: