Hello Prakash Vasant Holkar,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
The reason your WebGraphQlInterceptor
is not being invoked in the Azure spring Cloud Function App is because of many things, but majorly the cloud and traditional Spring Boot application architecture, Azure Functions Routing, Interceptor Registration, and Triggers.
I will advise you to start from your code: In your interceptor, try using Mono.defer
to ensure that the execution input is configured only when the request is being processed. For example:
@Override
public Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request, Chain chain) {
String value = request.getHeaders().getFirst("Authorization");
return Mono.defer(() -> {
request.configureExecutionInput((executionInput, builder) ->
builder.graphQLContext(Collections.singletonMap("Authorization", value)).build());
return chain.next(request);
});
}
Secondly, if your interceptor is in a package not scanned by Spring, it won’t be registered. You can explicitly specify the package to scan in your @SpringBootApplication
class using @ComponentScan
.
Thirdly, set up a Spring GraphQL function in Azure.
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class GraphQLController {
@GetMapping("/graphql")
public Mono<WebGraphQlResponse> handleGraphQL(WebGraphQlRequest request) {
// Logic to handle the request
}
}
Then, check your pom.xml or build.gradle to verify that the necessary Spring GraphQL libraries are included.
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.