Class ApolloClient

    • Method Detail

      • mutate

        public <D extends com.apollographql.apollo.api.Operation.Data,​T,​V extends com.apollographql.apollo.api.Operation.Variables> ApolloMutationCall<T> mutate​(@NotNull
                                                                                                                                                                             com.apollographql.apollo.api.Mutation<D,​T,​V> mutation)
        Description copied from interface: ApolloMutationCall.Factory
        Creates and prepares a new ApolloMutationCall call.
        Specified by:
        mutate in interface ApolloMutationCall.Factory
        Parameters:
        mutation - the Mutation which needs to be performed
        Returns:
        prepared ApolloMutationCall call to be executed at some point in the future
      • mutate

        public <D extends com.apollographql.apollo.api.Operation.Data,​T,​V extends com.apollographql.apollo.api.Operation.Variables> ApolloMutationCall<T> mutate​(@NotNull
                                                                                                                                                                             com.apollographql.apollo.api.Mutation<D,​T,​V> mutation,
                                                                                                                                                                             @NotNull
                                                                                                                                                                             D withOptimisticUpdates)
        Description copied from interface: ApolloMutationCall.Factory

        Creates and prepares a new ApolloMutationCall call with optimistic updates.

        Provided optimistic updates will be stored in ApolloStore immediately before mutation execution. Any ApolloQueryWatcher dependent on the changed cache records will be re-fetched.
        Specified by:
        mutate in interface ApolloMutationCall.Factory
        Parameters:
        mutation - the Mutation which needs to be performed
        withOptimisticUpdates - optimistic updates for this mutation
        Returns:
        prepared ApolloMutationCall call to be executed at some point in the future
      • query

        public <D extends com.apollographql.apollo.api.Operation.Data,​T,​V extends com.apollographql.apollo.api.Operation.Variables> ApolloQueryCall<T> query​(@NotNull
                                                                                                                                                                         com.apollographql.apollo.api.Query<D,​T,​V> query)
        Description copied from interface: ApolloQueryCall.Factory
        Creates and prepares a new ApolloQueryCall call.
        Specified by:
        query in interface ApolloQueryCall.Factory
        Parameters:
        query - the operation which needs to be performed
        Returns:
        prepared ApolloQueryCall call to be executed at some point in the future
      • prefetch

        public <D extends com.apollographql.apollo.api.Operation.Data,​T,​V extends com.apollographql.apollo.api.Operation.Variables> ApolloPrefetch prefetch​(@NotNull
                                                                                                                                                                        com.apollographql.apollo.api.Operation<D,​T,​V> operation)
        Description copied from interface: ApolloPrefetch.Factory
        Creates the ApolloPrefetch by wrapping the operation object inside.
        Specified by:
        prefetch in interface ApolloPrefetch.Factory
        Parameters:
        operation - the operation which needs to be performed
        Returns:
        The ApolloPrefetch object with the wrapped operation object
      • addOnSubscriptionManagerStateChangeListener

        public void addOnSubscriptionManagerStateChangeListener​(@NotNull
                                                                OnSubscriptionManagerStateChangeListener onStateChangeListener)
        Adds new listener for subscription manager state changes.
        Parameters:
        onStateChangeListener - to be called when state changed
      • removeOnSubscriptionManagerStateChangeListener

        public void removeOnSubscriptionManagerStateChangeListener​(@NotNull
                                                                   OnSubscriptionManagerStateChangeListener onStateChangeListener)
        Removes listener for subscription manager state changes.
        Parameters:
        onStateChangeListener - to remove
      • getSubscriptionManagerState

        public SubscriptionManagerState getSubscriptionManagerState()
        Returns the current state of subscription manager.
        Returns:
        current state
      • enableSubscriptions

        public void enableSubscriptions()
        Call start on the subscriptionManager. Which will put the subscriptionManager in a connectible state if its current state is STOPPED. This is a noop if the current state is anything other than STOPPED.

        When subscriptions are re-enabled after having been disabled, the underlying transport isn't reconnected immediately, but will be on the first new subscription created.

      • disableSubscriptions

        public void disableSubscriptions()
        Call stop on the subscriptionManager. Which will unsubscribe from all active subscriptions, disconnect the underlying transport (eg websocket), and put the subscriptionManager in the STOPPED state.

        New subscriptions will fail until enableSubscriptions() is called.

      • defaultCacheHeaders

        @Deprecated
        public com.apollographql.apollo.cache.CacheHeaders defaultCacheHeaders()
        Deprecated.
        Use getDefaultCacheHeaders() instead
        Returns:
        The default CacheHeaders which this instance of ApolloClient was configured.
      • getDefaultCacheHeaders

        public com.apollographql.apollo.cache.CacheHeaders getDefaultCacheHeaders()
        Returns:
        The default CacheHeaders which this instance of ApolloClient was configured.
      • clearHttpCache

        public void clearHttpCache()
        Clear all entries from the HttpCache, if present.
      • clearNormalizedCache

        public void clearNormalizedCache​(@NotNull
                                         com.apollographql.apollo.cache.normalized.ApolloStoreOperation.Callback<java.lang.Boolean> callback)
        Clear all entries from the normalized cache. This is asynchronous operation and will be scheduled on the dispatcher
        Parameters:
        callback - to be notified when operation is completed
      • clearNormalizedCache

        public boolean clearNormalizedCache()
        Clear all entries from the normalized cache. This is synchronous operation and will be executed int the current thread
        Returns:
        true if operation succeed, false otherwise
      • getServerUrl

        public okhttp3.HttpUrl getServerUrl()
        Returns:
        The HttpUrl serverUrl
      • getHttpCache

        public com.apollographql.apollo.api.cache.http.HttpCache getHttpCache()
        Returns:
        The HttpCache httpCache
      • getScalarTypeAdapters

        public com.apollographql.apollo.api.ScalarTypeAdapters getScalarTypeAdapters()
        Returns:
        The ScalarTypeAdapters scalarTypeAdapters
      • getApplicationInterceptorFactories

        public java.util.List<com.apollographql.apollo.interceptor.ApolloInterceptorFactory> getApplicationInterceptorFactories()
        Returns:
        The list of ApolloInterceptorFactory
      • getAutoPersistedOperationsInterceptorFactory

        public com.apollographql.apollo.interceptor.ApolloInterceptorFactory getAutoPersistedOperationsInterceptorFactory()
        Returns:
        The ApolloInterceptor used for auto persisted operations
      • idleCallback

        public void idleCallback​(IdleResourceCallback idleResourceCallback)
        Sets the idleResourceCallback which will be called when this ApolloClient is idle.
      • activeCallsCount

        public int activeCallsCount()
        Returns the count of ApolloCall & ApolloPrefetch objects which are currently in progress.