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.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault graphql.ExecutionResultdefault graphql.ExecutionResultdefault graphql.ExecutionResultdefault graphql.ExecutionResultexecute(String query, Map<String, Object> variables, Map<String, Object> extensions, org.springframework.http.HttpHeaders headers) graphql.ExecutionResultexecute(String query, Map<String, Object> variables, Map<String, Object> extensions, org.springframework.http.HttpHeaders headers, String operationName, org.springframework.web.context.request.WebRequest webRequest) Executes a GraphQL query.default <T> TexecuteAndExtractJsonPath(String query, String jsonPath) Executes a GraphQL query, parses the returned data, and uses a Json Path to extract specific elements out of the data.<T> TExecutes a GraphQL query, parses the returned data, and uses a Json Path to extract specific elements out of the data.<T> TexecuteAndExtractJsonPath(String query, 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> TexecuteAndExtractJsonPath(String query, 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> TexecuteAndExtractJsonPathAsObject(String query, 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 <T> TexecuteAndExtractJsonPathAsObject(String query, String jsonPath, 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> TexecuteAndExtractJsonPathAsObject(String query, String jsonPath, Map<String, 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> TexecuteAndExtractJsonPathAsObject(String query, String jsonPath, Map<String, 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> TexecuteAndExtractJsonPathAsObject(String query, String jsonPath, Map<String, Object> variables, 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> TexecuteAndExtractJsonPathAsObject(String query, String jsonPath, Map<String, Object> variables, 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 com.jayway.jsonpath.DocumentContextExecutes a GraphQL query, parses the returned data, and return aDocumentContext.com.jayway.jsonpath.DocumentContextexecuteAndGetDocumentContext(String query, Map<String, Object> variables) Executes a GraphQL query, parses the returned data, and return aDocumentContext.com.jayway.jsonpath.DocumentContextexecuteAndGetDocumentContext(String query, Map<String, Object> variables, org.springframework.http.HttpHeaders headers) Executes a GraphQL query, parses the returned data, and return aDocumentContext.
-
Method Details
-
execute
- Parameters:
query- The query string- Returns:
- Returns a GraphQL
ExecutionResult. This includes data and errors.
-
execute
default graphql.ExecutionResult execute(@Nullable String query, @NonNull Map<String, Object> variables) - Parameters:
query- The query stringvariables- A map of variables- Returns:
- Returns a GraphQL
ExecutionResult. This includes data and errors. - See Also:
-
execute
default graphql.ExecutionResult execute(@Nullable String query, @NonNull Map<String, Object> variables, @Nullable String operationName) - Parameters:
query- The query stringvariables- A map of variablesoperationName- The operation name- Returns:
- Returns a GraphQL
ExecutionResult. This includes data and errors. - See Also:
-
execute
default graphql.ExecutionResult execute(String query, @NonNull Map<String, Object> variables, @Nullable Map<String, Object> extensions, @Nullable org.springframework.http.HttpHeaders headers) - Parameters:
query- The query stringvariables- A map of variablesextensions- A map representing GraphQL extensions. This is made available in theDgsRequestDataobject on com.netflix.graphql.dgs.context.DgsContext}.- Returns:
- Returns a GraphQL
ExecutionResult. This includes data and errors. - See Also:
-
execute
graphql.ExecutionResult execute(String query, @NonNull Map<String, Object> variables, @Nullable Map<String, Object> extensions, @Nullable org.springframework.http.HttpHeaders headers, @Nullable String operationName, @Nullable org.springframework.web.context.request.WebRequest webRequest) Executes a GraphQL query. This method is used internally by all other methods in this interface.- Parameters:
query- The query stringvariables- A map of variablesextensions- A map representing GraphQL extensions. This is made available in theDgsRequestDataobject onDgsContext.headers- Request headers represented as a Spring FrameworkHttpHeadersoperationName- Operation namewebRequest- A SpringWebRequestgiving access to request details. Can cast to an environment specific class such asServletWebRequest.- Returns:
- Returns a GraphQL
ExecutionResult. This includes data and errors. - See Also:
-
executeAndExtractJsonPath
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. UseexecuteAndExtractJsonPathAsObject(String, String, TypeRef)instead.- Type Parameters:
T- The type of primitive or map representation that should be returned.- Parameters:
query- Query stringjsonPath- JsonPath expression.- Returns:
- The extracted value from the result, converted to type T
- See Also:
-
executeAndExtractJsonPath
<T> T executeAndExtractJsonPath(@NonNull String query, @NonNull String jsonPath, @NonNull Map<String, 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.*- Type Parameters:
T- The type of primitive or map representation that should be returned.- Parameters:
query- Query stringjsonPath- JsonPath expression.variables- A Map of variables- Returns:
- The extracted value from the result, converted to type T
- See Also:
-
executeAndExtractJsonPath
<T> T executeAndExtractJsonPath(@NonNull String query, @NonNull String jsonPath, @NonNull 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. The method is generic, and tries to cast the result into the type you specify. This does NOT work on Lists. UseexecuteAndExtractJsonPathAsObject(String, String, TypeRef)instead.This only works for primitive types and map representations. Use
executeAndExtractJsonPathAsObject(String, String, Class)for complex types and lists. *- Type Parameters:
T- The type of primitive or map representation that should be returned.- Parameters:
query- Query stringjsonPath- JsonPath expression.headers- SpringHttpHeaders- Returns:
- The extracted value from the result, converted to type T
- See Also:
-
executeAndExtractJsonPath
<T> T executeAndExtractJsonPath(@NonNull String query, @NonNull String jsonPath, @NonNull 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. The method is generic, and tries to cast the result into the type you specify. This does NOT work on Lists. UseexecuteAndExtractJsonPathAsObject(String, String, TypeRef)instead.This only works for primitive types and map representations. Use
executeAndExtractJsonPathAsObject(String, String, Class)for complex types and lists. *- Type Parameters:
T- The type of primitive or map representation that should be returned.- Parameters:
query- Query stringjsonPath- JsonPath expression.servletWebRequest- SpringServletWebRequest- Returns:
- The extracted value from the result, converted to type T
- See Also:
-
executeAndGetDocumentContext
Executes a GraphQL query, parses the returned data, and return aDocumentContext. ADocumentContextcan be used to extract multiple values using JsonPath, without re-executing the query.- Parameters:
query- Query string- Returns:
DocumentContextis a JsonPath type used to extract values from.
-
executeAndGetDocumentContext
com.jayway.jsonpath.DocumentContext executeAndGetDocumentContext(@NonNull String query, @NonNull Map<String, Object> variables) Executes a GraphQL query, parses the returned data, and return aDocumentContext. ADocumentContextcan be used to extract multiple values using JsonPath, without re-executing the query.- Parameters:
query- Query stringvariables- A Map of variables- Returns:
DocumentContextis a JsonPath type used to extract values from.- See Also:
-
executeAndGetDocumentContext
com.jayway.jsonpath.DocumentContext executeAndGetDocumentContext(@NonNull String query, @NonNull Map<String, Object> variables, @Nullable org.springframework.http.HttpHeaders headers) Executes a GraphQL query, parses the returned data, and return aDocumentContext. ADocumentContextcan be used to extract multiple values using JsonPath, without re-executing the query.- Parameters:
query- Query stringvariables- A Map of variablesheaders- SpringHttpHeaders- Returns:
DocumentContextis a JsonPath type used to extract values from.- See Also:
-
executeAndExtractJsonPathAsObject
default <T> T executeAndExtractJsonPathAsObject(@NonNull String query, @NonNull String jsonPath, @NonNull Class<T> clazz) Executes a GraphQL query, parses the returned data, extracts a value using JsonPath, and converts that value into the given type. Be aware that this method can't guarantee type safety.- Type Parameters:
T- The type that the extracted value should be converted to.- Parameters:
query- Query stringjsonPath- JsonPath expression.clazz- The type to convert the extracted value to.- Returns:
- The extracted value from the result, converted to type T
- See Also:
-
executeAndExtractJsonPathAsObject
default <T> T executeAndExtractJsonPathAsObject(@NonNull String query, @NonNull String jsonPath, @NonNull Map<String, Object> variables, @NonNull Class<T> clazz) Executes a GraphQL query, parses the returned data, extracts a value using JsonPath, and converts that value into the given type. Be aware that this method can't guarantee type safety.- Type Parameters:
T- The type that the extracted value should be converted to.- Parameters:
query- Query stringjsonPath- JsonPath expression.variables- A Map of variablesclazz- The type to convert the extracted value to.- Returns:
- The extracted value from the result, converted to type T
- See Also:
-
executeAndExtractJsonPathAsObject
<T> T executeAndExtractJsonPathAsObject(@NonNull String query, @NonNull String jsonPath, @NonNull Map<String, Object> variables, @NonNull Class<T> clazz, @Nullable 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. Be aware that this method can't guarantee type safety.- Type Parameters:
T- The type that the extracted value should be converted to.- Parameters:
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 FrameworkHttpHeaders- Returns:
- The extracted value from the result, converted to type T
- See Also:
-
executeAndExtractJsonPathAsObject
default <T> T executeAndExtractJsonPathAsObject(@NonNull String query, @NonNull String jsonPath, @NonNull 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. Uses aTypeRefto specify the expected type, which is useful for Lists and Maps. Be aware that this method can't guarantee type safety.- Type Parameters:
T- The type that the extracted value should be converted to.- Parameters:
query- Query stringjsonPath- JsonPath expression.typeRef- A JsonPath [TypeRef] representing the expected result type.- Returns:
- The extracted value from the result, converted to type T
- See Also:
-
executeAndExtractJsonPathAsObject
default <T> T executeAndExtractJsonPathAsObject(@NonNull String query, @NonNull String jsonPath, @NonNull Map<String, Object> variables, @NonNull 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. Uses aTypeRefto specify the expected type, which is useful for Lists and Maps. Be aware that this method can't guarantee type safety.- Type Parameters:
T- The type that the extracted value should be converted to.- Parameters:
query- Query stringjsonPath- JsonPath expression.variables- A Map of variablestypeRef- A JsonPathTypeRefrepresenting the expected result type.- Returns:
- The extracted value from the result, converted to type T
- See Also:
-
executeAndExtractJsonPathAsObject
<T> T executeAndExtractJsonPathAsObject(@NonNull String query, @NonNull String jsonPath, @NonNull Map<String, Object> variables, @NonNull com.jayway.jsonpath.TypeRef<T> typeRef, @Nullable 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. Uses aTypeRefto specify the expected type, which is useful for Lists and Maps. Be aware that this method can't guarantee type safety.- Type Parameters:
T- The type that the extracted value should be converted to.- Parameters:
query- Query stringjsonPath- JsonPath expression.variables- A Map of variablestypeRef- A JsonPathTypeRefrepresenting the expected result type.headers- Request headers represented as a Spring FrameworkHttpHeaders- Returns:
- The extracted value from the result, converted to type T
- See Also:
-