Skip to content

Commit

Permalink
Merge pull request #19523 from gustavotrott/middleware-stop-retransmi…
Browse files Browse the repository at this point in the history
…tting-mutations

Prevent graphql-middlware from re-transmitting Mutations
  • Loading branch information
gustavotrott committed Jan 25, 2024
2 parents bb595be + 05ddcb6 commit ecace2f
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions bbb-graphql-middleware/internal/hascli/conn/writer/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit ecace2f

Please sign in to comment.