Interface QueryExecutor


@ProviderType public interface QueryExecutor
A QueryExecutor service allows consumers to validate and execute GraphQL queries directly.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Map<String,Object>
    execute(@NotNull String query, @NotNull Map<String,Object> variables, @NotNull org.apache.sling.api.resource.Resource queryResource, @NotNull String[] selectors)
    Executes the passed query.
    validate(@NotNull String query, @NotNull Map<String,Object> variables, @NotNull org.apache.sling.api.resource.Resource queryResource, @NotNull String[] selectors)
    Validates the passed query and variables, by checking if the query obeys the known schemas.
  • Method Details

    • validate

      ValidationResult validate(@NotNull @NotNull String query, @NotNull @NotNull Map<String,Object> variables, @NotNull @NotNull org.apache.sling.api.resource.Resource queryResource, @NotNull @NotNull String[] selectors)
      Validates the passed query and variables, by checking if the query obeys the known schemas.
      Parameters:
      query - the query
      variables - the query's variables; can be an empty Map if the query doesn't accept variables
      queryResource - the current resource, used as the root for the query
      selectors - potential selectors used to select the schema applicable to the passed query
      Returns:
      {code true} if the query is valid, false otherwise
    • execute

      @NotNull @NotNull Map<String,Object> execute(@NotNull @NotNull String query, @NotNull @NotNull Map<String,Object> variables, @NotNull @NotNull org.apache.sling.api.resource.Resource queryResource, @NotNull @NotNull String[] selectors)
      Executes the passed query.
      Parameters:
      query - the query
      variables - the query's variables; can be an empty Map if the query doesn't accept variables
      queryResource - the current resource, used as the root for the query
      selectors - potential selectors used to select the schema applicable to the passed query
      Returns:
      a Map representing the query's result
      Throws:
      SlingGraphQLException - if the execution of the query leads to any issues