concept Apollo in category graphql

appears as: Apollo
GraphQL in Action

This is an excerpt from Manning's book GraphQL in Action.

In front-end Web or Mobile applications, you can use GraphQL by making direct Ajax calls to a GraphQL server or with a client like Apollo or Relay (which will make the Ajax request on your behalf). You can use a library like React (or React Native) to manage how your views use the data coming from a GraphQL service but you can also do that with APIs native to their UI environments as well (like the DOM API or the native iOS components).

While you do not need React, Apollo, or Relay to use GraphQL in your applications, these libraries add more value to how you can leverage GraphQL APIs without having to do complex data management tasks.

Apollo is a powerful and flexible GraphQL client that can be used with React, Vue, Angular, and many others. It can also be used with just plain JavaScript. Let’s start with an example of how to do that first and then we will see how to use it in the AZdev React project.

In some cases, you can do the refetching manually instead of automatically in a polling loop. If you want Apollo to fetch the query again on demand (for example, when the user clicks a "refresh" button), you can use the refetch function, which Apollo makes available to all useQuery results. For example:

Listing 10.42. Example of refetching a query on demand
export default function Home() {
  const { error, loading, refetch, data } = useQuery(TASK_MAIN_LIST);

  // ·-·-·

  return (
    <div>
      <Search />
      <div>
        <h1>Latest</h1>
        <button onClick={() => refetch()}>Refresh</button>
        {/* ·-·-· */}
      </div>
    </div>
  );
}

This would make Apollo fetch the same query again when the user clicks the refresh button.

Fullstack GraphQL Applications With GRANDstack

This is an excerpt from Manning's book Fullstack GraphQL Applications With GRANDstack.

Figure 1.1. The components of GRANDstack: GraphQL, React, Apollo, Neo4j Database
grandstack arch without code

Apollo is a collection of tooling to make it easier to use GraphQL, both on the server and the client. We will make use of Apollo Server, a Node.js library for building our GraphQL API and Apollo Client, a client side JavaScript library for querying our GraphQL API from our application.