From eaaae96eb2a6f44051ac758cb33d25012c626885 Mon Sep 17 00:00:00 2001 From: Denis Nikiforov Date: Wed, 18 Dec 2024 14:53:50 +0300 Subject: [PATCH] [4368] Add GraphQL subscription exception handler Bug: https://github.com/eclipse-sirius/sirius-web/issues/4368 Signed-off-by: Denis Nikiforov --- CHANGELOG.adoc | 1 + .../configuration/graphql/GraphQLConfiguration.java | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 7c9cb66fe3..5cb2cf6fa4 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -40,6 +40,7 @@ Specifiers can contribute dedicated AQL services for this feature using implemen === Improvements +- https://github.com/eclipse-sirius/sirius-web/issues/4368[#4368] [sirius-web] Add GraphQL subscription exception handler == v2025.1.0 diff --git a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/configuration/graphql/GraphQLConfiguration.java b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/configuration/graphql/GraphQLConfiguration.java index 719c08a4cf..e831c40225 100644 --- a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/configuration/graphql/GraphQLConfiguration.java +++ b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/configuration/graphql/GraphQLConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2024, 2024 Obeo. + * Copyright (c) 2024, 2025 Obeo. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -30,6 +30,7 @@ import graphql.execution.AsyncSerialExecutionStrategy; import graphql.execution.DataFetcherExceptionHandler; import graphql.execution.ExecutionStrategy; +import graphql.execution.SubscriptionExecutionStrategy; import graphql.schema.GraphQLCodeRegistry; import graphql.schema.GraphQLSchema; import graphql.schema.idl.RuntimeWiring; @@ -65,12 +66,13 @@ public GraphQL graphQL(GraphQLSchema graphQLSchema) { // @see https://www.graphql-java.com/documentation/v11/execution/ The graphql specification says that mutations // MUST be executed serially and in the order in which the query fields occur. ExecutionStrategy mutationExecutionStrategy = new AsyncSerialExecutionStrategy(exceptionHandler); - // @formatter:off + ExecutionStrategy subscriptionExecutionStrategy = new SubscriptionExecutionStrategy(exceptionHandler); + return GraphQL.newGraphQL(graphQLSchema) .queryExecutionStrategy(queryExecutionStrategy) .mutationExecutionStrategy(mutationExecutionStrategy) + .subscriptionExecutionStrategy(subscriptionExecutionStrategy) .build(); - // @formatter:on } @Bean @@ -112,4 +114,4 @@ public GraphQLSchema graphQLSchema(ResourcePatternResolver resourcePatternResolv } return null; } -} \ No newline at end of file +}