We took some architectural decisions while designing the realtime module of Space Cloud to make it performant and scalable. This means that you need to abide by some rules while designing your app for realtime subscriptions.
Following are the rules that you need to follow for realtime subscriptions to work correctly:
liveQuery.For example, the realtime subscriptions on the pokemons table will not work for the following use case because the mutation query does not include the primary field in the where clause:
Schema:
type pokemon {
id: ID! @primary
name: String!
combat_power: Integer!
}Mutation query (for which the subscription won’t work):
mutation {
update_pokemons (where: {name: {_eq: $pokemonName}}, set: {combat_power: 500}) @postgres {
status
error
}
}To fix this mutation, we need to use the unique identity (id field in this case) in the where clause like this:
mutation {
update_pokemons (where: {id: {_eq: $pokemonId}}, set: {combat_power: 500}) @postgres {
status
error
}
}These limitations are only applicable to those tables for which you want the realtime functionality.