Skip to content
Draft
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 @@ -571,7 +571,7 @@ private GraphQLSchema create() {
.field(
GraphQLFieldDefinition.newFieldDefinition()
.name("quays")
.description("Get all quays")
.description("Get quays. Either ids or name must be set.")
.withDirective(TransmodelDirectives.TIMING_DATA)
.type(new GraphQLNonNull(new GraphQLList(quayType)))
.argument(
Expand All @@ -583,18 +583,25 @@ private GraphQLSchema create() {
.argument(GraphQLArgument.newArgument().name("name").type(Scalars.GraphQLString).build())
.dataFetcher(environment -> {
if (environment.containsArgument("ids")) {
var ids = mapIDsToDomainNullSafe(environment.getArgument("ids"));

if (environment.getArgument("ids") == null) {
throw new IllegalArgumentException("ids argument must be set to a non-null value.");
}
if (environment.getArgument("name") != null) {
throw new IllegalArgumentException("Unable to combine other filters with ids");
}

var ids = mapIDsToDomainNullSafe(environment.getArgument("ids"));

TransitService transitService = GqlUtil.getTransitService(environment);
return ids.stream().map(transitService::getStopLocation).toList();
}

if (environment.getArgument("name") == null) {
throw new IllegalArgumentException("At least one of ids or name must be set.");
}

FindStopLocationsRequest request = FindStopLocationsRequest.of()
.withName(environment.getArgument("name"))
.withName(Objects.requireNonNull(environment.getArgument("name")))
.build();

return GqlUtil.getTransitService(environment).findStopLocations(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ type QueryType {
operators: [Operator]! @timingData
"Get a single quay based on its id)"
quay(id: String!): Quay @timingData
"Get all quays"
"Get quays. Either ids or name must be set."
quays(ids: [String], name: String): [Quay]! @timingData
"Get all quays within the specified bounding box"
quaysByBbox(
Expand Down
Loading