Giter Site home page Giter Site logo

Comments (6)

begedin avatar begedin commented on August 18, 2024

Since the posts endpoint will have pagination, should we just be getting the first page of posts here, somehow? Or maybe we should be getting just posts with status open?

Should the records be included, or just the relationships?

from deprecated-code-corps-rails-api.

joshsmith avatar joshsmith commented on August 18, 2024

@begedin is there a better way to do this on ember side probably? And API endpoint for /projects/:id/posts or something would hit that anyway.

from deprecated-code-corps-rails-api.

begedin avatar begedin commented on August 18, 2024

I'm not sure exactly, but generally speaking, I don't think ember likes using nested routes on it's own.

There's a linking feature defined in JSON API, where you can specify links for related records in the parent record. This link would be an URL to the route that retrieves those related records.

I'm not sure if ember-data already supports this feature. If it does, then a nested route makes sense.

Assuming it doesn't, the default behavior is that it will check the relationships object on the project, figure out there's a posts relationship and then, if those posts aren't in the included object, fetch them using the "GET /posts/" route, using an array of ids as a parameter.

For us this means

  • If ember data supports links, implement that feature on the API side, and expose the nested route
  • If it doesn't, add support for filtering through an array of ids on the GET /posts endpoint
  • Either way, we need to decide how many records, if any, we include with the project record itself.

from deprecated-code-corps-rails-api.

begedin avatar begedin commented on August 18, 2024

@joshsmith The more I think about it, the more sense it makes to me not to include anything except maybe the relationships part (not actual include).

The way I see it, it's easier to fetch posts via GET /posts?filter[project_id]=x&page[number]=y&page[size]=z, which is the standard way of doing it.

In the case of an RSpec get request, this would be equivalent to

get /posts, { filter: { project_id: x }, page: { number: y, size: z } }

Basically, I'm thinking most client apps will have a project page, with either special sections or subpages containing posts in general, or per category. We can add pagination to those subsections, which will then trigger requests to get the first page of posts for that specific project, with controls to switch pages.

In the case of an Ember app, it would be

{!  project details component}
{! basic details go here}
{post-list-component category=task pageSize=20}

The post list component would then fetch the first page of posts and have controls which fetch other pages, based on how we want to implement it.

This way, we don't need to include anything.

from deprecated-code-corps-rails-api.

joshsmith avatar joshsmith commented on August 18, 2024

Does this need to be closed?

from deprecated-code-corps-rails-api.

begedin avatar begedin commented on August 18, 2024

I believe so. Currently, we're fetching posts explicitly, after loading the project. As we discussed, we're avoiding having includes with the project. Relationships are fine, but includes are an issue.

from deprecated-code-corps-rails-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.