How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • const client = new ApolloClient({
      cache: new InMemoryCache().restore(JSON.parse(window.__APOLLO_STATE__)),
      uri: 'https://example.com/graphql'
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> client<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • const client = new ApolloClient({
      cache: new InMemoryCache().restore(JSON.parse(window.__APOLLO_STATE__)),
      link,
      ssrForceFetchDelay: 100, // in milliseconds
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> client<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • cache.modify({
      id: cache.identify(myPost),
      fields(fieldValue, details) {
        return details.INVALIDATE;
      },
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> cache<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • cache.modify({
      id: cache.identify(myPost),
      fields: {
        comments(existingCommentRefs, { DELETE }) {
          return DELETE;
        },
      },
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> cache<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • cache.modify({
      id: cache.identify(myObject),
      fields: {
        name(cachedName) {
          return cachedName.toUpperCase();
        },
      },
      /* broadcast: false // Include this to prevent automatic query refresh */
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> cache<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • cache.modify({
      id: cache.identify(myPost),
      fields: {
        comments(existingCommentRefs, { INVALIDATE }) {
          return INVALIDATE;
        },
      },
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> cache<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • const idToRemove = 'abc123';
    
    cache.modify({
      id: cache.identify(myPost),
      fields: {
        comments(existingCommentRefs, { readField }) {
          return existingCommentRefs.filter(
            commentRef => idToRemove !== readField('id', commentRef)
          );
        },
      },
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> idToRemove<span class="token operator">:</span> <span class="token string">"abc123"</span></code></pre>
    Docs
    0
  • import { ApolloClient, InMemoryCache } from "@apollo/client";
    
    const client = new ApolloClient({
      cache: new InMemoryCache(),
      uri: "/graphql"
    });
    
    client.query({
      query: MY_QUERY,
      context: {
        // example of setting the headers with context per operation
        headers: {
          special: "Special header value"
        }
      }
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">class</span> <span class="token class-name">ApolloClient<span class="token operator">&lt;</span>TCacheShape<span class="token operator">></span></span> <span class="token keyword">import</span> ApolloClient</code></pre>
    Docs
    1
  • import {
      ApolloClient,
      InMemoryCache,
      HttpLink,
      ApolloLink
    } from "@apollo/client";
    import { asyncMap } from "@apollo/client/utilities";
    
    import { usdToEur } from './currency';
    
    const httpLink = new HttpLink({ uri: '/graphql' });
    
    const usdToEurLink = new ApolloLink((operation, forward) => {
      return asyncMap(forward(operation), async (response) => {
        let data = response.data;
        if (data.price && data.currency === "USD") {
          data.price = await usdToEur(data.price);
          data.currency = "EUR";
        }
        return response;
      });
    });
    
    const client = new ApolloClient({
      cache: new InMemoryCache(),
      link: usdToEurLink.concat(httpLink)
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">class</span> <span class="token class-name">ApolloClient<span class="token operator">&lt;</span>TCacheShape<span class="token operator">></span></span> <span class="token keyword">import</span> ApolloClient</code></pre>
    Docs
    1
  • import { ApolloClient, InMemoryCache } from '@apollo/client';
    
    const client = new ApolloClient({
      cache: new InMemoryCache(),
      resolvers: { ... },
      typeDefs: { ... },
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">class</span> <span class="token class-name">ApolloClient<span class="token operator">&lt;</span>TCacheShape<span class="token operator">></span></span> <span class="token keyword">import</span> ApolloClient</code></pre>
    Docs
    0
  • import { AsyncStorage } from 'react-native';
    import { InMemoryCache } from '@apollo/client';
    import { persistCache } from 'apollo3-cache-persist';
    
    const cache = new InMemoryCache();
    
    persistCache({
      cache,
      storage: AsyncStorage,
    }).then(() => {
      // Continue setting up Apollo Client as usual.
    })
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">type</span> <span class="token class-name">AsyncStorage</span> <span class="token operator">=</span> <span class="token function">AsyncStorageStatic</span> <span class="token punctuation">(</span>alias<span class="token punctuation">)</span> <span class="token keyword">const</span> AsyncStorage<span class="token operator">:</span> AsyncStorageStatic <span class="token keyword">import</span> AsyncStorage</code><div class="typing-tooltip-markup">AsyncStorage has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from <code>@react-native-community/async-storage</code> instead of 'react-native'.<br><br><em>@see</em> — https://github.com/react-native-community/async-storage<br><br><em>@deprecated</em><br><br><em>@see</em> — https://github.com/react-native-community/async-storage<br><br><em>@deprecated</em></div></pre>
    Docs
    0
  • const cache = new InMemoryCache({
      typePolicies: {
        Query: {
          fields: {
            feed: {
              keyArgs: ["type"],
    
              // While args.cursor may still be important for requesting
              // a given page, it no longer has any role to play in the
              // merge function.
              merge(existing, incoming, { readField }) {
                const merged = { ...existing };
                incoming.forEach(item => {
                  merged[readField("id", item)] = item;
                });
                return merged;
              },
    
              // Return all items stored so far, to avoid ambiguities
              // about the order of the items.
              read(existing) {
                return existing && Object.values(existing);
              },
            },
          },
        },
      },
    });
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> cache<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • cache.release('my-object-id');
    <pre class="typing-tooltip"><code data-language="javascript" class="language-javascript"><span class="token keyword">const</span> cache<span class="token operator">:</span> <span class="token builtin">any</span></code></pre>
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples