GithubHelp home page GithubHelp logo

Comments (7)

phortx avatar phortx commented on May 17, 2024 1

I could imagine, that the fetch() method accepts a include param with a list of relationships to eager load for that request. Could be useful.

from plugin-graphql.

oligus avatar oligus commented on May 17, 2024

Also consider relations och relations.

For instance, MusicUsageAreasModel -> hasMany(PriceListsModel) -> hasMany(PricePriceRowsModel)

You might want to to eager loadpriceRows or perhaps not.

await MusicUsageAreasModel.fetch({ include: priceLists, priceLists.priceRows] })

from plugin-graphql.

gotexis avatar gotexis commented on May 17, 2024

How to combine queries to API?

Let's say we have Posts, Authors, and Comments.

Currently I have to do 3 queries:

Posts.fetch()
Comments.fetch()
Users.fetch()

Of course that is not optimal.

Plus when I bind fetch() to created(), every time I re-navigate to the page, the server is queried 4 times, once again.

I imagine I have to write a judgment to check if the store has already been populated before calling the query.

https://vuex-orm.github.io/plugin-graphql/guide/fetch.html#caching

Yet, because I read that the package caches the queries, I wonder if there is a built-in way of doing this.

from plugin-graphql.

phortx avatar phortx commented on May 17, 2024

@gotexis you can use eager loading to achieve that. See the docs. This way you could just fetch the Post and all related records are fetched within one query.

https://vuex-orm.github.io/plugin-graphql/guide/eager-loading.html

from plugin-graphql.

dmitry avatar dmitry commented on May 17, 2024

@phortx that's done on the model level, not on the query level (via fetch method). Would be great to control it more finely, on the fetch level.

from plugin-graphql.

phortx avatar phortx commented on May 17, 2024

@dmitry Absolutely!

from plugin-graphql.

phortx avatar phortx commented on May 17, 2024

Moved to #95

from plugin-graphql.

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.