-
Notifications
You must be signed in to change notification settings - Fork 200
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
query not supported through the realtime channel #3885
Comments
@ChurikiTenna Thanks for submitting the issue, we'll take a look and provide updates here. |
Hi @ChurikiTenna , The let onUpdateSubscription = Amplify.Publisher.create(Amplify.API.subscribe(
request: .subscription(to: Post.self, subscriptionType: .onUpdate)
))
let cancellable = onUpdateSubscription.filter {
if case let .data(.success(result)) = $0 {
result.model.identifier == "specific-id"
} else {
false
}
}.sink { complete in
// on subscription end
} receiveValue: { onUpdateEvent in
// your logic
} |
Hi @5d ! Thank you for the suggestion. |
Hi @ChurikiTenna ,
It will listen to all authorized Post.self updates. If that's a concern, there's another approach you can try, building a custom GraphQL query. In your case, it might look something like this: let updateOnSpecificPostIdRequest = GraphQLRequest(
document: """
subscription OnSpecificPostIdUpdated {
onUpdatePost(filter: { id: { eq: "\(postId)" } }) {
id
otherFiled0
otherFiled1
...
}
}
""",
responseType: JSONValue.self
)
let subscription = Amplify.API.subscribe(request: updateOnSpecificPostIdRequest) We recommend thoroughly reviewing the AWS AppSync documentation before attempting to write your own custom queries. |
Thank you @5d ! |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
This is not a bug. I think I am misusing the Amplify.API.subscribe.
I want to get UserData with specific id when it's updated.
I tried to use Amplify.API.subscribe like this:
let subscription = Amplify.API.subscribe(request: .list(UserData.self, where: UserData.keys.id.eq(userId)))
But it fails with error:
Do I need to define something first, or is such functionality not available?
Steps To Reproduce
Expected behavior
Get UserData.self with specific id when updated.
Amplify Framework Version
2.39.0
Amplify Categories
API
Dependency manager
Swift PM
Swift version
latest
CLI version
12.12.6
Xcode version
15.4
Relevant log output
Is this a regression?
Yes
Regression additional context
No response
Platforms
iOS
OS Version
iOS 18.1
Device
iPhone 15
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: