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

Facilitate the retrieval of unprocessed data from the API #4068

Closed
BrokenEagle opened this issue Mar 13, 2019 · 3 comments
Closed

Facilitate the retrieval of unprocessed data from the API #4068

BrokenEagle opened this issue Mar 13, 2019 · 3 comments

Comments

@BrokenEagle
Copy link
Collaborator

Many times the extra processed data added to the API response isn't needed, but processing that data takes extra time. The /post_versions endpoint is especially slow with this, since it seems to do queries for the current post as well as the previous post version record for that post.

Therefore, have a universal URL addon for all of the index endpoints which will return the raw data, minus any sensitive data such as IP addresses and all other hidden attributes.

@r888888888
Copy link
Collaborator

Is there any interest in integrating GraphQL? In addition to solving this problem it would also allow for more intelligent embedding of associated records to eliminate n+1 situations.

@evazion
Copy link
Member

evazion commented Mar 15, 2019

I looked into it before, but full GraphQL support seemed like it would introduce a ton of complexity, plus the Rails support didn't seem very mature. Maybe it's better now.

For most purposes, you just want to be able to include a few extra associations with the response, or to only include certain fields. Something like this would be sufficient:

https://danbooru.donmai.us/pools/123.json?fields=id,description,category
https://danbooru.donmai.us/posts/456.json?include=comments,notes
https://danbooru.donmai.us/tags/789.json?include=artist,wiki_page&fields=tags.*,artist.urls,wiki_page.body

as_json has options that let you do this (docs). So it would mainly be a matter of getting respond_with to pass things down to the as_json call. I think this would be doable with a custom responder (cf https://github.com/plataformatec/responders).

@BrokenEagle
Copy link
Collaborator Author

Would that replace the REST API, or be an addition to it? If it does replace it, would there be backwards compatibility? Otherwise it would break any program relying on it.

It would also be nice to test out the performance characteristics as a comparison to see if the gains achieved make the task worth it. The post versions endpoint should be included in this since it is currently the slowest.

  • Getting everything with REST
  • Getting everything with GraphQL
  • Getting select values with GraphQL

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