Last active
September 20, 2017 08:01
-
-
Save ceefour/b721750ba2c2e1440e8c2059fc595db3 to your computer and use it in GitHub Desktop.
GraphQL Java
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
type Query { | |
countries: [Country!] | |
} | |
# Country in the world | |
type Country { | |
# ISO 3-letter country code | |
code: ID! | |
# Formal name of country | |
name: String! | |
continent: String | |
region: String | |
surfaceArea: String | |
indepYear: String | |
population: String | |
lifeExpectancy: Float | |
gnp: Float | |
gnpOld: Float | |
localName: String | |
governmentForm: String | |
headOfState: String | |
# ISO 2-letter country code | |
code2: String | |
} |
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
<dependency> | |
<groupId>com.graphql-java</groupId> | |
<artifactId>graphql-java-tools</artifactId> | |
<version>4.1.1</version> | |
</dependency> | |
<dependency> | |
<groupId>com.graphql-java</groupId> | |
<artifactId>graphql-spring-boot-starter</artifactId> | |
<version>3.9.0</version> | |
</dependency> |
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
package com.hendyirawan.jws1051; | |
import com.coxautodev.graphql.tools.GraphQLQueryResolver; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Component; | |
import java.util.List; | |
@Component | |
public class Query implements GraphQLQueryResolver { | |
@Autowired | |
private CountryRepository countryRepo; | |
public List<Country> countries() { | |
return countryRepo.findAll(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment