diff --git a/server/api/src/main/java/io/smallrye/graphql/api/ErrorExtensionProvider.java b/server/api/src/main/java/io/smallrye/graphql/api/ErrorExtensionProvider.java
new file mode 100644
index 000000000..f0f11033c
--- /dev/null
+++ b/server/api/src/main/java/io/smallrye/graphql/api/ErrorExtensionProvider.java
@@ -0,0 +1,13 @@
+package io.smallrye.graphql.api;
+
+import jakarta.json.JsonValue;
+
+/**
+ * To add you own GraphQL error extension
fields, you can add your own implementations
+ * of this class via the {@link java.util.ServiceLoader ServiceLoader} mechanism.
+ */
+public interface ErrorExtensionProvider {
+ String getKey();
+
+ JsonValue mapValueFrom(Throwable exception);
+}
diff --git a/server/implementation/src/main/java/io/smallrye/graphql/execution/ExecutionResponse.java b/server/implementation/src/main/java/io/smallrye/graphql/execution/ExecutionResponse.java
index 566fe4b7d..7e20f1642 100644
--- a/server/implementation/src/main/java/io/smallrye/graphql/execution/ExecutionResponse.java
+++ b/server/implementation/src/main/java/io/smallrye/graphql/execution/ExecutionResponse.java
@@ -59,9 +59,7 @@ public JsonObject getExecutionResultAsJsonObject() {
// Extensions
returnObjectBuilder = addExtensionsToResponse(returnObjectBuilder, executionResult);
- JsonObject jsonResponse = returnObjectBuilder.build();
-
- return jsonResponse;
+ return returnObjectBuilder.build();
}
public String getExecutionResultAsString() {
@@ -75,10 +73,8 @@ private JsonObjectBuilder addErrorsToResponse(JsonObjectBuilder returnObjectBuil
if (!jsonArray.isEmpty()) {
returnObjectBuilder = returnObjectBuilder.add(ERRORS, jsonArray);
}
- return returnObjectBuilder;
- } else {
- return returnObjectBuilder;
}
+ return returnObjectBuilder;
}
private JsonObjectBuilder addDataToResponse(JsonObjectBuilder returnObjectBuilder, ExecutionResult executionResult) {
@@ -123,7 +119,7 @@ private JsonObject buildExtensions(final Map