Hello everyone, we would appreciate some help with...
# graphql-kotlin
m
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?
l
i’ve hit this before, and this is how i solved it https://gist.github.com/lennyburdette/f3fe6ae7a498698774cc95d1bfc956b4
m
Thank you @Lenny Burdette. Your answer helped me find a workaround for us.
l
great! glad to hear it