Read the documentation for more information
yarn add gqler
import GQLer from 'gqler';
import MemoryCache from 'gqler/lib/cache/MemoryCache';
const gql = GQLer({
url: 'https://example.com/graphql',
cacheAdapter: MemoryCache(),
});
const userData = gql.query`
query UserData($uid: String) {
user(uid: $uid) {
uid
name
age
addresses {
id
line1
line2
city
country
}
}
}
`;
async function fetchUser() {
const response = await userData.run({ uid: '13wsffw' });
return response.data;
}
const userAddressFragment = gql.fragment`
fragment UserAddressPart on User {
addresses {
id
line1
line2
city
country
}
}
`;
const userData = gql.query`
query UserData($uid: String) {
user(uid: $uid) {
uid
name
age
${userAddressFragment}
}
}
`;