Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Allow single resource arbitrary queries to get passed as props #69

Open
joshlevinson opened this issue Sep 21, 2017 · 2 comments
Open

Comments

@joshlevinson
Copy link

joshlevinson commented Sep 21, 2017

When making an arbitrary query with connectWpQuery, resources end up getting stored on props.kasia.data, even if only one resource was fetched.
It'd be nice if there was a concise way to translate an arbitrary query to a single resource and have that resource get passed as a prop, instead of having to filter through data to find the originally requested resource.
Right now, I'm thinking about overloading KasiaConnectWpQueryComponent::_makePropsData to be closer to the same method of KasiaConnectWpPostComponent. Is that something of enough utility that it should be considered for this library?

@sdgluck
Copy link
Contributor

sdgluck commented Sep 24, 2017

Hey Josh- that sounds useful. It's definitely a pain point having to trudge through the props for a single entity when using connectWpQuery.

The approach seems good. Did you have something in mind API wise? In 4.2 we have the options object available to us when using connectWpQuery - we could do something like single=true.

Or were you thinking that recognising a request which returned a single entity would be performed automatically? My only worry with this is that it could be confusing for someone who hasn't thoroughly read the documentation (the result not being on props.data).

@joshlevinson
Copy link
Author

@sdgluck Something like the former is what I had in mind–I agree that doing it silently would easily lead to confusion/a potential source of bugs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants