Interface GGClient


  • public interface GGClient
    Instances can be used for communicating with the smash.gg GraphQL API. Rate limits can be configured and will be handled automatically.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  GGClient.Builder
      Used for building instances of GGClient.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      static GGClient.Builder builder​(java.lang.String token)
      For creating instances of GGClient.
      boolean isShutDown()
      Whether the client is already shut down
      default java.util.concurrent.CompletableFuture<GGResponse<MutationResponse>> mutation​(java.lang.String query)
      Performs a mutation request with the given query to the GraphQL API.
      java.util.concurrent.CompletableFuture<GGResponse<MutationResponse>> mutation​(java.lang.String query, com.google.gson.JsonObject variables)
      Performs a mutation request with the given query and variables to the GraphQL API.
      default java.util.concurrent.CompletableFuture<GGResponse<QueryResponse>> query​(java.lang.String query)
      Performs a query request with the given query to the GraphQL API.
      java.util.concurrent.CompletableFuture<GGResponse<QueryResponse>> query​(java.lang.String query, com.google.gson.JsonObject variables)
      Performs a query request with the given query and variables to the GraphQL API.
      default java.util.concurrent.CompletableFuture<com.google.gson.JsonObject> request​(java.lang.String query)
      Performs a request with the given query to the GraphQL API.
      java.util.concurrent.CompletableFuture<com.google.gson.JsonObject> request​(java.lang.String query, com.google.gson.JsonObject variables)
      Performs a request with the given query and variables to the GraphQL API.
      java.util.concurrent.CompletableFuture<java.lang.Void> shutdown()
      Shuts down the client gracefully.
    • Method Detail

      • request

        @Nonnull
        java.util.concurrent.CompletableFuture<com.google.gson.JsonObject> request​(@Nonnull
                                                                                   java.lang.String query,
                                                                                   @Nullable
                                                                                   com.google.gson.JsonObject variables)
        Performs a request with the given query and variables to the GraphQL API.

        The returned CompletableFuture will be completed with the response on the requester thread. If you don't use async methods and block, no requests will be sent during execution of your code. If you block until a request is complete in a not-async callback, you will deadlock.

        Parameters:
        query - the GraphQL query
        variables - the variable assignments as a JsonObject of format {"variable1":"value1", "variable2":"value2" ...}
        Returns:
        a CompletableFuture that will be completed with the JsonObject of the response of the format {"data": {...}} or will be completed exceptionally if the request fails with a non-normal response code
        Throws:
        java.lang.IllegalArgumentException - if query or variables is null
        java.lang.IllegalStateException - if the client is already shut down
      • request

        @Nonnull
        default java.util.concurrent.CompletableFuture<com.google.gson.JsonObject> request​(@Nonnull
                                                                                           java.lang.String query)
        Performs a request with the given query to the GraphQL API. Generally query(String) or mutation(String) are preferred, but if you need the raw JsonObject response, you can use this method.

        The returned CompletableFuture will be completed with the response on the requester thread. If you don't use async methods and block, no requests will be sent during execution of your code. If you block until a request is complete in a not-async callback, you will deadlock.

        Parameters:
        query - the GraphQL query
        Returns:
        a CompletableFuture that will be completed with the JsonObject of the response of the format {"data": {...}} or will be completed exceptionally if the request fails with a non-normal response code
        Throws:
        java.lang.IllegalArgumentException - if query is null
        java.lang.IllegalStateException - if the client is already shut down
      • query

        @Nonnull
        java.util.concurrent.CompletableFuture<GGResponse<QueryResponse>> query​(@Nonnull
                                                                                java.lang.String query,
                                                                                @Nullable
                                                                                com.google.gson.JsonObject variables)
        Performs a query request with the given query and variables to the GraphQL API.

        The returned CompletableFuture will be completed with the response on the requester thread. If you don't use async methods and block, no requests will be sent during execution of your code. If you block until a request is complete in a not-async callback, you will deadlock.

        Parameters:
        query - the GraphQL query
        variables - the variable assignments as a JsonObject of format {"variable1":"value1", "variable2":"value2" ...}
        Returns:
        a CompletableFuture that will be completed with the GGResponse of the response or will be completed exceptionally if the request fails with a non-normal response code or deserialization fails
        Throws:
        java.lang.IllegalArgumentException - if query is null
        java.lang.IllegalStateException - if the client is already shut down
      • query

        @Nonnull
        default java.util.concurrent.CompletableFuture<GGResponse<QueryResponse>> query​(@Nonnull
                                                                                        java.lang.String query)
        Performs a query request with the given query to the GraphQL API.

        The returned CompletableFuture will be completed with the response on the requester thread. If you don't use async methods and block, no requests will be sent during execution of your code. If you block until a request is complete in a not-async callback, you will deadlock.

        Parameters:
        query - the GraphQL query
        Returns:
        a CompletableFuture that will be completed with the QueryResponse of the response or will be completed exceptionally if the request fails with a non-normal response code or deserialization fails
        Throws:
        java.lang.IllegalArgumentException - if query is null
        java.lang.IllegalStateException - if the client is already shut down
      • mutation

        @Nonnull
        java.util.concurrent.CompletableFuture<GGResponse<MutationResponse>> mutation​(@Nonnull
                                                                                      java.lang.String query,
                                                                                      @Nullable
                                                                                      com.google.gson.JsonObject variables)
        Performs a mutation request with the given query and variables to the GraphQL API.

        The returned CompletableFuture will be completed with the response on the requester thread. If you don't use async methods and block, no requests will be sent during execution of your code. If you block until a request is complete in a not-async callback, you will deadlock.

        Parameters:
        query - the GraphQL query
        variables - the variable assignments as a JsonObject of format {"variable1":"value1", "variable2":"value2" ...}
        Returns:
        a CompletableFuture that will be completed with the MutationResponse of the response or will be completed exceptionally if the request fails with a non-normal response code or deserialization fails
        Throws:
        java.lang.IllegalArgumentException - if query is null
        java.lang.IllegalStateException - if the client is already shut down
      • mutation

        @Nonnull
        default java.util.concurrent.CompletableFuture<GGResponse<MutationResponse>> mutation​(@Nonnull
                                                                                              java.lang.String query)
        Performs a mutation request with the given query to the GraphQL API.

        The returned CompletableFuture will be completed with the response on the requester thread. If you don't use async methods and block, no requests will be sent during execution of your code. If you block until a request is complete in a not-async callback, you will deadlock.

        Parameters:
        query - the GraphQL query
        Returns:
        a CompletableFuture that will be completed with the MutationResponse of the response or will be completed exceptionally if the request fails with a non-normal response code or deserialization fails
        Throws:
        java.lang.IllegalArgumentException - if query is null
        java.lang.IllegalStateException - if the client is already shut down
      • shutdown

        @Nonnull
        java.util.concurrent.CompletableFuture<java.lang.Void> shutdown()
        Shuts down the client gracefully. Already enqueued requests will still be executed.
        Returns:
        a CompletableFuture that will be completed once the shutdown is completed
      • isShutDown

        boolean isShutDown()
        Whether the client is already shut down
        Returns:
        true if the client is shut down
      • builder

        @Nonnull
        static GGClient.Builder builder​(@Nonnull
                                        java.lang.String token)
        For creating instances of GGClient.
        Returns:
        a new Builder for building a GGClient
        Throws:
        java.lang.IllegalArgumentException - if token is null or empty