Comments (7)
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.
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.
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.
@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.
@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.
@dmitry Absolutely!
from plugin-graphql.
Moved to #95
from plugin-graphql.
Related Issues (20)
- Forcing upcase on model name in buildQuery overwites value set by adapter
- Error: No such model HOT 1
- Need to change the "typings" path to "dist/index.d.ts" HOT 2
- morphToMany not return related models HOT 2
- Custom query not working returning Couldn't find Type of name UserInput in the GraphQL Schema. HOT 3
- Where to get type definitions for 'fetch' in TypeScript?
- v1.0.0-rc.42 not published to NPM? HOT 1
- Trouble with fetch() in Nuxt app HOT 1
- How to handle models that have multiple words? HOT 2
- Better documentation about how to $persist() a record with Many-to-many relationships
- getInputTypeName() seems to be ignored HOT 1
- GraphQL Upload support
- persist ID as string shows NaN HOT 2
- toPrimaryKey broke ObjectId from MongoDB HOT 1
- BUG: .$push does not add variables to variable definitions on mutation HOT 1
- method .all() not returns pure literal object from database (store)
- "Connection mode" doc page unclear
- Type errors HOT 1
- State of Vue 3 support? HOT 1
- Slack invite link is dead HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugin-graphql.