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
@Component | |
class HelloWorldResolver: GraphQLQueryResolver { | |
fun hello(): String { | |
return "Hello World!" | |
} | |
} |
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
query{ | |
hello | |
} |
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
{ | |
"data": { | |
"hello": "Hello World!" | |
} | |
} |
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
@Configuration | |
class GraphQLConfig() { | |
@Bean | |
fun schemaParserDictionary(): SchemaParserDictionary { | |
return SchemaParserDictionary() | |
.add(IBike::class) | |
.add(ICar::class) | |
} | |
} |
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
{ | |
"errors": [ | |
{ | |
"message": "Internal Server Error(s) while executing query" | |
} | |
], | |
"data": null | |
} |
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
mutation createCar($input: CarInput){ | |
createCar(input: $input) { | |
name | |
} | |
} |
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
query{ | |
getCar(input: "B Class"){ | |
name | |
} | |
} |
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{ | |
hello: String | |
getCar(input: String) : Car! | |
} | |
type Mutation{ | |
createCar(input: CarInput): Car | |
} | |
type Car { |
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
@Service | |
class CarService { | |
fun getCar(input: String): Car { | |
return CarMap.cars[input]!! | |
} | |
fun createCar(input: CarInput): Car { | |
val car = Car(input.name, input.price, input.engineType) | |
CarMap.cars[input.name] = car | |
return car |
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
open class CarNotFoundException( | |
errorMessage: String? = "", | |
private val parameters: Map<String, Any>? = mutableMapOf() | |
) : GraphQLException(errorMessage) { | |
override val message: String? | |
get() = super.message | |
override fun getExtensions(): MutableMap<String, Any> { | |
return mutableMapOf("parameters" to (parameters ?: mutableMapOf())) | |
} |