Comments (10)
@dabit3 i am right here?
from graphql-recipes.
Have you found a way to do so?
from graphql-recipes.
@patrianova
I guess there is no out of the box way for this.
likes: [PostLike] @connection(keyName: "postLikesByPostId", fields: ["id"])
this is a bad idea. if there are more likes than 1MB Data, than you can't count here the likes, and you don't know if your user has liked this post.
So you could use a table for likesCount. Every time a user likes a post, you can count up in this table for this post.
And for the "Show if user liked it already" problem, you could save a document in a table with:
user_id+post_id as id.
every post has to check than if there is a entry with this id.
else you could use elasticSearch for this. But this is a more expansive and self scaling way.
Any idea else?
from graphql-recipes.
@davidbiller reading a bit more, I believe you could use resolvers to do this. Pipeline resolvers seems to be an option where upon a request to posts you could then rapidly search if that particular post is liked by the user requesting and create a field on the document on the fly indicating it.
You'd keep the PostLike relationship and that's where you execute your mutation (create a record) and on the queries to fetch the result you implement the custom resolver.
This said, I haven't done anything related to this yet and it would be great to have @dabit3 giving us some direction if possible.
from graphql-recipes.
@davidbiller reading a bit more, I believe you could use resolvers to do this. Pipeline resolvers seems to be an option where upon a request to posts you could then rapidly search if that particular post is liked by the user requesting and create a field on the document on the fly indicating it.
You'd keep the PostLike relationship and that's where you execute your mutation (create a record) and on the queries to fetch the result you implement the custom resolver.
This said, I haven't done anything related to this yet and it would be great to have @dabit3 giving us some direction if possible.
But how would you search? as a scan? this takes to long in dynamoDB if there are 100k entries. When the user scrolls through the images.
from graphql-recipes.
you wouldn't do this per post but rather on the query that returns them.
if you get the first 100 posts on a query, on the resolver of this query is where you'd iterate through the 100 posts and search if it has been liked or not.
see below
https://docs.aws.amazon.com/appsync/latest/devguide/pipeline-resolvers.html
from graphql-recipes.
you wouldn't do this per post but rather on the query that returns them.
if you get the first 100 posts on a query, on the resolver of this query is where you'd iterate through the 100 posts and search if it has been liked or not.
see below
https://docs.aws.amazon.com/appsync/latest/devguide/pipeline-resolvers.html
But the pipeline resolver is using the scan operator of dynamodb?
from graphql-recipes.
@davidbiller I'm not quite there yet :) but I'm assuming you could run two graphql queries on the resolver and merge them programmatically. I'll do some reading and let you know what I find out. If you do find an answer, please share here.
from graphql-recipes.
@davidbiller I'm not quite there yet :) but I'm assuming you could run two graphql queries on the resolver and merge them programmatically. I'll do some reading and let you know what I find out. If you do find an answer, please share here.
Ja, this is the problem here, you only can search in dynamoDB with a index key or with scans. And scans are expansive and it takes to long.
from graphql-recipes.
@dabit3 any soultion ?
from graphql-recipes.
Related Issues (4)
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 graphql-recipes.