-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API] Subscribe with arguments (real time filtering) #580
Comments
We could add a filtering argument to public static <M extends Model> GraphQLRequest<M> onUpdate(
Class<M> modelType, QueryPredicate filter) {
...
} Is this what you have in mind? This would constrain the set of results returned over the network, by means of a GraphQL predicate. Since we don't have that, for the time-being, you could do the filtering on the client. I recommend using the Rx Bindings for this. RxAmplify.API.subscribe(onUpdate(MyData::class.java))
.filter { post -> !post.hasErrors() && post.hasData() }
.map { post -> post.data }
.filter { data -> data.x == "5" }
.subscribe(
{ Log.i("Demo", "Found a match: $it") },
{ Log.i("Demo", "No matches.", it) }
) |
A I guess it would be better to have an option to pass the complete string, maybe like this -
|
@chiragmittal19 Thanks for the feedback! We prioritize work based on the number of reactions an issue receives. I'll close this issue for now, but let's leave it as a feature request. If you are reading this and would like to see this feature implemented, please add a 👍 here: #580 (comment) |
Yes would like this feature. Very helpful to reduce network traffic |
I also want this feature. Maybe this feature makes more secure in addition to moderating network traffic. |
For anyone who finds themselves here... AppSync has a feature that MIGHT help you like it helped me https://docs.aws.amazon.com/appsync/latest/devguide/extensions.html
It allows you to add additional filters on the server side |
@jamesonwilliams Any update on the feature Request? |
Hey, @vibhorkhurana580 - sorry, I haven't worked on this project in a number of years. Overall I'd encourage folks to migrate to Apollo Kotlin, which also supports AppSync's flavor of WebSockets if you're stuck on that backend for now. |
There should be a way to pass arguments to subscriptions so that only a subset is subscribed.
Model schema -
Subscription method
onUpdateMyData
which take an input parameterx
-Mutation method
updateMyData
-Following the official documentation, I wrote the below code for subscription. Works as expected, i.e, gets triggered whenever the
updateMyData
mutation is called, irrespective of the value of x.But the problem is, I only want to subscribe for a specific value of x, say 5.
So, I tried by modifying the request -
This made no difference. I'm still receiving updates for other values of x.
This is how I call
updateMyData
mutation from AppSync console -Subscription in AppSync console works like a charm, i.e, it gets triggered only for a subset where
x = 5
-Just to mention, DynamoDB is used as the data source.
The text was updated successfully, but these errors were encountered: