Open katsanva opened 3 years ago
I don't really understand the question. What do you mean by personalized content, and how you model it?
@mcollina lets say its something like news feed. the subscription query will look like (pseudocode)
subscription news {
title
img
preview
}
with no variables.
When the anonymous user makes that query he will get some default stream of events But when the logged-in user subscribes he need to get not the default stream, but more relevant news, that he is interested in.
Does that sound better?
But currently, they will obtain the same default stream due to the implementation.
Hi @katsanva, regarding the user authentication, mercurius exposes two options: subscription.onConnect
or subscription.verifyClient
, with these options you can authenticate/identify the request and extend the subscription context with any useful information related to the current user (like a decoded JWT token). Your resolver implementation can then change its behavior depending on the context.
@PacoDu thank you. I know how to auth the user. The issue is that subscription-client ignores on the second call is the user authenticated or not.
Can you please make an example to reproduce your code with a failing test?
Hello. I've been using the
mercurius
for some time and got a question on how to resolve the personalized subscriptions?The part that handles this is located here.
Use case 1:
Users should obtain personalized content by making the subscription query.
This is not working as far
operationId
is resolved by the query & params only.Is it a good way to add the
connectionInit
when resolving theoperationId
?Use case 2:
Non-logged in user creates a subscription and get's non-personalized content. Then the user performs a query to log in, while the subscription is still active. Since that user should get the personalized content from the existing subscription.
Is this intended to be resolved on the
mercurius
side or is that application-specific?