# Apollo Client

#### Apollo Client Creation

The Apollo Client is set up using the GraphQL server's URI and the client's cache is configured.

```typescript
typescriptCopy codeimport { ApolloClient, InMemoryCache } from "@apollo/client/core/index.js";
import { HttpLink } from "@apollo/client/link/http/HttpLink.js";

export function createApolloClient(uri: string) {
  return new ApolloClient({
    link: new HttpLink({
      uri,
    }),
    ssrMode: typeof window === "undefined",
    connectToDevTools:
      typeof window !== "undefined" && process.env.NODE_ENV === "development",
    cache: new InMemoryCache(),
  });
}
```

* **uri**: The endpoint of your GraphQL server.
* **ssrMode**: Configures the client for server-side rendering if the code is running on the server.
* **connectToDevTools**: Enables connection to browser development tools in development mode.
* **cache**: Configures the client to use an in-memory cache for storing query results.

#### Fetching Data

To fetch data specific to a blockchain network (e.g., Polygon or BSC), the appropriate GraphQL subgraph URI is determined based on the network chain ID. Then the Apollo Client executes a query to the subgraph.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://symmdocs.gitbook.io/frontend-sdk-technical-docs/frontend-sdk/core-package/apollo-client.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
