graphql.servlet.GraphQLContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphql-java-servlet Show documentation
Show all versions of graphql-java-servlet Show documentation
relay.js-compatible GraphQL servlet
package graphql.servlet;
import org.dataloader.DataLoaderRegistry;
import javax.security.auth.Subject;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import javax.websocket.Session;
import javax.websocket.server.HandshakeRequest;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
public class GraphQLContext {
private HttpServletRequest httpServletRequest;
private HttpServletResponse httpServletResponse;
private Session session;
private HandshakeRequest handshakeRequest;
private Subject subject;
private Map> parts;
private DataLoaderRegistry dataLoaderRegistry;
public GraphQLContext(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Session session, HandshakeRequest handshakeRequest, Subject subject) {
this.httpServletRequest = httpServletRequest;
this.httpServletResponse = httpServletResponse;
this.session = session;
this.handshakeRequest = handshakeRequest;
this.subject = subject;
}
public GraphQLContext(HttpServletRequest httpServletRequest) {
this(httpServletRequest, null);
}
public GraphQLContext(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
this(httpServletRequest, httpServletResponse, null, null, null);
}
public GraphQLContext(Session session, HandshakeRequest handshakeRequest) {
this(null, null, session, handshakeRequest, null);
}
public GraphQLContext() {
this(null, null, null, null, null);
}
public Optional getHttpServletRequest() {
return Optional.ofNullable(httpServletRequest);
}
public Optional getHttpServletResponse() {
return Optional.ofNullable(httpServletResponse);
}
public Optional getSubject() {
return Optional.ofNullable(subject);
}
public Optional getSession() {
return Optional.ofNullable(session);
}
public Optional