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.AutoCloseableThe GQL context is created once per query method call, and once for the whole operation for mutations. Note thatGQLServletcan be updated to handle queries serially as mutations if need be.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedGQLContext(javax.servlet.http.HttpServletRequest request, GQLOperation operation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort(java.lang.Exception ex)Implement if a failed context session ends in failure, e.g. update failure.voidcommit()Implement if a successful request is passed, and e.g. a transaction needs to be committed (instead of aborted).GQLOperationgetOperation()javax.servlet.http.HttpServletRequestgetRequest()
-
-
-
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.ExceptionImplement 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.ExceptionImplement 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.
-
-