Skip to content

Array of references #222

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

Closed
Dragomir-Ivanov opened this issue Dec 31, 2018 · 6 comments
Closed

Array of references #222

Dragomir-Ivanov opened this issue Dec 31, 2018 · 6 comments

Comments

@Dragomir-Ivanov
Copy link
Contributor

Hi @smyrman ,
I saw about #100, however the API has changed since then, how this is supposed to be configured:

			"applianceIds": {
				Validator: &schema.Array{
					Values: schema.Field{Validator: &schema.Reference{Path: "appliances"}},
				},
			},

Thanks.

@smyrman
Copy link
Collaborator

smyrman commented Dec 31, 2018

I believe that will just work for the validation part, but hooks won't get passed the right context as described in #192, and field embedding probably won't work; that wasn't solved by #100. Field embedding still rely on a hardcoded type check somewhere.

@Dragomir-Ivanov
Copy link
Contributor Author

Dragomir-Ivanov commented Dec 31, 2018

Thanks Sindre. However I need field embedding part. It seems that this case is the only one missing from rest-layer. I am willing to work on this.
Do you have anything in mind? Maybe I can try hard-code schema.Reference in schema.Array in evalProjection function?

@smyrman
Copy link
Collaborator

smyrman commented Jan 1, 2019

What we have done for similar cases when embedding is needed, is too implement it as a field handler parameter, e.g. expand=1 (one level), expand=2 (two levels).

For fixing it properly, some sort of interface is needed that the code doing the embedding can use.

@Dragomir-Ivanov
Copy link
Contributor Author

It would be good if mainline rest-layer supports such expand query parameter. However often times not full expansion is needed, but only handful of fields.
Once I implement ( which may not be that soon ) the * field, then we can have rather flexible query language with optional expansion. Say

?fields=*,posts{*,user{*}}

Where posts and user are references.

@Dragomir-Ivanov
Copy link
Contributor Author

In the mean time, I will try to add another parameter to schema.Reference, Array: true as a POC, and see where it goes.
BTW, Happy New Year @smyrman ! Wish you much success in the 2019 year.

@Dragomir-Ivanov
Copy link
Contributor Author

Dragomir-Ivanov commented Jan 1, 2019

I think I nailed #222 and #223, but it conflicts with yet not merged #215.
No additional parameter for schema.Reference need. It is auto detected from the payload.

Dragomir-Ivanov added a commit to Dragomir-Ivanov/rest-layer that referenced this issue Jan 2, 2019
Dragomir-Ivanov added a commit to Dragomir-Ivanov/rest-layer that referenced this issue Jan 2, 2019
Dragomir-Ivanov added a commit to Dragomir-Ivanov/rest-layer that referenced this issue Jan 3, 2019
@smyrman smyrman closed this as completed in 8bd1218 Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants