document: NOTIFICATION_CREATED_OR_DELETED, updateQuery: async (prev, { subscriptionData }) => { if (!subscriptionData.data) return prev; operation, notification, } = subscriptionData.data.notificationCreatedOrDeleted; document: GET_NEW_CONVERSATIONS_SUBSCRIPTION, updateQuery: (prev, { subscriptionData }) => { if (!subscriptionData.data) return prev; const { newConversation } = subscriptionData.data;
const initiateFetchMyChangeRequests = dispatch => { dispatch(changeRequestsIsLoading()); return fetchMyChangeRequests() .then(result => result.data.myChangeRequests) .then(changeRequests => dispatch(changeRequestIsFetched(changeRequests))) .catch(error => { console.log("An error occurred while fetching my change requests", error); dispatch(changeRequestFetchError([error.message])); }); }
client .query({ query: postsQuery }) .then(data => { const { posts } = data.data; this.setState({ posts }); }) .catch(err => { console.log("catch", err); });
const recursivelyFetchAllPosts = async (currentCursor = null) => { const response = await queryPosts(currentCursor); const currentPosts = response.data.allPosts.edges.map((edge) => edge.node); if (!response.data.allPosts.pageInfo.hasNextPage) { return currentPosts; } const newCursor = response.data.allPosts.pageInfo.endCursor; const newPosts = await recursivelyFetchAllPosts(newCursor); return [...currentPosts, ...newPosts]; }
client .query({ query: FraToMun() }) .then(result => result.data) .then(queryResult => this.setState({ ...this.state, queryResult }));
function* handleQuery<T>(options: WatchQueryOptions) { const client: ApolloClient = yield getClient(); const response: ApolloQueryResult<T> = yield call(client.query, options); return yield response.data; }
const initiateFetchChangeRequests = dispatch => { dispatch(changeRequestsIsLoading()); return fetchAllPendingChangeRequests() .then(result => result.data.profileChangeRequests) .then(changeRequests => dispatch(changeRequestIsFetched(changeRequests))) .catch(error => { console.log("An error occurred while fetching change requests", error); dispatch(changeRequestFetchError([error.message])); }); }
document: NOTIFICATION_CREATED_OR_DELETED, updateQuery: async (prev, { subscriptionData }) => { if (!subscriptionData.data) return prev; operation, notification, } = subscriptionData.data.notificationCreatedOrDeleted; document: GET_NEW_CONVERSATIONS_SUBSCRIPTION, updateQuery: (prev, { subscriptionData }) => { if (!subscriptionData.data) return prev; const { newConversation } = subscriptionData.data;
const initiateFetchMyChangeRequests = dispatch => { dispatch(changeRequestsIsLoading()); return fetchMyChangeRequests() .then(result => result.data.myChangeRequests) .then(changeRequests => dispatch(changeRequestIsFetched(changeRequests))) .catch(error => { console.log("An error occurred while fetching my change requests", error); dispatch(changeRequestFetchError([error.message])); }); }
const initiateFetchChangeRequests = dispatch => { dispatch(changeRequestsIsLoading()); return fetchAllPendingChangeRequests() .then(result => result.data.profileChangeRequests) .then(changeRequests => dispatch(changeRequestIsFetched(changeRequests))) .catch(error => { console.log("An error occurred while fetching change requests", error); dispatch(changeRequestFetchError([error.message])); }); }