Skip to content
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

not working on nested objects ? #1

Open
spiff-radio opened this issue Jul 13, 2023 · 4 comments
Open

not working on nested objects ? #1

spiff-radio opened this issue Jul 13, 2023 · 4 comments

Comments

@spiff-radio
Copy link

Hi, thanks for your code, but it seems it does not work on nested object.

raw :

{"id":12,"attributes":{"title":"Sometimes happy","description":null,"private":true,"synced":false,"wp_id":104,"wp_status":"private","track_count":51,"createdAt":"2019-11-21T18:15:11.000Z","updatedAt":"2023-06-19T08:07:09.741Z","publishedAt":"2019-11-21T18:15:11.000Z","thumbnail":{"data":{"id":86,"attributes":{"url":"https://test.com/public/uploads/20190904_180714_cc0513641e.jpg"}}},"author":{"data":{"id":1,"attributes":{"username":"jordan"}}},"tags":{"data":[]},"favoriters":{"data":[]}}}

flattenEntity():
{"title":"Sometimes happy","description":null,"private":true,"synced":false,"wp_id":104,"wp_status":"private","track_count":51,"createdAt":"2019-11-21T18:15:11.000Z","updatedAt":"2023-06-19T08:07:09.741Z","publishedAt":"2019-11-21T18:15:11.000Z","thumbnail":{"data":{"id":86,"attributes":{"url":"https://test.com/public/uploads/20190904_180714_cc0513641e.jpg"}}},"author":{"data":{"id":1,"attributes":{"username":"jordan"}}},"tags":{"data":[]},"favoriters":{"data":[]},"id":12}

@spiff-radio
Copy link
Author

@ciekawy
Copy link
Owner

ciekawy commented Jul 13, 2023

thanks for the comment! from the brief look - does the input you tried come from strapi graphql endpoint? my code relies on presence of __typename in the strapi structure and expects the flattenable objects to have __typename ending with EntityResponse or ResponseCollection

@rikkit
Copy link

rikkit commented Aug 23, 2023

Not sure if it's the same issue but also I'm finding TS is not unwrapping nested objects. In this case page.meta.image is also an entity with data prop.

image

I can pass this to flattenEntity again but expected that it would all be done in one go. Maybe it's just the type definitiion that's off - haven't been able to run the code yet as I'm mid migration

@ciekawy
Copy link
Owner

ciekawy commented Aug 24, 2023

I think paging is not supported (yet). I see there is data.pages and currently the library expect data to be either an array or single object with just id and attributes

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

3 participants