diff --git a/graphql/graphql-error-handling/pom.xml b/graphql/graphql-error-handling/pom.xml
new file mode 100644
index 0000000000..0cd00df3b9
--- /dev/null
+++ b/graphql/graphql-error-handling/pom.xml
@@ -0,0 +1,97 @@
+
+
+ 4.0.0
+ com.baeldung.graphql
+ graphql-error-handling
+ 1.0
+ jar
+ graphql-error-handling
+
+
+ com.baeldung
+ parent-boot-2
+ 0.0.1-SNAPSHOT
+ ../../parent-boot-2
+
+
+
+ 1.8
+ 1.18.18
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ com.graphql-java
+ graphql-spring-boot-starter
+ 5.0.2
+
+
+
+ com.graphql-java
+ graphql-java-tools
+ 5.2.4
+
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+
+
+
+ com.h2database
+ h2
+ ${h2.version}
+
+
+
+ org.springframework.boot
+ spring-boot-test
+ test
+ 2.6.4
+
+
+
+ com.graphql-java
+ graphql-spring-boot-starter-test
+ test
+ 5.0.2
+
+
+
+ org.assertj
+ assertj-core
+ 3.22.0
+ test
+
+
+
+ org.skyscreamer
+ jsonassert
+ 1.5.0
+ test
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
\ No newline at end of file
diff --git a/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/GraphQLErrorHandlerApplication.java b/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/GraphQLErrorHandlerApplication.java
new file mode 100644
index 0000000000..565c9e0a15
--- /dev/null
+++ b/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/GraphQLErrorHandlerApplication.java
@@ -0,0 +1,46 @@
+package com.baeldung.graphql.error.handling;
+
+import com.baeldung.graphql.error.handling.exception.GraphQLErrorAdapter;
+import graphql.ExceptionWhileDataFetching;
+import graphql.GraphQLError;
+import graphql.servlet.GraphQLErrorHandler;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@SpringBootApplication
+public class GraphQLErrorHandlerApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(GraphQLErrorHandlerApplication.class, args);
+ }
+
+ @Bean
+ public GraphQLErrorHandler errorHandler() {
+ return new GraphQLErrorHandler() {
+ @Override
+ public List processErrors(List errors) {
+ List clientErrors = errors.stream()
+ .filter(this::isClientError)
+ .collect(Collectors.toList());
+
+ List serverErrors = errors.stream()
+ .filter(e -> !isClientError(e))
+ .map(GraphQLErrorAdapter::new)
+ .collect(Collectors.toList());
+
+ List e = new ArrayList<>();
+ e.addAll(clientErrors);
+ e.addAll(serverErrors);
+ return e;
+ }
+
+ private boolean isClientError(GraphQLError error) {
+ return !(error instanceof ExceptionWhileDataFetching || error instanceof Throwable);
+ }
+ };
+ }
+}
diff --git a/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/domain/Location.java b/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/domain/Location.java
new file mode 100644
index 0000000000..815bf3a26a
--- /dev/null
+++ b/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/domain/Location.java
@@ -0,0 +1,29 @@
+package com.baeldung.graphql.error.handling.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@Entity
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class Location {
+ @Id
+ private String zipcode;
+
+ private String city;
+ private String state;
+
+ @OneToMany(mappedBy = "location", fetch = FetchType.EAGER)
+ private List vehicles = new ArrayList<>();
+}
diff --git a/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/domain/Vehicle.java b/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/domain/Vehicle.java
new file mode 100644
index 0000000000..e206bdb009
--- /dev/null
+++ b/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/domain/Vehicle.java
@@ -0,0 +1,26 @@
+package com.baeldung.graphql.error.handling.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+
+@Data
+@Entity
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class Vehicle {
+ @Id
+ private String vin;
+ private Integer year;
+ private String make;
+ private String model;
+ private String trim;
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "fk_location")
+ private Location location;
+}
diff --git a/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/exception/AbstractGraphQLException.java b/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/exception/AbstractGraphQLException.java
new file mode 100644
index 0000000000..4e7be50ae4
--- /dev/null
+++ b/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/exception/AbstractGraphQLException.java
@@ -0,0 +1,44 @@
+package com.baeldung.graphql.error.handling.exception;
+
+import graphql.ErrorType;
+import graphql.GraphQLError;
+import graphql.language.SourceLocation;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AbstractGraphQLException extends RuntimeException implements GraphQLError {
+ private Map parameters = new HashMap();
+
+ public AbstractGraphQLException(String message) {
+ super(message);
+ }
+
+ public AbstractGraphQLException(String message, Map additionParams) {
+ this(message);
+ if (additionParams != null) {
+ parameters = additionParams;
+ }
+ }
+
+ @Override
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ @Override
+ public List getLocations() {
+ return null;
+ }
+
+ @Override
+ public ErrorType getErrorType() {
+ return null;
+ }
+
+ @Override
+ public Map getExtensions() {
+ return this.parameters;
+ }
+}
diff --git a/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/exception/GraphQLErrorAdapter.java b/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/exception/GraphQLErrorAdapter.java
new file mode 100644
index 0000000000..d982f98db3
--- /dev/null
+++ b/graphql/graphql-error-handling/src/main/java/com/baeldung/graphql/error/handling/exception/GraphQLErrorAdapter.java
@@ -0,0 +1,48 @@
+package com.baeldung.graphql.error.handling.exception;
+
+import graphql.ErrorType;
+import graphql.ExceptionWhileDataFetching;
+import graphql.GraphQLError;
+import graphql.language.SourceLocation;
+
+import java.util.List;
+import java.util.Map;
+
+public class GraphQLErrorAdapter implements GraphQLError {
+
+ private GraphQLError error;
+
+ public GraphQLErrorAdapter(GraphQLError error) {
+ this.error = error;
+ }
+
+ @Override
+ public Map getExtensions() {
+ return error.getExtensions();
+ }
+
+ @Override
+ public List getLocations() {
+ return error.getLocations();
+ }
+
+ @Override
+ public ErrorType getErrorType() {
+ return error.getErrorType();
+ }
+
+ @Override
+ public List