Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1312] Provide the validation GraphQL datafetchers
Bug: #1312 Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
- Loading branch information
1 parent
d33f718
commit 9752073
Showing
37 changed files
with
489 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...n/java/org/eclipse/sirius/components/graphql/api/IEventProcessorSubscriptionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 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 | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.graphql.api; | ||
|
||
import org.eclipse.sirius.components.collaborative.api.IRepresentationConfiguration; | ||
import org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor; | ||
import org.eclipse.sirius.components.core.api.IInput; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
|
||
import reactor.core.publisher.Flux; | ||
|
||
/** | ||
* Used to retrieve subscriptions. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public interface IEventProcessorSubscriptionProvider { | ||
<T extends IRepresentationEventProcessor> Flux<IPayload> getSubscription(String editingContextId, Class<T> representationEventProcessorClass, | ||
IRepresentationConfiguration representationConfiguration, IInput input); | ||
|
||
/** | ||
* Implementation which does nothing, used for mocks in unit tests. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
class NoOp implements IEventProcessorSubscriptionProvider { | ||
|
||
@Override | ||
public <T extends IRepresentationEventProcessor> Flux<IPayload> getSubscription(String editingContextId, Class<T> representationEventProcessorClass, | ||
IRepresentationConfiguration representationConfiguration, IInput input) { | ||
return Flux.empty(); | ||
} | ||
|
||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...raphql-api/src/main/java/org/eclipse/sirius/components/graphql/api/IExceptionWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 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 | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.graphql.api; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.function.Supplier; | ||
|
||
import org.eclipse.sirius.components.core.api.IInput; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
|
||
import graphql.relay.Connection; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
|
||
/** | ||
* Used to encapsulate calls to methods which may throw exceptions. This wrapper will make sure that a default result is | ||
* properly returned instead of having to repeat a default response in all the data fetchers. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public interface IExceptionWrapper { | ||
Flux<IPayload> wrapFlux(Supplier<Flux<IPayload>> supplier, IInput input); | ||
|
||
IPayload wrap(Supplier<IPayload> supplier, IInput input); | ||
|
||
<T> List<T> wrapList(Supplier<List<T>> supplier); | ||
|
||
<T> Optional<T> wrapOptional(Supplier<Optional<T>> supplier); | ||
|
||
<T> Connection<T> wrapConnection(Supplier<Connection<T>> supplier); | ||
|
||
Mono<IPayload> wrapMono(Supplier<Mono<IPayload>> supplier, IInput input); | ||
|
||
/** | ||
* Implementation which does nothing, used for mocks in unit tests. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
class NoOp implements IExceptionWrapper { | ||
|
||
@Override | ||
public Flux<IPayload> wrapFlux(Supplier<Flux<IPayload>> supplier, IInput input) { | ||
return Flux.empty(); | ||
} | ||
|
||
@Override | ||
public IPayload wrap(Supplier<IPayload> supplier, IInput input) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public <T> List<T> wrapList(Supplier<List<T>> supplier) { | ||
return List.of(); | ||
} | ||
|
||
@Override | ||
public <T> Optional<T> wrapOptional(Supplier<Optional<T>> supplier) { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public <T> Connection<T> wrapConnection(Supplier<Connection<T>> supplier) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public Mono<IPayload> wrapMono(Supplier<Mono<IPayload>> supplier, IInput input) { | ||
return Mono.empty(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/core/backend/sirius-components-graphql-utils/.mvn/wrapper/maven-wrapper.properties
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
packages/core/backend/sirius-components-graphql-utils/README.adoc
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...tarter/src/main/java/org/eclipse/sirius/components/starter/services/ExceptionWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 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 | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.starter.services; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.function.Supplier; | ||
|
||
import org.eclipse.sirius.components.core.api.IInput; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
import org.eclipse.sirius.components.graphql.api.IExceptionWrapper; | ||
|
||
import graphql.relay.Connection; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
|
||
/** | ||
* Used to encapsulate calls to methods which can throw exceptions. | ||
* | ||
* @author sbegaudeau | ||
*/ | ||
public class ExceptionWrapper implements IExceptionWrapper { | ||
|
||
@Override | ||
public Flux<IPayload> wrapFlux(Supplier<Flux<IPayload>> supplier, IInput input) { | ||
return supplier.get(); | ||
} | ||
|
||
@Override | ||
public IPayload wrap(Supplier<IPayload> supplier, IInput input) { | ||
return supplier.get(); | ||
} | ||
|
||
@Override | ||
public <T> List<T> wrapList(Supplier<List<T>> supplier) { | ||
return supplier.get(); | ||
} | ||
|
||
@Override | ||
public <T> Optional<T> wrapOptional(Supplier<Optional<T>> supplier) { | ||
return supplier.get(); | ||
} | ||
|
||
@Override | ||
public <T> Connection<T> wrapConnection(Supplier<Connection<T>> supplier) { | ||
return supplier.get(); | ||
} | ||
|
||
@Override | ||
public Mono<IPayload> wrapMono(Supplier<Mono<IPayload>> supplier, IInput input) { | ||
return supplier.get(); | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.