Package io.smallrye.graphql.api
Interface Context
@Experimental("Request context to allow downstream operations to get insight into the request. Not covered by the specification. Subject to change.")
public interface Context
Holing context for the current request
There are two parts to this.The initial request, that can be a aggregation of requests, and the current execution context.
- Author:
- Phillip Kruger ([email protected])
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Help to parse the variables -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault <A> A
getArgument
(String name) Get the argument using a name This return the argument instance if it existsdefault <A> A
getArgumentOrDefault
(String name, A defaultValue) Same as above but with the option to do a default valueGet all the argumentsGet the execution ID.Get the field nameGet the operationName of the request.Return the current type (Query, Mutation ext) Current type means the type currently being executed.Return the type name of the parent (if any)getPath()
Return the current pathdefault String
getQuery()
Get the query part of the request.jakarta.json.JsonObject
Get the full body of the request.Return all the operation types requested (unique list) A Request can contain more than one operation.jakarta.json.JsonArray
Return the fields and source fields in the requestjakarta.json.JsonArray
Return the fields selected in the request<S> S
Get the variables of the request Could be null (not set)default <A> Boolean
hasArgument
(String name) Return true if the argument existdefault boolean
Check if the request contains an operation namedefault boolean
Check if there is a request setdefault boolean
default boolean
Check if the request contains variables<T> T
This leaky abstraction allows falling down to the underlying implementation
-
Field Details
-
QUERY
- See Also:
-
OPERATION_NAME
- See Also:
-
VARIABLES
- See Also:
-
-
Method Details
-
getRequest
jakarta.json.JsonObject getRequest()Get the full body of the request. This includes the query, variables and operation name- Returns:
- JsonObject
-
hasRequest
default boolean hasRequest()Check if there is a request set- Returns:
-
getQuery
Get the query part of the request. TODO: Consider creating a domain object for this (rather than String).- Returns:
- raw string query
-
getOperationName
Get the operationName of the request. Could be null (not set)- Returns:
- the operation name if set
-
hasOperationName
default boolean hasOperationName()Check if the request contains an operation name- Returns:
- true if it does
-
getVariables
Get the variables of the request Could be null (not set)- Returns:
-
hasVariables
default boolean hasVariables()Check if the request contains variables- Returns:
- true if it does
-
getExecutionId
String getExecutionId()Get the execution ID.- Returns:
- the ID as a String
-
getFieldName
String getFieldName()Get the field name- Returns:
- name of the field
-
hasArgument
Return true if the argument exist- Parameters:
name
- the argument name- Returns:
- true if there
-
getArgument
Get the argument using a name This return the argument instance if it exists- Parameters:
name
- key- Returns:
- argument value
-
getArgumentOrDefault
Same as above but with the option to do a default value- Parameters:
name
-defaultValue
-- Returns:
- the argument instance if it exists, else the provided default
-
getArguments
Get all the arguments- Returns:
- a map with name and instance of the argument
-
hasSource
default boolean hasSource() -
getSource
<S> S getSource() -
getPath
String getPath()Return the current path- Returns:
- the path as a String
-
getSelectedFields
jakarta.json.JsonArray getSelectedFields()Return the fields selected in the request- Returns:
- JsonArray of fields selected
-
getSelectedAndSourceFields
jakarta.json.JsonArray getSelectedAndSourceFields()Return the fields and source fields in the request- Returns:
- JsonArray of fields selected
-
getOperationType
String getOperationType()Return the current type (Query, Mutation ext) Current type means the type currently being executed.- Returns:
- name of the operation type
-
getRequestedOperationTypes
Return all the operation types requested (unique list) A Request can contain more than one operation. This will return a unique list of types. So if there is 2 Queries, it will only return one QUERY type, but if there is two queries and a mutation, it will return QUERY,MUTATION- Returns:
-
getParentTypeName
Return the type name of the parent (if any)- Returns:
- the parent type name maybe
-
unwrap
This leaky abstraction allows falling down to the underlying implementation- Type Parameters:
T
- the implementation class- Parameters:
wrappedType
- the class type of T- Returns:
- instance of the implementation class
-