/*
 * Copyright (c) 2017-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

package com.facebook.litho.sections.common;

import com.facebook.litho.annotations.Event;
import com.facebook.litho.sections.Children;

/**
 * An {@link Event} that gets triggered by a
 * {@link com.facebook.litho.sections.annotations.GroupSectionSpec} to render the section of the
 * {@link com.facebook.litho.sections.fb.datasources.GraphQLRootQuerySectionSpec} result.
 */
@Event(returnType = Children.class)
public class RenderSectionEvent {

  public enum FetchState {
    /**
     * GraphQLConnectionService is performing an initial fetch.
     * This will only happen once for the entire lifecycle of the GraphQLConnectionService.
     */
    INITIAL_STATE,

    /**
     * Data fetching on GraphQLConnectionService has started.
     */
    DOWNLOADING_STATE,

    /**
     * Data fetching has completed and the result is returned from GraphQLConnectionService.
     * Result can be empty.
     *
     * There could be an error with the latest fetch but has cached data available,
     * so the state will not be DOWNLOAD_ERROR.
     */
    IDLE_STATE,

    /**
     * Data fetching has failed to complete and there is an error.
     *
     * Data is always empty at this state.
     */
    DOWNLOAD_ERROR,
  }

  public Object model;
  public Object lastNonNullModel;
  public FetchState state;
  public Throwable error;
}

@@ -1521,16 +1521,270 @@
 R,%0A  %7D%0A%0A
+  public enum DataSource %7B%0A    /** Returned on Initial, Downloading, or Error states */%0A    UNSET,%0A    /** the data for the model came from the network */%0A    FROM_NETWORK,%0A    /** the data for the model came from the device */%0A    FROM_LOCAL_CACHE%0A  %7D%0A%0A
   public
@@ -1885,10 +1885,42 @@
  error;%0A
+  public DataSource dataSource;%0A
 %7D%0A

return data freshness from graqhQL queries