-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into OmarAlJarrah/add-masking-feature
- Loading branch information
Showing
34 changed files
with
327 additions
and
327 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
94 changes: 94 additions & 0 deletions
94
code/src/main/kotlin/com/expediagroup/sdk/graphql/common/AbstractGraphQLExecutor.kt
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,94 @@ | ||
/* | ||
* Copyright (C) 2024 Expedia, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.expediagroup.sdk.graphql.common | ||
|
||
import com.apollographql.apollo.api.Mutation | ||
import com.apollographql.apollo.api.Query | ||
import com.apollographql.java.client.ApolloClient | ||
import com.expediagroup.sdk.core.client.Disposable | ||
import com.expediagroup.sdk.core.client.AbstractRequestExecutor | ||
import com.expediagroup.sdk.core.model.exception.service.ExpediaGroupServiceException | ||
import com.expediagroup.sdk.graphql.model.exception.NoDataException | ||
import com.expediagroup.sdk.graphql.model.response.RawResponse | ||
import java.util.concurrent.CompletableFuture | ||
|
||
/** | ||
* Abstract base class for executing GraphQL operations, providing a structure for executing queries and mutations | ||
* and returning the full response data along with any errors. | ||
* | ||
* This class is designed to handle the execution of GraphQL operations and return a [RawResponse] containing | ||
* the complete, unprocessed data and error details. Subclasses should implement specific behaviors for how | ||
* requests are sent and processed. | ||
*/ | ||
abstract class AbstractGraphQLExecutor( | ||
private val requestExecutor: AbstractRequestExecutor | ||
) : Disposable { | ||
|
||
/** | ||
* The Apollo Client instance used to perform GraphQL requests. | ||
* Subclasses must initialize this property with a configured [ApolloClient] instance. | ||
*/ | ||
protected abstract val apolloClient: ApolloClient | ||
|
||
/** | ||
* Executes a GraphQL query and returns the complete raw response. | ||
* | ||
* @param query The GraphQL query to be executed. | ||
* @return A [RawResponse] containing the full data and any errors from the query response. | ||
* @throws [ExpediaGroupServiceException] If an exception occurs during the execution of the query. | ||
* @throws [NoDataException] If the query completes without data but includes errors. | ||
*/ | ||
abstract fun <T : Query.Data> execute(query: Query<T>): RawResponse<T> | ||
|
||
/** | ||
* Executes a GraphQL mutation and returns the complete raw response. | ||
* | ||
* @param mutation The GraphQL mutation to be executed. | ||
* @return A [RawResponse] containing the full data and any errors from the mutation response. | ||
* @throws [ExpediaGroupServiceException] If an exception occurs during the execution of the mutation. | ||
* @throws [NoDataException] If the mutation completes without data but includes errors. | ||
*/ | ||
abstract fun <T : Mutation.Data> execute(mutation: Mutation<T>): RawResponse<T> | ||
|
||
/** | ||
* Asynchronously executes a GraphQL query and returns the complete raw response in a [CompletableFuture]. | ||
* | ||
* @param query The GraphQL query to be executed. | ||
* @return A [CompletableFuture] containing the full data and any errors from the query response wrapped in [RawResponse]. | ||
* @throws [ExpediaGroupServiceException] If an exception occurs during the execution of the query. | ||
* @throws [NoDataException] If the query completes without data but includes errors. | ||
*/ | ||
abstract fun <T : Query.Data> executeAsync(query: Query<T>): CompletableFuture<RawResponse<T>> | ||
|
||
/** | ||
* Asynchronously executes a GraphQL mutation and returns the complete raw response in a [CompletableFuture]. | ||
* | ||
* @param mutation The GraphQL mutation to be executed. | ||
* @return A [CompletableFuture] containing the full data and any errors from the mutation response wrapped in [RawResponse]. | ||
* @throws [ExpediaGroupServiceException] If an exception occurs during the execution of the mutation. | ||
* @throws [NoDataException] If the mutation completes without data but includes errors. | ||
*/ | ||
abstract fun <T : Mutation.Data> executeAsync(mutation: Mutation<T>): CompletableFuture<RawResponse<T>> | ||
|
||
/** | ||
* Closes the underlying [AbstractRequestExecutor] and [ApolloClient] | ||
*/ | ||
override fun dispose() { | ||
requestExecutor.dispose() | ||
apolloClient.close() | ||
} | ||
} |
170 changes: 0 additions & 170 deletions
170
code/src/main/kotlin/com/expediagroup/sdk/graphql/common/DefaultGraphQLExecutor.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.