4 examples of 'apolloclient.query' in JavaScript

Every line of 'apolloclient.query' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
12query(query, options) {
13 options = Object.assign({ query }, options);
14 return this.client.query(options);
15}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

17watchQuery(query, options) {
18 options = Object.assign({ query }, options);
19 return this.client.watchQuery(options);
20}
135private _namedClient(operation: OperationDefinitionNode): string {
136 let name: string;
137
138 if (this._operationHasDirective(operation, 'namedClient')) {
139 name = this._extractNamedClient(operation);
140 } else if (this.config.namedClient) {
141 name = this.config.namedClient;
142 }
143
144 return name ? `client = '${name}';` : '';
145}
21export default function createApolloClient({ graphQlApiUrl }) {
22 // "apollo-link" is a standard interface for modifying control flow of GraphQL requests and fetching GraphQL results,
23 // designed to provide a simple GraphQL client that is capable of extensions.
24 // https://github.com/apollographql/apollo-link
25 const link = from([
26 // Handle and inspect errors in your GraphQL network stack.
27 // https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-error
28 onError(({ graphQLErrors, networkError }) => {
29 if (graphQLErrors) {
30 graphQLErrors.map(({ message, locations, path }) =>
31 console.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`)
32 );
33 }
34 if (networkError) {
35 console.warn(`[Network error]: ${networkError}`);
36 }
37 }),
38
39 // HTTP Link takes an object with some options on it to customize the behavior of the link.
40 // If your server supports it, the HTTP link can also send over metadata about the request in the extensions field.
41 // https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-http
42 new HttpLink({
43 uri: graphQlApiUrl,
44 credentials: 'same-origin'
45 })
46 ]);
47
48 const cache = createCache();
49
50 return new ApolloClient({
51 link,
52 ssr: !IS_BROWSER,
53 cache: IS_BROWSER ? cache.restore(window.APOLLO_STATE) : cache,
54 queryDeduplication: true,
55 connectToDevTools: IS_BROWSER
56 });
57}

Related snippets