diff --git a/task07/src/main/java/de/hftstuttgart/vs/task07/integration/graphql/CountryClient.java b/task07/src/main/java/de/hftstuttgart/vs/task07/integration/graphql/CountryClient.java index d8fc622..0ea6277 100644 --- a/task07/src/main/java/de/hftstuttgart/vs/task07/integration/graphql/CountryClient.java +++ b/task07/src/main/java/de/hftstuttgart/vs/task07/integration/graphql/CountryClient.java @@ -14,12 +14,6 @@ import reactor.core.publisher.Mono; @Service public class CountryClient { - /* - TODO: - 1. Add query document names - 2. Assign variables as needed in the query document - */ - private final GraphQlClient graphQlClient; public CountryClient() { @@ -28,25 +22,33 @@ public class CountryClient { } public Mono getCountryByCountryCode(final String countryCode, final String lang) { - return graphQlClient.documentName("TODO").variable("TODO", "TODO").retrieve("country").toEntity(Country.class); + return graphQlClient + .documentName("getCountry") + .variable("countryCode", countryCode) + .variable("lang", lang) + .retrieve("country") + .toEntity(Country.class); } public Mono> getCountriesByCurrency(final String currency) { return graphQlClient - .documentName("TODO") - .variable("TODO", "TODO") + .documentName("getAllCountriesWithCurrency") + .variable("currency", currency) .retrieve("countries") .toEntityList(Country.class); } public Mono> getAllContinents() { - return graphQlClient.documentName("TODO").retrieve("continents").toEntityList(Continent.class); + return graphQlClient + .documentName("getAllContinents") + .retrieve("continents") + .toEntityList(Continent.class); } public Mono getContinentByCodeWithCountries(final String code) { return graphQlClient - .documentName("TODO") - .variable("TODO", "TODO") + .documentName("getContinentWithCountries") + .variable("continentCode", code) .retrieve("continent") .toEntity(Continent.class); } diff --git a/task07/src/main/resources/graphql-documents/getAllContinents.graphql b/task07/src/main/resources/graphql-documents/getAllContinents.graphql index 351a5f4..ae6ee38 100644 --- a/task07/src/main/resources/graphql-documents/getAllContinents.graphql +++ b/task07/src/main/resources/graphql-documents/getAllContinents.graphql @@ -1 +1,6 @@ -# TODO add query +query getAllContinents { + continents { + name + code + } +} diff --git a/task07/src/main/resources/graphql-documents/getAllCountriesWithCurrency.graphql b/task07/src/main/resources/graphql-documents/getAllCountriesWithCurrency.graphql index 351a5f4..8b747db 100644 --- a/task07/src/main/resources/graphql-documents/getAllCountriesWithCurrency.graphql +++ b/task07/src/main/resources/graphql-documents/getAllCountriesWithCurrency.graphql @@ -1 +1,6 @@ -# TODO add query +query getAllCountriesWithCurrency($currency: String!) { + countries(filter: {currency: {regex: $currency}}) { + code + name + } +} diff --git a/task07/src/main/resources/graphql-documents/getContinentWithCountries.graphql b/task07/src/main/resources/graphql-documents/getContinentWithCountries.graphql index 351a5f4..7190a33 100644 --- a/task07/src/main/resources/graphql-documents/getContinentWithCountries.graphql +++ b/task07/src/main/resources/graphql-documents/getContinentWithCountries.graphql @@ -1 +1,10 @@ -# TODO add query +query getContinentWithCountries($continentCode: ID!) { + continent(code: $continentCode) { + name + code + countries { + name + code + } + } +} diff --git a/task07/src/main/resources/graphql-documents/getCountry.graphql b/task07/src/main/resources/graphql-documents/getCountry.graphql index 351a5f4..93cebb4 100644 --- a/task07/src/main/resources/graphql-documents/getCountry.graphql +++ b/task07/src/main/resources/graphql-documents/getCountry.graphql @@ -1 +1,13 @@ -# TODO add query +query getCountry($countryCode: ID!, $lang: String) { + country(code: $countryCode) { + name(lang: $lang) + capital + emoji + languages { + name + code + } + currencies + phones + } +}