const { data } = await client.query({ query: SEARCH_USERS, variables: { searchQuery: debounceSearchQuery },
const getProducts = () =>{ return client.query({ fetchPolicy: 'network-only', query: gql` { products{id, name} } ` }) }
const getOwners = searchText => async (dispatch) => { dispatch(loadingOwners()); client .query({ query: ownersQuery, variables: { searchText } }) .then(({ error, data }) => { if (error) { throw new Error(error); } return dispatch(showOwners(ownersFromData(data))); }) .catch(error => dispatch(showOwnersError(error))); }
function getJobs() { return new Promise((resolve, reject) => { client .query({ query: JOBS_QUERY }) .then(resolve) .catch(reject); }); }
client.query({ query: gql` { users { id displayName } } ` }) .then(result => console.log(result));
client .query({ query: postsQuery }) .then(data => { const { posts } = data.data; this.setState({ posts }); }) .catch(err => { console.log("catch", err); });
async function getRoutes () { const output = ['/', '/about', '/books'] const { data } = await client.query({ query: gql` query graphql { books { id } } ` }) return output.concat(data.books.map(book => `/books/${encodeURIComponent(book.id)}`)) }
async fetchGraphQlData() { const { data } = await this.client.query({ query: GET_ALL }); //** update your d3 or whatever */ console.log('data ', data); this.setState({messageTest: data.a1}) }
function* handleQuery<T>(options: WatchQueryOptions) { const client: ApolloClient = yield getClient(); const response: ApolloQueryResult<T> = yield call(client.query, options); return yield response.data; }
const getRepositories = ownerLogin => async (dispatch) => { dispatch(loadingRepositories()); client .query({ query: repositoriesQuery, variables: { ownerLogin } }) .then(({ error, data }) => { if (error) { throw new Error(error); } return dispatch(showRepositories(repositoriesFromData(data))); }) .catch(error => dispatch(showRepositoriesError(error))); }
const queryWithApolloConsumer = () => ( <ApolloConsumer> {client => { client .query({ query: gql` { chatroom(id:1) { id title } } ` }) .then(result => console.log(result)); return null; }} </ApolloConsumer> )
async getSharedInboxEndpoints() { const result = await this.client.query({ query: gql` query { SharedInboxEndpoint { uri } } `, }) throwErrorIfApolloErrorOccurred(result) return result.data.SharedInboxEnpoint }
const { data } = await client.query({ query: SEARCH_USERS, variables: { searchQuery: debounceSearchQuery },