Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On the client side, support @Id on collections #1365

Merged
merged 2 commits into from
Apr 22, 2022
Merged
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 @@ -36,7 +36,11 @@ public String toString() {

public String graphQlInputTypeName() {
if (parameter.isAnnotationPresent(Id.class)) {
return "ID" + optionalExclamationMark(type);
if (type.isCollection()) {
return "[ID" + optionalExclamationMark(type.getItemType()) + "]" + optionalExclamationMark(type);
} else {
return "ID" + optionalExclamationMark(type);
}
} else if (type.isCollection()) {
return "[" + withExclamationMark(type.getItemType()) + "]" + optionalExclamationMark(type);
} else if (type.isMap()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tck.graphql.typesafe;

import static java.time.ZoneOffset.UTC;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.catchThrowableOfType;
import static org.assertj.core.api.BDDAssertions.then;

Expand All @@ -15,6 +16,7 @@
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.eclipse.microprofile.graphql.Id;
Expand Down Expand Up @@ -584,9 +586,14 @@ interface IdApi {
@Id
String idea(
@Id String stringId,
@Id List<String> stringListId,
@Id List<@NonNull String> stringListInnerNonNullId,
@Id @NonNull List<String> stringListOuterNonNullId,
@Id @NonNull List<@NonNull String> stringListBothNonNullId,
@Id long primitiveLongId,
@Id int primitiveIntId,
@Id Long longId,
@Id List<Long> longListId,
@Id Integer intId,
@Id UUID uuidId);
}
Expand Down Expand Up @@ -719,20 +726,31 @@ void shouldCallIdQuery() {
fixture.returnsData("'idea':'out'");
IdApi api = fixture.builder().build(IdApi.class);

String out = api.idea("stringId", 1L, 2, 3L, 4, UUID.randomUUID());
String out = api.idea("stringId", singletonList("x"), singletonList("x"), singletonList("x"), singletonList("x"),
1L, 2, 3L, singletonList(5L), 4, UUID.randomUUID());

then(fixture.query()).isEqualTo("query idea(" +
"$stringId: ID, " +
"$stringListId: [ID], " +
"$stringListInnerNonNullId: [ID!], " +
"$stringListOuterNonNullId: [ID]!, " +
"$stringListBothNonNullId: [ID!]!, " +
"$primitiveLongId: ID!, " +
"$primitiveIntId: ID!, " +
"$longId: ID, " +
"$longListId: [ID], " +
"$intId: ID, " +
"$uuidId: ID) " +
"{ idea(" +
"stringId: $stringId, " +
"stringListId: $stringListId, " +
"stringListInnerNonNullId: $stringListInnerNonNullId, " +
"stringListOuterNonNullId: $stringListOuterNonNullId, " +
"stringListBothNonNullId: $stringListBothNonNullId, " +
"primitiveLongId: $primitiveLongId, " +
"primitiveIntId: $primitiveIntId, " +
"longId: $longId, " +
"longListId: $longListId, " +
"intId: $intId, " +
"uuidId: $uuidId) }");
then(out).isEqualTo("out");
Expand Down