-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from Netflix/spring-graphql-docs
Update docs with request/response interceptor.
- Loading branch information
Showing
4 changed files
with
29 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Response Instrumentation | ||
The DGS framework internally uses [GraphQL Java] and [Spring for GraphQL]. | ||
|
||
If you need to modify the HTTP request and response headers, you can leverage the `WebGraphQlInterceptor` in [Spring for GraphQL] (https://docs.spring.io/spring-graphql/reference/transports.html#server.interception) to accomplish this. | ||
This provides a hook to update the request and response headers based using the `GraphQLContext` | ||
|
||
#### Example: | ||
|
||
```java | ||
@Component | ||
public class MyInterceptor implements WebGraphQlInterceptor { | ||
@Override | ||
public Mono<WebGraphQlResponse> intercept(WebGraphQlRequest request, Chain chain) { | ||
String value = request.getHeaders().getFirst("myHeader"); | ||
request.configureExecutionInput((executionInput, builder) -> | ||
builder.graphQLContext(Collections.singletonMap("myHeader", value)).build()); | ||
return chain.next(request).doOnNext((response) -> { | ||
String value = response.getExecutionInput().getGraphQLContext().get("myContext"); | ||
response.getResponseHeaders().add("MyContext", value); | ||
}); | ||
} | ||
} | ||
``` |
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