How to use the react-apollo.compose function in react-apollo

To help you get started, we’ve selected a few react-apollo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github demokratie-live / democracy-client / src / screens / Search / index.js View on Github external
mostSearchedTerms: PropTypes.arrayOf(PropTypes.shape()),
  searchTerm: PropTypes.string.isRequired,
  addToSearchHistory: PropTypes.func.isRequired,
  searchHistory: PropTypes.arrayOf(PropTypes.string),
  client: PropTypes.instanceOf(ApolloClient).isRequired,
};

SearchScreen.defaultProps = {
  navigator: undefined,
  mostSearchedTerms: [],
  searchHistory: [],
};

export default withApollo(
  preventNavStackDuplicate(
    compose(
      // Queries
      graphql(mostSearched, {
        props: ({ data: { mostSearched: mostSearchedTerms, refetch: refetchMostSearched } }) => ({
          mostSearchedTerms,
          refetchMostSearched,
        }),
        options: () => ({
          fetchPolicy: 'cache-and-network',
        }),
      }),

      graphql(SEARCH_TERM, {
        props: ({ data: { searchTerm: searchTermData } }) =>
          searchTermData ? { searchTerm: searchTermData.term } : { searchTerm: '' },
      }),
      graphql(SEARCH_HISTORY, {
github assembl / assembl / assembl / static2 / js / app / pages / syntheses.jsx View on Github external
) : null}
          
        
      
    );
  }
}

const mapStateToProps = state => ({
  lang: state.i18n.locale,
  slug: state.debate.debateData.slug
});

export default compose(
  connect(mapStateToProps),
  graphql(SynthesesQuery, {
    props: ({ data }) => {
      if (data.error || data.loading) {
        return {
          error: data.error,
          loading: data.loading
        };
      }

      return {
        error: data.error,
        loading: data.loading,
        syntheses: data.syntheses,
        hasSyntheses: data && data.syntheses ? data.syntheses.length > 0 : false
      };
github Skjutsgruppen / skjutsgruppen-reactnative / app / screens / Route.js View on Github external
right: 20,
    backgroundColor: Colors.background.fullWhite,
    elevation: 2,
    zIndex: 200,
    overflow: 'hidden',
  },
  myLocationIcon: {
    width: 48,
    height: 48,
    borderRadius: 24,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

const ShareLocationWithData = compose(withStopSpecific, withGroupParticipantIds)(ShareLocation);

class RouteMap extends PureComponent {
  static navigationOptions = {
    header: null,
  };

  constructor(props) {
    super(props);
    this.mapView = null;
    this.state = ({
      myLocationIconBottom: 20,
      showTurnOnGpsModal: false,
      fetchingPosition: false,
      initialRegion: {
        longitude: 0,
        latitude: 0,
github replicatedhq / kots / web / src / components / apps / AppConfig.jsx View on Github external
}
              <div>
                <button type="button">Continue editing</button>
                
                  <button type="button">{isNewVersion ? "Go to new version" : "Go to updated version"}</button>
                
              </div>
            
          }
        
      
    )
  }
}

export default withRouter(compose(
  withApollo,
  withRouter,
  graphql(getAppConfigGroups, {
    name: "getAppConfigGroups",
    options: ({ match, app, fromLicenseFlow }) =&gt; {
      let sequence;
      if (fromLicenseFlow) {
        sequence = 0;
      } else if (match.params.sequence != undefined) {
        sequence = match.params.sequence;
      } else {
        sequence = app.currentSequence;
      }
      const slug = fromLicenseFlow ? match.params.slug : app.slug;
      return {
        variables: {
github erxes / erxes / src / modules / deals / containers / deal / DealAddForm.js View on Github external
const extendedProps = {
    ...props,
    boardId: board ? board._id : null
  };

  return ;
};

const propTypes = {
  boardGetDefaultQuery: PropTypes.object
};

DealAddFormContainer.propTypes = propTypes;

export default compose(
  graphql(gql(queries.boardGetDefault), {
    name: 'boardGetDefaultQuery'
  })
)(DealAddFormContainer);
github orbiting / republik-frontend / components / Article / PayNote.js View on Github external
)
})

const PayNoteCta = ({ variation, payload, position, darkMode }) =&gt; {
  return (
    <div>
      {variation.cta === 'try' ? (
        
      ) : (
        
      )}
    </div>
  )
}

export const PayNote = compose(
  withRouter,
  withInNativeApp,
  withMemberStatus
)(
  ({
    router: { query },
    inNativeIOSApp,
    isEligibleForTrial,
    seed,
    trial,
    documentId,
    repoId,
    series,
    position
  }) =&gt; {
    const variation = getPayNoteVariation({
github artsmia / lume / components / cms / ContentEditor / index.js View on Github external
import {compose} from 'react-apollo'
import Component from './ContentEditor.component.js'
import query from '../../../apollo/queries/content'
import mutation from '../../../apollo/mutations/editContent'

export default compose(query, mutation)(Component)
github orbiting / republik-frontend / pages / discussion.js View on Github external
import Frame from '../components/Frame'
import Discussion from '../components/Discussion/Discussion'
import DiscussionIndex from '../components/Discussion/DiscussionIndex'

const DiscussionPage = ({ router: { query } }) =&gt; (
  
    {query.id
      ? 
      : }
  
)

export default compose(withRouter)(DiscussionPage)
github aws-samples / aws-mobile-appsync-events-starter-react-native / App.js View on Github external
})
      }
    }),
    options: {
      refetchQueries: [{ query: ListEvents }],
      update: (dataProxy, { data: { deleteEvent: { id } } }) => {
        const query = ListEvents;
        const data = dataProxy.readQuery({ query });
        data.listEvents.items = data.listEvents.items.filter(event => event.id !== id);
        dataProxy.writeQuery({ query, data });
      }
    }
  }),
)(AllEvents);

const AddEventData = compose(
  graphql(CreateEvent, {
    options: {
      refetchQueries: [{ query: ListEvents }],
      update: (dataProxy, { data: { createEvent } }) => {
        const query = ListEvents;
        const data = dataProxy.readQuery({ query });
        data.listEvents = {
          ...data.listEvents,
          items: [
            ...data.listEvents.items,
            createEvent
          ]
        }
        dataProxy.writeQuery({ query, data });
      }
    },
github artsmia / lume / app / old / oldCms / EditObj / index.js View on Github external
variables: {
      objId,
      userId,
      subdomain,
      thematicFilter: {
        limit: 10,
      }
    }
  })
}

let EditObj = graphql(editOrCreateDetail, {
  name: "editDetail",
})(Component)

export default compose(
  graphql(query, queryOptions),
  graphql(editOrCreateObj, {
    name: "editObj",
  }),
  graphql(deleteObj, {
    name: "deleteObj",
  }),
)(
  EditObj
)