Hello everyone, we would appreciate some help with the problem below.
I am using expedia graphql-kotlin library and dataloaders approach in particular to resolve types, but I am stack on the mutation implementation. I want to use already defined data loader for returning the result type( i want to be able to return full object, not just the part which changed) , but I need to chain the mutation call to happen before resolving the type. Soomething like
Copy code
class ConsumerMutation(
private val mutateDefaultConsumerAddressUseCase: MutateDefaultConsumerAddress
) : Mutation {
@GraphQLDescription("Updates default consumer address.")
fun setDefaultConsumerAddress(env: DataFetchingEnvironment, addressId: String): CompletableFuture<Consumer>
return mutateDefaultConsumerAddressUseCase.setDefaultConsumerAddress(env.getContext(), addressId).flatMap {
//want to reuse ConsumerDataLoader for result fetching
env.getValueFromMonoDataLoaderWithContext(ConsumerDataLoader::class, addressId).toMono()
}.toFuture()
}
}
Do you have any suggestions on how to use dataLoaders inside mutations or is it even a right pattern?