Class 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  
    • 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
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 class javax.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 class javax.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.