I am trying to design a schema for an application and I have a problem that I can't solve. Here is a detail of the application
User A LIKES User B User B MATCHS User B Now User A and User B can start chatting with each others.
I also keep track of who visited each profile User A VISITED BY User B User A Visited BY User C
In the application, I have Me type with details of the user running the app. I have a me query that looks like this:
me {
id
name
email
...
...
likes { ## users who liked me
nextToken
edges {
node { ## user
id
name
...
}
}
}
matchs { ## users who matched with me
nextToken
edges {
node { ## user
id
name
...
...
}
}
}
Vists { ## users who visited me
nextToken
edges {
node { ##
id
name
...
...
}
}
}
}
In addition to that, I have listUsers query that list users nearby to Me and looks something like this:
listUsers {
nextToken
total
edges {
distance
node { ## user
id
name
...
...
}
}
}
MY QUESTION Since there is a relationship between users (LIKED_BY, MATCHED_WITH) where do I use this relationship in my schema such that it is cashable. Keep in mind the relationship can change at the client from NO_RELATIONSHIP to LIKED_BY to MATCHED_WITH so if the relationship is duplicated in multiple places, this will be a problem.
I would really appreciate any help as I am out of ideas.
Thanks in advance.
You clarified in a comment:
That is, you're trying to ask about some user
The
relationToMe
field can have any number (including zero) of relationship types; you can define those as a GraphQL enumThen in your query you can ask
and get back a response like
You'd need to implement a custom resolver in your implementation to populate this field. If you had something like a many-to-many SQL join table, you could query that to fill in this field, if requested.