graphql(createUserGql, { props: ({ mutate }) => ({ mutations: { signUp: ({ firstName, lastName, email, password }) => mutate({ variables: { firstName, lastName, email, password } }) } }) })
graphql(allPostsGql, { options: () => ({ variables: { skip: 0, first: POSTS_PER_PAGE } }), props: ({ data }) => ({ data, loadMorePosts: () => data.fetchMore({ variables: { skip: data.allPosts.length }, updateQuery: (previousResult, { fetchMoreResult }) => { if (!fetchMoreResult) { return previousResult; } return Object.assign({}, previousResult, { // Append the new posts results to the old one allPosts: [...previousResult.allPosts, ...fetchMoreResult.allPosts] }); } }) }) })
graphql(getPostGql, { options: ({ postId }) => ({ variables: { postId } }), props: ({ data: { loading, Post, error } }) => ({ loading, Post, error }) })
graphql(createPostGql, { props: ({ mutate }) => ({ mutations: { createPost: (title, url) => mutate({ variables: { title, url }, updateQueries: { allPosts: (previousResult, { mutationResult }) => { const newPost = mutationResult.data.createPost; return Object.assign({}, previousResult, { // Append the new post allPosts: [newPost, ...previousResult.allPosts] }); } } }) } }) })
graphql(upvotePostGql, { props: ({ ownProps, mutate }) => ({ upvote: (id, votes) => mutate({ variables: { id, votes }, optimisticResponse: { __typename: 'Mutation', updatePost: { __typename: 'Post', id: ownProps.id, votes: ownProps.votes + 1 } } }) }) })
graphql(ListAllItemsQuery, { options: { fetchPolicy: 'cache-and-network' }, props: (props) => ({ // fits structure identified in query and stores in allItems // stores as prop.allItems allItems: props.data.listListItems && props.data.listListItems.items }) })(ListItems)
graphql(USER_QUERY, { skip: ownProps => !ownProps.auth || !ownProps.auth.jwt, options: ownProps => ({ variables: { id: ownProps.auth.id } }), props: ({ data: { loading, networkStatus, refetch, user } }) => ({ loading, networkStatus, refetch, user, }), })
graphql(GROUP_QUERY, { options: ownProps => ({ variables: { groupId: ownProps.navigation.state.params.id } }), props: ({ data: { loading, group } }) => ({ loading, group, }), })
graphql(signInGql, { props: ({ mutate }) => ({ mutations: { signIn: ({ email, password }) => mutate({ variables: { email, password } }) } }) })
graphql( gql` query recentCommunities($filter: MemberConnectionFilter) { recentCommunities { ...communityInfo ...communityMembers } } ${communityInfoFragment} ${communityMemberConnectionFragment} `, { name: 'recent', options: () => ({ variables: { filter: { isOwner: true, isMember: true }, }, fetchPolicy: 'cache-and-network', }), } )
graphql(ListAllItemsQuery, { options: { fetchPolicy: "cache-and-network" }, props: props => ({ // fits structure identified in query and stores in allItems // stores as prop.allItems allItems: props.data.listListItems && props.data.listListItems.items }) })(ListItems)
graphql(usersQuery, { options: ({ perPage, currentPage, search }) => ({ variables: { perPage, currentPage, search, }, }), })(AdminUsersList)