4 ms·
This frontend code. const ProfileImage = ({ user }) => <img src={user.avatarUrl} alt={user.name} />; const query = gql`{ user(id: 3) { name
by arstin 9y ago
This frontend code.
const ProfileImage = ({ user }) => <img src={user.avatarUrl} alt={user.name} />;
const query = gql`{
user(id: 3) {
name
avatarUrl
}
}`
export const ProfileImageWithData = graphql(query)(ProfileImage);
You can ask for data in the structure the UI expects and only get exactly that data, letting the GQL client handle batching network requests for needs distributed across the whole app, caching, UI updating, etc under the hood. Also does a great job of decoupling product and data management code.