Skip to content

Instantly share code, notes, and snippets.

View maniish-jaiin's full-sized avatar
🎯
Focusing

Manish Jain maniish-jaiin

🎯
Focusing
View GitHub Profile
{
"errors": [
{
"message": "Internal Server Error(s) while executing query"
}
],
"data": null
}
query getComments {
comment {
body
user{
id
name
}
}
}
type Comment {
body: String
user: User
}
type User{
id: ID
name: String
}
type Comment {
body: String
userId: ID
}
type Mutation {
addComment(input: AddCommentInput!): Comment
}
input AddCommentInput {
userId: ID
body: String
}
type Comment {
{
"errors": [
{
"message":
"Exception while fetching data (/getCar) : Car with name = B Class not found",
"path": [
"getCar"
],
"extensions": {
@Service
class CarService {
fun getCar(input: String): Car {
return CarMap.cars[input]
?: throw CarNotFoundException("Car with name = $input not found",
mapOf("name" to input))
}
fun createCar(input: CarInput): Car {
val car = Car(input.name, input.price, input.engineType)
public class GraphQLException extends RuntimeException implements GraphQLError {
String customMessage;
public GraphQLException(String customMessage) {
this.customMessage = customMessage;
}
@Override
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()))
}
@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