Package net.morimekta.providence.graphql
Class GQLServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- net.morimekta.providence.graphql.GQLServlet
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class GQLServlet extends javax.servlet.http.HttpServlet
A servlet for serving graphql given a GQL service and associated providers. Spec for serving GraphQL over HTTP can be found here.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONTENT_TYPE
static java.lang.String
MEDIA_TYPE
-
Constructor Summary
Constructors Constructor Description GQLServlet(GQLDefinition definition, GQLProcessorProvider queryProvider, GQLProcessorProvider mutationProvider, java.util.Collection<GQLFieldProvider> fieldProviders, GQLContextFactory contextFactory, java.util.concurrent.ExecutorService executorService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
Only non-mutation GQL queries may be handed to a get request, putting the actual query in the query= parameter.protected void
doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
Both normal GQL queries and mutations may be posted.protected void
handleOperation(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, GQLOperation operation, boolean handleSerially)
Handle operation.-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
-
-
-
-
Field Detail
-
CONTENT_TYPE
public static final java.lang.String CONTENT_TYPE
- See Also:
- Constant Field Values
-
MEDIA_TYPE
public static final java.lang.String MEDIA_TYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GQLServlet
public GQLServlet(@Nonnull GQLDefinition definition, @Nonnull GQLProcessorProvider queryProvider, @Nullable GQLProcessorProvider mutationProvider, @Nonnull java.util.Collection<GQLFieldProvider> fieldProviders, @Nullable GQLContextFactory contextFactory, @Nonnull java.util.concurrent.ExecutorService executorService)
-
-
Method Detail
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException
Only non-mutation GQL queries may be handed to a get request, putting the actual query in the query= parameter.- Overrides:
doGet
in classjavax.servlet.http.HttpServlet
- Parameters:
req
- The HTTP request.resp
- The HTTP response.- Throws:
java.io.IOException
-
doPost
protected void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException
Both normal GQL queries and mutations may be posted. The- Overrides:
doPost
in classjavax.servlet.http.HttpServlet
- Parameters:
req
- The HTTP request.resp
- The HTTP response.- Throws:
java.io.IOException
-
handleOperation
@OverridingMethodsMustInvokeSuper protected void handleOperation(@Nonnull javax.servlet.http.HttpServletRequest req, @Nonnull javax.servlet.http.HttpServletResponse resp, @Nonnull GQLOperation operation, boolean handleSerially) throws java.io.IOException
Handle operation.- Parameters:
req
- The HTTP request.resp
- The HTTP response.operation
- The operation to be done.handleSerially
- If the operation should be handled serially. If true will create a single context and handle all method calls after one another and stop on first error. If false will spawn one thread per method call, and write a data response or error separately for each call.- Throws:
java.io.IOException
- If operation handle failed.
-
-