Skip to content

Commit

Permalink
[4368] Add GraphQL subscription exception handler
Browse files Browse the repository at this point in the history
Bug: #4368
Signed-off-by: Denis Nikiforov <[email protected]>
  • Loading branch information
AresEkb authored and sbegaudeau committed Jan 6, 2025
1 parent ad44eda commit eaaae96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -112,4 +114,4 @@ public GraphQLSchema graphQLSchema(ResourcePatternResolver resourcePatternResolv
}
return null;
}
}
}

0 comments on commit eaaae96

Please sign in to comment.