Skip to content

Commit 694cc4e

Browse files
committed
06-GraphQL Query/Mutation with Higher-Order Components in React
1 parent feb2b79 commit 694cc4e

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

src/Profile/index.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import gql from 'graphql-tag';
3-
import { Query } from 'react-apollo';
3+
import { graphql } from 'react-apollo';
44

55
import RepositoryList from '../Repository';
66
import Loading from '../Loading';
@@ -41,22 +41,18 @@ const GET_REPOSITORIES_OF_CURRENT_USER = gql`
4141
}
4242
`;
4343

44-
const Profile = () => (
45-
<Query query={GET_REPOSITORIES_OF_CURRENT_USER}>
46-
{({ data, loading, error }) => {
47-
if (error) {
48-
return <ErrorMessage error={error} />;
49-
}
44+
const Profile = ({ data, loading, error }) => {
45+
if (error) {
46+
return <ErrorMessage error={error} />;
47+
}
5048

51-
const { viewer } = data;
49+
const { viewer } = data;
5250

53-
if (loading || !viewer) {
54-
return <Loading />;
55-
}
51+
if (loading || !viewer) {
52+
return <Loading />;
53+
}
5654

57-
return <RepositoryList repositories={viewer.repositories} />;
58-
}}
59-
</Query>
60-
);
55+
return <RepositoryList repositories={viewer.repositories} />;
56+
};
6157

62-
export default Profile;
58+
export default graphql(GET_REPOSITORIES_OF_CURRENT_USER)(Profile);

0 commit comments

Comments
 (0)