Package net.morimekta.providence.graphql
Class GQLContext
- java.lang.Object
-
- net.morimekta.providence.graphql.GQLContext
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public abstract class GQLContext extends java.lang.Object implements java.lang.AutoCloseable
The GQL context is created once per query method call, and once for the whole operation for mutations. Note thatGQLServlet
can be updated to handle queries serially as mutations if need be.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GQLContext(javax.servlet.http.HttpServletRequest request, GQLOperation operation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort(java.lang.Exception ex)
Implement if a failed context session ends in failure, e.g. update failure.void
commit()
Implement if a successful request is passed, and e.g. a transaction needs to be committed (instead of aborted).GQLOperation
getOperation()
javax.servlet.http.HttpServletRequest
getRequest()
-
-
-
Constructor Detail
-
GQLContext
protected GQLContext(@Nonnull javax.servlet.http.HttpServletRequest request, @Nonnull GQLOperation operation)
-
-
Method Detail
-
getRequest
public javax.servlet.http.HttpServletRequest getRequest()
- Returns:
- The HTTP request that initiated the GQL operation.
-
getOperation
public GQLOperation getOperation()
- Returns:
- The GQL operation to be handled.
-
commit
public void commit() throws java.lang.Exception
Implement if a successful request is passed, and e.g. a transaction needs to be committed (instead of aborted). This method is called when the last method call has passed for the context. It will be called before close.- Throws:
java.lang.Exception
- If committing failed.
-
abort
public void abort(java.lang.Exception ex) throws java.lang.Exception
Implement if a failed context session ends in failure, e.g. update failure. This can be used to trigger transaction abort procedure etc. This will also trigger ifcommit()
throws exception.- Parameters:
ex
- The exception causing the abort.- Throws:
java.lang.Exception
- If the abort procedure failed.
-
-