Skip to content

Commit 678682a

Browse files
authored
Update README.md
1 parent 53e2bdd commit 678682a

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,42 @@ GraphQLServlet servlet = new SimpleGraphQLServlet(schema, executionStrategy);
4343
GraphQLServlet servlet = new SimpleGraphQLServlet(schema, executionStrategy, operationListeners);
4444
```
4545

46-
You can also add [listeners](https://github.com/graphql-java/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/GraphQLOperationListener.java) to an existing servlet.
46+
You can also add [operation listeners](https://github.com/graphql-java/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/GraphQLOperationListener.java) and [servlet listeners](https://github.com/graphql-java/graphql-java-servlet/blob/master/src/main/java/graphql/servlet/GraphQLServletListener.java) to an existing servlet.
4747
These listeners provide hooks into query execution - before, on success, and on failure:
4848
```java
4949
servlet.addOperationListener(new GraphQLOperationListener() {
5050
@Override
51-
public void beforeGraphQLOperation(GraphQLContext context, String operationName, String query, Map<String, Object> variables) {
51+
void beforeGraphQLOperation(GraphQLContext context, String operationName, String query, Map<String, Object> variables) {
5252

5353
}
5454

5555
@Override
56-
public void onSuccessfulGraphQLOperation(GraphQLContext context, String operationName, String query, Map<String, Object> variables, Object data) {
56+
void onSuccessfulGraphQLOperation(GraphQLContext context, String operationName, String query, Map<String, Object> variables, Object data) {
5757

5858
}
5959

6060
@Override
61-
public void onFailedGraphQLOperation(GraphQLContext context, String operationName, String query, Map<String, Object> variables, List<GraphQLError> errors) {
61+
void onFailedGraphQLOperation(GraphQLContext context, String operationName, String query, Map<String, Object> variables, Object data, List<GraphQLError> errors) {
6262

6363
}
64-
});
64+
})
65+
66+
servlet.addServletListener(new GraphQLServletListener() {
67+
@Override
68+
void onStart(HttpServletRequest request, HttpServletResponse response) {
69+
70+
}
71+
72+
@Override
73+
void onError(HttpServletRequest request, HttpServletResponse response, Throwable throwable) {
74+
75+
}
76+
77+
@Override
78+
void onFinally(HttpServletRequest request, HttpServletResponse response) {
79+
80+
}
81+
})
6582
```
6683

6784
## Relay.js support

0 commit comments

Comments
 (0)