Skip to content

Commit 2de0f00

Browse files
Copilotxperiandri
andauthored
Deduplicate deferred pending announcements
Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent 5ee0b11 commit 2de0f00

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎src/FSharp.Data.GraphQL.Server.AspNetCore/IncrementalDelivery.fs‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,11 @@ type IncrementalDelivery () =
276276
// A plain (non-indexed) path: a @defer field's own value.
277277
let state, isNew = stateFor fieldPath
278278
let incremental = { Id = state.Id; Data = Include data; Items = Skip; Errors = Skip }
279-
let pending = [
280-
yield! pendingFor fieldPath state isNew
281-
yield! takeFieldPending fieldPath
282-
yield! takePendingVisibleIn fieldPath data
283-
]
279+
let fieldPending =
280+
match takeFieldPending fieldPath with
281+
| [] -> pendingFor fieldPath state isNew
282+
| pending -> pending
283+
let pending = [ yield! fieldPending; yield! takePendingVisibleIn fieldPath data ]
284284
ValueSome (SubscriptionExecutionResult.CreateSubsequent (pending, [ incremental ], [], true))
285285
| DeferredErrors (data, errors, fieldPath) ->
286286
match fields.TryGetValue fieldPath with
@@ -295,11 +295,11 @@ type IncrementalDelivery () =
295295
// A @defer field's own failure.
296296
let state, isNew = stateFor fieldPath
297297
let incremental = { Id = state.Id; Data = Include data; Items = Skip; Errors = Include errors }
298-
let pending = [
299-
yield! pendingFor fieldPath state isNew
300-
yield! takeFieldPending fieldPath
301-
yield! takePendingVisibleIn fieldPath data
302-
]
298+
let fieldPending =
299+
match takeFieldPending fieldPath with
300+
| [] -> pendingFor fieldPath state isNew
301+
| pending -> pending
302+
let pending = [ yield! fieldPending; yield! takePendingVisibleIn fieldPath data ]
303303
ValueSome (SubscriptionExecutionResult.CreateSubsequent (pending, [ incremental ], [], true))
304304
| DeferredCompleted fieldPath ->
305305
match fields.TryGetValue fieldPath with

0 commit comments

Comments
 (0)