JAVA-12421 Renamed graphql to graphql-modules

This commit is contained in:
Dhawal Kapil
2022-06-03 18:00:47 +05:30
parent 4413c8d66d
commit db663d2033
81 changed files with 12 additions and 11 deletions
@@ -0,0 +1,25 @@
package com.bealdung.graphqlDGS;
public class Album {
private final String title;
private final String artist;
private final Integer recordNo;
public Album(String title, String artist, Integer recordNo) {
this.title = title;
this.recordNo = recordNo;
this.artist = artist;
}
public String getTitle() {
return title;
}
public String getArtist() {
return artist;
}
public Integer getRecordNo() {
return recordNo;
}
}
@@ -0,0 +1,28 @@
package com.bealdung.graphqlDGS;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsQuery;
import com.netflix.graphql.dgs.InputArgument;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@DgsComponent
public class AlbumsDataFetcher {
private final List<Album> albums = Arrays.asList(
new Album("Rumours", "Fleetwood Mac", 20),
new Album("What's Going On", "Marvin Gaye", 10),
new Album("Pet Sounds", "The Beach Boys", 12)
);
@DgsQuery
public List<Album> albums(@InputArgument String titleFilter) {
if(titleFilter == null) {
return albums;
}
return albums.stream()
.filter(s -> s.getTitle().contains(titleFilter))
.collect(Collectors.toList());
}
}
@@ -0,0 +1,13 @@
package com.bealdung.graphqlDGS;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
@@ -0,0 +1 @@
server.servlet.context-path=
@@ -0,0 +1,9 @@
type Query {
albums(titleFilter: String): [Album]
}
type Album {
title: String
artist: String
recordNo: Int
}