Created
February 2, 2021 20:30
-
-
Save paulbakker/75af1511a97bdc8954a6ef29a073bf5e to your computer and use it in GitHub Desktop.
DGS code example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@DgsComponent | |
public class ShowsDatafetcher { | |
private final List<Show> shows = | |
List.of( | |
new Show("Stranger Things", 2016), | |
new Show("Ozark", 2017) | |
); | |
@DgsData(parentType = "Query", field = "shows") | |
public List<Show> shows(@InputArgument("titleFilter") String titleFilter) { | |
if(titleFilter == null) { | |
return shows; | |
} | |
return shows.stream() | |
.filter(s -> s.getTitle().contains(titleFilter)) | |
.collect(Collectors.toList()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment