Skip to content

Conversation

BoD
Copy link
Contributor

@BoD BoD commented Dec 17, 2024

Implements the latest (as of 2025-09-24) @defer incremental response format as seen in examples and spec edits.

A protocol can now be passed to the HttpNetworkTransport to choose which to use (legacy 20220824 is still the default).

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Dec 17, 2024

✅ Docs Preview Ready

Configuration
{
  "repoOverrides": {
    "apollographql/apollo-kotlin@main": {
      "remote": {
        "owner": "apollographql",
        "repo": "apollo-kotlin",
        "branch": "defer-incremental-response-format-june-2023"
      }
    }
  }
}
Name Link

Commit

e2da859

Preview

https://www.apollographql.com/docs/deploy-preview/1919dfd3b4a18c13cba2

Build ID

1919dfd3b4a18c13cba2

File Changes

0 new, 1 changed, 0 removed
* (developer-tools)/kotlin/(latest)/caching/declarative-ids.mdx

Pages

1


1 pages published. Build will be available for 30 days.

@BoD BoD force-pushed the defer-incremental-response-format-june-2023 branch from e2da859 to bb504f6 Compare July 17, 2025 09:39
@apollo-librarian
Copy link

apollo-librarian bot commented Jul 17, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: c8d256329554a5b39384233f
Build Logs: View logs

@BoD BoD force-pushed the defer-incremental-response-format-june-2023 branch 2 times, most recently from e1ee642 to 4fa99ad Compare July 18, 2025 17:01
@martinbonnin
Copy link
Contributor

Apollo Client 4 introduces different handlers for different incremental formats. We could do the same while the format iterates.

@BoD BoD force-pushed the defer-incremental-response-format-june-2023 branch 3 times, most recently from fc4f174 to 8dfc4b3 Compare September 24, 2025 16:23
@BoD BoD marked this pull request as ready for review September 25, 2025 07:44
@BoD BoD requested a review from martinbonnin as a code owner September 25, 2025 07:44
this.engine = httpEngine
}

fun incrementalDeliveryProtocol(incrementalDeliveryProtocol: IncrementalDeliveryProtocol) = apply {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing KDoc here

Also, looks like apollo-client went with incrementalHandler. Might be worth reusing some of the terminology? But we also have "protocol" for other things like WebSockets so my logaf is low.

Comment on lines 232 to 243
public final class com/apollographql/apollo/internal/incremental/Defer20220824IncrementalResultsMerger : com/apollographql/apollo/internal/incremental/IncrementalResultsMerger {
public fun <init> ()V
public fun getHasNext ()Z
public fun getIncrementalResultIdentifiers ()Ljava/util/Set;
public fun getMerged ()Ljava/util/Map;
public fun isEmptyResponse ()Z
public fun merge (Ljava/util/Map;)Ljava/util/Map;
public fun merge (Lokio/BufferedSource;)Ljava/util/Map;
public fun reset ()V
}

public final class com/apollographql/apollo/internal/incremental/GraphQL17Alpha9IncrementalResultsMerger : com/apollographql/apollo/internal/incremental/IncrementalResultsMerger {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird that one is Defer20220824 and the other GraphQL17Alpha9. I haven't followed all the latest discussions lately but could we somwhat uniformized that? Are there specs versions (or tags) somewhere that describe what each one is doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t look like there are any tags on the spec itself, so using graphql-js versions is cool. So maybe we should rename Defer20220824 to whatever version of graphql-js it corresponds to, for consistency. For now I kept the same naming as Apollo Client, but maybe it’s not too late to change the name there too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Let's keep a practical approach here and do whatever is easiest. This is all experimental so the whole point is to move fast and iterate 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end, I opted for this naming in the API:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Draft0_0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, what about:

  • Incremental0_0
  • Incremental0_1
    ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I like it! But then it would make sense to have specs.apollo.dev/incremental/v0.0 to match it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would make sense to have specs.apollo.dev/incremental/v0.0 to match it.

Yea, would be nice of course but if we don't have time for this, I think it's still fine. Besides me, everyone finds 0.0 to be a weird version name. So I think most people would understand if 0.0 is "unreleased initial version"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't have it, add a KDoc comment: "0.0 is the @defer protocol used as of 20220824. It has not been specified and is kept for backward compatibility reasons", something like this.

payloadResponse != null -> payloadResponse
else -> null
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to test from the response whether it supports the incremental delivey protocol? Is there something in response.headers["content-type"] that signals what protocol was used by the server?

BoD added 29 commits October 16, 2025 14:42
…gmentIdentifier -> IncrementalResultIdentifier
@BoD BoD force-pushed the defer-incremental-response-format-june-2023 branch from 76ff55c to 97177bd Compare October 16, 2025 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants