Coder Social home page Coder Social logo

Comments (5)

lindyhopchris avatar lindyhopchris commented on July 20, 2024 2

Hi @tylergets

I've looked into this and it's going to involve some interface changes. As I'm probably going to have to make interface changes when I sort out all the relationships stuff (see #60) I'll include it in that change.

I'm going to do a release of the 1.0 changes I've already made on #60, then will probably move on to the relationship stuff next.

from laravel-json-api.

lindyhopchris avatar lindyhopchris commented on July 20, 2024

Hi. The with is only called on index calls at the moment. I can change this but wasn't sure what the point of calling it on a read call is? Because N+1 would only occur if you are loading multiple Auction objects, which you wouldn't on a read request (because it is for a single record).

Unless I'm missing something?! Happy to discuss as if there's a good reason it's needed for the with request this can be added.

from laravel-json-api.

tylergets avatar tylergets commented on July 20, 2024

@lindyhopchris In my case, I am including the nested relationships "items,items.bids,items.bids.bidder"

I need to eager load the Bidder object which is N+1ed on a read. Unless I am looking at this wrong?

from laravel-json-api.

lindyhopchris avatar lindyhopchris commented on July 20, 2024

ah, ok that makes sense - couldn't see that in your adapter's with method.

it makes sense for the change to be implemented. I'll take a look at what it involves - I suspect I'd need to include it in the next release because it'll be breaking (I'll have to modify the AdapterInterface so that the find method receives the encoding parameters from the client).

from laravel-json-api.

lindyhopchris avatar lindyhopchris commented on July 20, 2024

This change is now included on the develop (1.0) branch.

The Eloquent adapter now converts JSON API include paths into Eloquent relationship paths for eager loading e.g. comments.created-by is converted to comments.createdBy for eager loading. If you need to map these paths differently, you can specify this using the $includePaths property of your adapter. See https://github.com/cloudcreativity/laravel-json-api/blob/develop/src/Eloquent/Concerns/IncludesModels.php#L18-L47

It also continues to support default paths for eager loading on the $defaultWith property.

In addition, eager loading is now also supported when reading and updating specific resources.

from laravel-json-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.