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.example.demo.data | |
import org.springframework.data.mongodb.core.mapping.Document | |
import java.util.* | |
import javax.persistence.Id | |
@Document(collection="person") | |
data class Person( | |
@Id | |
val id: String = UUID.randomUUID().toString(), |
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.example.demo.repository | |
import com.example.demo.data.Person | |
import org.springframework.data.mongodb.repository.MongoRepository | |
import org.springframework.stereotype.Repository | |
@Repository | |
interface PersonRepository : MongoRepository<Person, String> { | |
fun findByNameLike(name: String): List<Person> | |
} |
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.example.demo.dao | |
import com.example.demo.repository.PersonRepository | |
import org.springframework.stereotype.Component | |
@Component | |
class PersonDao( | |
private val personRepository: PersonRepository | |
) { | |
fun getPersonById(id: 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
package com.example.demo.graphql.query | |
import com.coxautodev.graphql.tools.GraphQLQueryResolver | |
import com.example.demo.dao.PersonDao | |
import com.example.demo.data.Person | |
import org.springframework.stereotype.Component | |
@Component | |
class PersonQueryResolver( | |
private val personDao: PersonDao |
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 { | |
# The API Version | |
version: String! | |
# Get person with ID | |
person(id: ID!): Person | |
# Get persons by name | |
personsByName(name: String!): [Person] | |
} |
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 Person { | |
id: ID! | |
name: 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
type Query { | |
# The API Version | |
version : 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
package com.example.demo.graphql | |
import com.coxautodev.graphql.tools.GraphQLQueryResolver | |
import org.springframework.stereotype.Component | |
@Component | |
class Query: GraphQLQueryResolver { | |
fun version() = "1.0.0" | |
} |
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.example.demo.dao | |
import com.example.demo.repository.PersonRepository | |
import org.springframework.stereotype.Component | |
@Component | |
class PersonDao( | |
private val personRepository: PersonRepository | |
) { | |
fun getPersonById(id: 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
package com.example.demo.graphql | |
import com.coxautodev.graphql.tools.GraphQLMutationResolver | |
import com.example.demo.dao.PersonDao | |
import com.example.demo.data.Person | |
import com.example.demo.graphql.input.PersonInput | |
import org.springframework.stereotype.Component | |
@Component | |
class Mutation( |