public interface DgsQueryExecutor
The executeAnd* methods use the JsonPath library library to easily get specific fields out of a nested Json structure.
The executeAndGetDocumentContext(String) method sets up a DocumentContext, which can then be reused to get multiple fields.
| Modifier and Type | Method and Description |
|---|---|
default graphql.ExecutionResult |
execute(java.lang.String query) |
default graphql.ExecutionResult |
execute(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables) |
default graphql.ExecutionResult |
execute(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables,
java.util.Map<java.lang.String,java.lang.Object> extensions,
org.springframework.http.HttpHeaders headers) |
graphql.ExecutionResult |
execute(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables,
java.util.Map<java.lang.String,java.lang.Object> extensions,
org.springframework.http.HttpHeaders headers,
java.lang.String operationName,
org.springframework.web.context.request.WebRequest webRequest)
Executes a GraphQL query.
|
default graphql.ExecutionResult |
execute(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables,
java.lang.String operationName) |
default <T> T |
executeAndExtractJsonPath(java.lang.String query,
java.lang.String jsonPath)
Executes a GraphQL query, parses the returned data, and uses a Json Path to extract specific elements out of the data.
|
<T> T |
executeAndExtractJsonPath(java.lang.String query,
java.lang.String jsonPath,
org.springframework.http.HttpHeaders headers)
Executes a GraphQL query, parses the returned data, and uses a Json Path to extract specific elements out of the data.
|
<T> T |
executeAndExtractJsonPath(java.lang.String query,
java.lang.String jsonPath,
java.util.Map<java.lang.String,java.lang.Object> variables)
Executes a GraphQL query, parses the returned data, and uses a Json Path to extract specific elements out of the data.
|
<T> T |
executeAndExtractJsonPath(java.lang.String query,
java.lang.String jsonPath,
org.springframework.web.context.request.ServletWebRequest servletWebRequest)
Executes a GraphQL query, parses the returned data, and uses a Json Path to extract specific elements out of the data.
|
default <T> T |
executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
java.lang.Class<T> clazz)
Executes a GraphQL query, parses the returned data, extracts a value using JsonPath, and converts that value into the given type.
|
default <T> T |
executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
java.util.Map<java.lang.String,java.lang.Object> variables,
java.lang.Class<T> clazz)
Executes a GraphQL query, parses the returned data, extracts a value using JsonPath, and converts that value into the given type.
|
<T> T |
executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
java.util.Map<java.lang.String,java.lang.Object> variables,
java.lang.Class<T> clazz,
org.springframework.http.HttpHeaders headers)
Executes a GraphQL query, parses the returned data, extracts a value using JsonPath, and converts that value into the given type.
|
default <T> T |
executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
java.util.Map<java.lang.String,java.lang.Object> variables,
com.jayway.jsonpath.TypeRef<T> typeRef)
Executes a GraphQL query, parses the returned data, extracts a value using JsonPath, and converts that value into the given type.
|
<T> T |
executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
java.util.Map<java.lang.String,java.lang.Object> variables,
com.jayway.jsonpath.TypeRef<T> typeRef,
org.springframework.http.HttpHeaders headers)
Executes a GraphQL query, parses the returned data, extracts a value using JsonPath, and converts that value into the given type.
|
default <T> T |
executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
com.jayway.jsonpath.TypeRef<T> typeRef)
Executes a GraphQL query, parses the returned data, extracts a value using JsonPath, and converts that value into the given type.
|
default com.jayway.jsonpath.DocumentContext |
executeAndGetDocumentContext(java.lang.String query)
Executes a GraphQL query, parses the returned data, and return a
DocumentContext. |
com.jayway.jsonpath.DocumentContext |
executeAndGetDocumentContext(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables)
Executes a GraphQL query, parses the returned data, and return a
DocumentContext. |
com.jayway.jsonpath.DocumentContext |
executeAndGetDocumentContext(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables,
org.springframework.http.HttpHeaders headers)
Executes a GraphQL query, parses the returned data, and return a
DocumentContext. |
default graphql.ExecutionResult execute(java.lang.String query)
query - The query stringExecutionResult. This includes data and errors.default graphql.ExecutionResult execute(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables)
query - The query stringvariables - A map of variablesExecutionResult. This includes data and errors.default graphql.ExecutionResult execute(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables,
java.lang.String operationName)
query - The query stringvariables - A map of variablesoperationName - The operation nameExecutionResult. This includes data and errors.default graphql.ExecutionResult execute(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables,
java.util.Map<java.lang.String,java.lang.Object> extensions,
org.springframework.http.HttpHeaders headers)
query - The query stringvariables - A map of variablesextensions - A map representing GraphQL extensions.
This is made available in the DgsRequestData object on com.netflix.graphql.dgs.context.DgsContext}.ExecutionResult. This includes data and errors.graphql.ExecutionResult execute(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables,
java.util.Map<java.lang.String,java.lang.Object> extensions,
org.springframework.http.HttpHeaders headers,
java.lang.String operationName,
org.springframework.web.context.request.WebRequest webRequest)
query - The query stringvariables - A map of variablesextensions - A map representing GraphQL extensions. This is made available in the DgsRequestData object on DgsContext.headers - Request headers represented as a Spring Framework HttpHeadersoperationName - Operation namewebRequest - A Spring WebRequest giving access to request details. Can cast to an environment specific class such as ServletWebRequest.ExecutionResult. This includes data and errors.default <T> T executeAndExtractJsonPath(java.lang.String query,
java.lang.String jsonPath)
executeAndExtractJsonPathAsObject(String, String, TypeRef)instead.T - The type of primitive or map representation that should be returned.query - Query stringjsonPath - JsonPath expression.<T> T executeAndExtractJsonPath(java.lang.String query,
java.lang.String jsonPath,
java.util.Map<java.lang.String,java.lang.Object> variables)
Executes a GraphQL query, parses the returned data, and uses a Json Path to extract specific elements out of the data.
The method is generic, and tries to cast the result into the type you specify. This does NOT work on Lists. Use executeAndExtractJsonPathAsObject(String, String, TypeRef)instead.
This only works for primitive types and map representations.
Use executeAndExtractJsonPathAsObject(String, String, Class) for complex types and lists.*
T - The type of primitive or map representation that should be returned.query - Query stringjsonPath - JsonPath expression.variables - A Map of variables<T> T executeAndExtractJsonPath(java.lang.String query,
java.lang.String jsonPath,
org.springframework.http.HttpHeaders headers)
executeAndExtractJsonPathAsObject(String, String, TypeRef)instead.
This only works for primitive types and map representations.
Use executeAndExtractJsonPathAsObject(String, String, Class) for complex types and lists. *
T - The type of primitive or map representation that should be returned.query - Query stringjsonPath - JsonPath expression.headers - Spring HttpHeaders<T> T executeAndExtractJsonPath(java.lang.String query,
java.lang.String jsonPath,
org.springframework.web.context.request.ServletWebRequest servletWebRequest)
executeAndExtractJsonPathAsObject(String, String, TypeRef)instead.
This only works for primitive types and map representations.
Use executeAndExtractJsonPathAsObject(String, String, Class) for complex types and lists. *
T - The type of primitive or map representation that should be returned.query - Query stringjsonPath - JsonPath expression.servletWebRequest - Spring ServletWebRequestdefault com.jayway.jsonpath.DocumentContext executeAndGetDocumentContext(java.lang.String query)
DocumentContext.
A DocumentContext can be used to extract multiple values using JsonPath, without re-executing the query.query - Query stringDocumentContext is a JsonPath type used to extract values from.com.jayway.jsonpath.DocumentContext executeAndGetDocumentContext(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables)
DocumentContext.
A DocumentContext can be used to extract multiple values using JsonPath, without re-executing the query.query - Query stringvariables - A Map of variablesDocumentContext is a JsonPath type used to extract values from.com.jayway.jsonpath.DocumentContext executeAndGetDocumentContext(java.lang.String query,
java.util.Map<java.lang.String,java.lang.Object> variables,
org.springframework.http.HttpHeaders headers)
DocumentContext.
A DocumentContext can be used to extract multiple values using JsonPath, without re-executing the query.query - Query stringvariables - A Map of variablesheaders - Spring HttpHeadersDocumentContext is a JsonPath type used to extract values from.default <T> T executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
java.lang.Class<T> clazz)
T - The type that the extracted value should be converted to.query - Query stringjsonPath - JsonPath expression.clazz - The type to convert the extracted value to.default <T> T executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
java.util.Map<java.lang.String,java.lang.Object> variables,
java.lang.Class<T> clazz)
T - The type that the extracted value should be converted to.query - Query stringjsonPath - JsonPath expression.variables - A Map of variablesclazz - The type to convert the extracted value to.<T> T executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
java.util.Map<java.lang.String,java.lang.Object> variables,
java.lang.Class<T> clazz,
org.springframework.http.HttpHeaders headers)
T - The type that the extracted value should be converted to.query - Query stringjsonPath - JsonPath expression.variables - A Map of variablesclazz - The type to convert the extracted value to.headers - Request headers represented as a Spring Framework HttpHeadersdefault <T> T executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
com.jayway.jsonpath.TypeRef<T> typeRef)
TypeRef to specify the expected type, which is useful for Lists and Maps.
Be aware that this method can't guarantee type safety.T - The type that the extracted value should be converted to.query - Query stringjsonPath - JsonPath expression.typeRef - A JsonPath [TypeRef] representing the expected result type.default <T> T executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
java.util.Map<java.lang.String,java.lang.Object> variables,
com.jayway.jsonpath.TypeRef<T> typeRef)
TypeRef to specify the expected type, which is useful for Lists and Maps.
Be aware that this method can't guarantee type safety.T - The type that the extracted value should be converted to.query - Query stringjsonPath - JsonPath expression.variables - A Map of variablestypeRef - A JsonPath TypeRef representing the expected result type.<T> T executeAndExtractJsonPathAsObject(java.lang.String query,
java.lang.String jsonPath,
java.util.Map<java.lang.String,java.lang.Object> variables,
com.jayway.jsonpath.TypeRef<T> typeRef,
org.springframework.http.HttpHeaders headers)
TypeRef to specify the expected type, which is useful for Lists and Maps.
Be aware that this method can't guarantee type safety.T - The type that the extracted value should be converted to.query - Query stringjsonPath - JsonPath expression.variables - A Map of variablestypeRef - A JsonPath TypeRef representing the expected result type.headers - Request headers represented as a Spring Framework HttpHeaders