Merge pull request #19523 from gustavotrott/middleware-stop-retransmitting-mutations

Prevent graphql-middlware from re-transmitting Mutations
This commit is contained in:
Gustavo Trott 2024-01-25 20:12:52 -03:00 committed by GitHub
commit ecace2f221
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -96,20 +96,23 @@ RangeLoop:
jsonPatchSupported = true
}
browserConnection.ActiveSubscriptionsMutex.Lock()
browserConnection.ActiveSubscriptions[queryId] = common.GraphQlSubscription{
Id: queryId,
Message: fromBrowserMessageAsMap,
OperationName: operationName,
StreamCursorField: streamCursorField,
StreamCursorVariableName: streamCursorVariableName,
StreamCursorCurrValue: streamCursorInitialValue,
LastSeenOnHasuraConnetion: hc.Id,
JsonPatchSupported: jsonPatchSupported,
Type: messageType,
//Not storing Mutations because they will not be retransmitted in case of reconnection
if messageType != common.Mutation {
browserConnection.ActiveSubscriptionsMutex.Lock()
browserConnection.ActiveSubscriptions[queryId] = common.GraphQlSubscription{
Id: queryId,
Message: fromBrowserMessageAsMap,
OperationName: operationName,
StreamCursorField: streamCursorField,
StreamCursorVariableName: streamCursorVariableName,
StreamCursorCurrValue: streamCursorInitialValue,
LastSeenOnHasuraConnetion: hc.Id,
JsonPatchSupported: jsonPatchSupported,
Type: messageType,
}
// log.Tracef("Current queries: %v", browserConnection.ActiveSubscriptions)
browserConnection.ActiveSubscriptionsMutex.Unlock()
}
// log.Tracef("Current queries: %v", browserConnection.ActiveSubscriptions)
browserConnection.ActiveSubscriptionsMutex.Unlock()
}
if fromBrowserMessageAsMap["type"] == "stop" {