skills.vishalvoidskills/vishalvoid
Creative & DesignIntermediate

apollo-client

Build React applications with Apollo Client 4

Developer Setup

Setup & Installation

bash
npx skills add https://github.com/apollographql/skills --skill apollo-client

Overview

What This Skill Does

Build React applications with Apollo Client 4

Application

When to use this Skill

Documentation

Show Skills.md file

Apollo Client 4.x Guide

Apollo Client is a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL. Version 4.x brings improved caching, better TypeScript support, and React 19 compatibility.

Integration Guides

Choose the integration guide that matches your application setup:

Each guide includes installation steps, configuration, and framework-specific patterns optimized for that environment.

Quick Reference

Basic Query

import { gql } from "@apollo/client";
import { useQuery } from "@apollo/client/react";

const GET_USER = gql`
  query GetUser($id: ID!) {
    user(id: $id) {
      id
      name
    }
  }
`;

function UserProfile({ userId }: { userId: string }) {
  const { loading, error, data, dataState } = useQuery(GET_USER, {
    variables: { id: userId },
  });

  if (loading) return <p>Loading...</p>;
  if (error) return <p>Error: {error.message}</p>;

  // TypeScript note: for stricter type narrowing, you can also check `dataState === "complete"` before accessing data
  return <div>{data?.user.name}</div>;
}
Lines 1 - 44 of 151

Recommendations

Explore other random skills

All skillsMy patterns