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

  • // server application code (integrated usage)
    import { renderToStringWithData } from "@apollo/react-ssr";
    
    const client = new ApolloClient(...);
    
    // during request
    renderToStringWithData(App).then((content) => {
      const initialState = client.extract();
      const html = ;
    
      res.status(200);
      res.send(`\n${ReactDOMServer.renderToStaticMarkup(html)}`);
      res.end();
    });
    Docs
    0
  • import { getDataFromTree } from "@apollo/react-ssr";
    
    const client = new ApolloClient(....);
    
    // during request (see above)
    getDataFromTree(App).then(() => {
      // We are ready to render for real
      const content = ReactDOM.renderToString(App);
      const initialState = client.extract();
    
      const html = ;
    
      res.status(200);
      res.send(`\n${ReactDOM.renderToStaticMarkup(html)}`);
      res.end();
    });
    Docs
    0
  • const { todo } = client.readQuery({
      query: gql`
        query ReadTodo($id: Int!) {
          todo(id: $id) {
            id
            text
            completed
          }
        }
      `,
      variables: {
        id: 5,
      },
    });
    
    Docs
    0
  • const query = gql`
      query MyTodoAppQuery {
        todos {
          id
          text
          completed
        }
      }
    `;
    
    // Get the current to-do list
    const data = client.readQuery({ query });
    
    const myNewTodo = {
      id: "6",
      text: "Start using Apollo Client.",
      completed: false,
      __typename: "Todo",
    };
    
    // Write back to the to-do list and include the new item
    client.writeQuery({
      query,
      data: {
        todos: [...data.todos, myNewTodo],
      },
    });
    
    Docs
    0
  • const { todo } = client.readQuery({
      query: gql`
        query ReadTodo {
          todo(id: 5) {
            id
            text
            completed
          }
        }
      `,
    });
    
    Docs
    0
  • // Create our enhancer function.
    const withTodoAppQuery = graphql(gql`query { ... }`);
    
    // Enhance our component.
    const TodoAppWithData = withTodoAppQuery(TodoApp);
    
    // Export the enhanced component.
    export default TodoAppWithData;
    
    Docs
    0
  • const query = gql`{ todos { ... } }`;
    
    export default graphql(
      gql`
      mutation ($text: String!) {
        createTodo(text: $text) { ... }
      }
    `,
      {
        options: {
          update: (proxy, { data: { createTodo } }) => {
            const data = proxy.readQuery({ query });
            data.todos.push(createTodo);
            proxy.writeQuery({ query, data });
          },
        },
      }
    )(MyComponent);
    
    Docs
    0
  • class MyComponent extends Component {
      render() {
        return (
          
    ); } } export default graphql(gql`query { ... }`)(MyComponent);
    Docs
    0
  • const typeDefs = gql`
      extend type Rocket {
        description: String!
      }
    `;
    
    const resolvers = {
      Rocket: {
        description: () =>
          "A boilerplate standard space rocket",
      },
    };
    
    const client = new ApolloClient({
      cache,
      link,
      typeDefs,
      resolvers,
    });
    
    Docs
    0
  • const query = gql`
      query MyTodoAppQuery {
        todos {
          id
          text
          completed
        }
      }
    `;
    
    // Get the current to-do list
    const data = client.readQuery({ query });
    
    const myNewTodo = {
      id: "6",
      text: "Start using Apollo Client.",
      completed: false,
      __typename: "Todo",
    };
    
    // Write back to the to-do list and include the new item
    client.writeQuery({
      query,
      data: {
        todos: [...data.todos, myNewTodo],
      },
    });
    
    Docs
    0
  • import { setup } from "meteor/swydo:blaze-apollo";
    
    const client = new ApolloClient(meteorClientConfig());
    
    setup({ client });
    
    Docs
    0
  • import ApolloClient from "apollo-boost";
    
    // the Apollo cache is set up automatically
    const client = new ApolloClient();
    
    Docs
    0
  • const typeDefs = gql`
      extend type Rocket {
        description: String!
      }
    `;
    
    const resolvers = {
      Rocket: {
        description: () =>
          "A boilerplate standard space rocket",
      },
    };
    
    const client = new ApolloClient({
      cache,
      link,
      typeDefs,
      resolvers,
    });
    
    Docs
    0
  • const client = new ApolloClient({
      cache: new InMemoryCache().restore(
        window.__APOLLO_STATE__
      ),
      link,
      ssrForceFetchDelay: 100,
    });
    
    Docs
    0
  • import { Accounts } from "meteor/accounts-base";
    import ApolloClient from "apollo-boost";
    
    const client = new ApolloClient({
      uri: "/graphql",
      request: (operation) =>
        operation.setContext(() => ({
          headers: {
            authorization: Accounts._storedLoginToken(),
          },
        })),
    });
    
    Docs
    0
  • const todo = client.readFragment({
      id: "5",
      fragment: gql`
        fragment myTodo on Todo {
          id
          text
          completed
        }
      `,
    });
    
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples