Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class SchemaTypeSpecBuilder(
fun responseMarshallerSpec(fieldSpecs: List<FieldSpec>): MethodSpec {
val code = fieldSpecs
.map { fieldSpec ->
if (fieldSpec.type.isOptional()) {
if (fieldSpec.type.isNullable()) {
CodeBlock.builder()
.addStatement("final \$T \$L = \$L", fieldSpec.type.unwrapOptionalType().withoutAnnotations(),
"\$${fieldSpec.name}", fieldSpec.type.unwrapOptionalValue(fieldSpec.name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,14 @@ public ResponseFieldMarshaller marshaller() {
return new ResponseFieldMarshaller() {
@Override
public void marshal(ResponseWriter writer) {
writer.writeFragment(humanDetails.marshaller());
writer.writeFragment(droidDetails.marshaller());
final HumanDetails $humanDetails = humanDetails;
if ($humanDetails != null) {
writer.writeFragment($humanDetails.marshaller());
}
final DroidDetails $droidDetails = droidDetails;
if ($droidDetails != null) {
writer.writeFragment($droidDetails.marshaller());
}
}
};
}
Expand Down Expand Up @@ -575,8 +581,14 @@ public ResponseFieldMarshaller marshaller() {
return new ResponseFieldMarshaller() {
@Override
public void marshal(ResponseWriter writer) {
writer.writeFragment(humanDetails.marshaller());
writer.writeFragment(droidDetails.marshaller());
final HumanDetails $humanDetails = humanDetails;
if ($humanDetails != null) {
writer.writeFragment($humanDetails.marshaller());
}
final DroidDetails $droidDetails = droidDetails;
if ($droidDetails != null) {
writer.writeFragment($droidDetails.marshaller());
}
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,14 @@ public ResponseFieldMarshaller marshaller() {
return new ResponseFieldMarshaller() {
@Override
public void marshal(ResponseWriter writer) {
writer.writeFragment(character.marshaller());
writer.writeFragment(starship.marshaller());
final Character $character = character;
if ($character != null) {
writer.writeFragment($character.marshaller());
}
final Starship $starship = starship;
if ($starship != null) {
writer.writeFragment($starship.marshaller());
}
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ public Builder useHttpGetMethodForQueries(boolean useHttpGetMethodForQueries) {

public Builder autoPersistQueries(boolean autoPersistQueries) {
this.autoPersistQueries = autoPersistQueries;
if (autoPersistQueries) {
sendQueryDocument = false;
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void run() {
}
};
private final List<OnSubscriptionManagerStateChangeListener> onStateChangeListeners = new CopyOnWriteArrayList<>();

private final boolean autoPersistSubscription;

public RealSubscriptionManager(@NotNull ScalarTypeAdapters scalarTypeAdapters,
Expand All @@ -89,6 +90,7 @@ public RealSubscriptionManager(@NotNull ScalarTypeAdapters scalarTypeAdapters,
this.transport = transportFactory.create(new SubscriptionTransportCallback(this, dispatcher));
this.dispatcher = dispatcher;
this.connectionHeartbeatTimeoutMs = connectionHeartbeatTimeoutMs;

this.responseNormalizer = responseNormalizer;
this.autoPersistSubscription = autoPersistSubscription;
}
Expand Down Expand Up @@ -309,7 +311,9 @@ void onOperationServerMessage(OperationServerMessage message) {
} else if (message instanceof OperationServerMessage.Complete) {
onCompleteServerMessage((OperationServerMessage.Complete) message);
} else if (message instanceof OperationServerMessage.ConnectionError) {
disconnect(true);
// Jordan - Ignore connection errors, as they don't always mean the socket should be disconnected
// See https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md#gql_connection_error
// disconnect(true);
} else if (message instanceof OperationServerMessage.ConnectionKeepAlive) {
resetConnectionKeepAliveTimerTask();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ public Init(@NotNull Map<String, Object> connectionParams) {
public static final class Start extends OperationClientMessage {
private static final String TYPE = "start";
private static final String JSON_KEY_QUERY = "query";
private static final String JSON_KEY_ID = "id";
private static final String JSON_KEY_VARIABLES = "variables";
private static final String JSON_KEY_OPERATION_NAME = "operationName";
private static final String JSON_KEY_EXTENSIONS = "extensions";
private static final String JSON_KEY_EXTENSIONS_PERSISTED_QUERY = "persistedQuery";
private static final String JSON_KEY_EXTENSIONS_PERSISTED_QUERY_VERSION = "version";
private static final String JSON_KEY_EXTENSIONS_PERSISTED_QUERY_HASH = "sha256Hash";
private final ScalarTypeAdapters scalarTypeAdapters;
private boolean enableAutoPersistedQueries;

public final String subscriptionId;
public final Subscription<?, ?, ?> subscription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void proceedAsync(@NotNull ApolloInterceptor.InterceptorRequest request,
)
);
} else if (proceedAsyncInvocationCount == 2) {
assertThat(request.sendQueryDocument).isTrue();
assertThat(request.sendQueryDocument).isFalse();
assertThat(request.autoPersistQueries).isTrue();
callBack.onResponse(
new ApolloInterceptor.InterceptorResponse(
Expand Down Expand Up @@ -157,7 +157,7 @@ public void proceedAsync(@NotNull ApolloInterceptor.InterceptorRequest request,
)
);
} else if (proceedAsyncInvocationCount == 2) {
assertThat(request.sendQueryDocument).isTrue();
assertThat(request.sendQueryDocument).isFalse();
assertThat(request.autoPersistQueries).isTrue();
callBack.onResponse(
new ApolloInterceptor.InterceptorResponse(
Expand Down
Loading