.cursor/skills/data-client-graphql-setup/SKILL.md
Set up @data-client/graphql for GraphQL APIs. Configures GQLEndpoint with auth and custom options. Use after data-client-setup detects GraphQL patterns.
npx skillsauth add reactive/data-client data-client-graphql-setupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill configures @data-client/graphql for a project. It should be applied after data-client-setup detects GraphQL patterns.
Install the GraphQL package alongside the core package:
# npm
npm install @data-client/graphql
# yarn
yarn add @data-client/graphql
# pnpm
pnpm add @data-client/graphql
Create a file at src/api/gql.ts (or similar):
import { GQLEndpoint } from '@data-client/graphql';
export const gql = new GQLEndpoint('/graphql');
Scan the existing codebase for GraphQL patterns:
/graphql or custom pathsimport { GQLEndpoint } from '@data-client/graphql';
export const gql = new GQLEndpoint('/graphql', {
getHeaders() {
const token = localStorage.getItem('authToken');
return {
'Content-Type': 'application/json',
...(token && { Authorization: `Bearer ${token}` }),
};
},
});
import { GQLEndpoint } from '@data-client/graphql';
export const gql = new GQLEndpoint('/graphql', {
async getHeaders() {
const token = await getValidToken();
return {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
};
},
});
import { GQLEndpoint } from '@data-client/graphql';
class CustomGQLEndpoint extends GQLEndpoint {
async fetchResponse(input: RequestInfo, init: RequestInit): Promise<any> {
const response = await super.fetchResponse(input, init);
// Handle GraphQL errors
if (response.errors?.length) {
const authError = response.errors.find(
e => e.extensions?.code === 'UNAUTHENTICATED'
);
if (authError) {
window.dispatchEvent(new CustomEvent('auth:expired'));
}
}
return response;
}
}
export const gql = new CustomGQLEndpoint('/graphql');
import { gql } from './gql';
import { User } from '../schemas/User';
export const getUser = gql.query(
(v: { id: string }) => `
query GetUser($id: ID!) {
user(id: $id) {
id
name
email
}
}
`,
{ schema: User },
);
import { gql } from './gql';
import { User } from '../schemas/User';
export const updateUser = gql.mutation(
(v: { id: string; name: string }) => `
mutation UpdateUser($id: ID!, $name: String!) {
updateUser(id: $id, name: $name) {
id
name
}
}
`,
{ schema: User },
);
import { gql } from './gql';
import { User, UserCollection } from '../schemas/User';
export const listUsers = gql.query(
() => `
query ListUsers {
users {
id
name
email
}
}
`,
{ schema: UserCollection },
);
export const createUser = gql.mutation(
(v: { name: string; email: string }) => `
mutation CreateUser($name: String!, $email: String!) {
createUser(name: $name, email: $email) {
id
name
email
}
}
`,
{ schema: UserCollection.push },
);
import { useSuspense, useController } from '@data-client/react';
import { getUser, updateUser } from './api/users';
function UserProfile({ id }: { id: string }) {
const user = useSuspense(getUser, { id });
const ctrl = useController();
const handleUpdate = async (name: string) => {
await ctrl.fetch(updateUser, { id, name });
};
return (
<div>
<h1>{user.name}</h1>
<button onClick={() => handleUpdate('New Name')}>Update</button>
</div>
);
}
tools
Create a GitHub pull request from current working changes. Handles all git states - uncommitted changes, no branch, unpushed commits, etc. Analyzes diffs and changesets to generate a PR with filled-in template. Opens the PR in the browser when done. Use when the user asks to create a PR, open a PR, submit changes, or push for review.
tools
Migrate @data-client/rest path strings from path-to-regexp v6 to v8 syntax. Use when upgrading path-to-regexp, updating RestEndpoint.path or resource path strings, or when seeing errors about unexpected ?, +, (, or ) in paths.
development
Write, update, and format docs for public APIs - API reference, README, docstrings, usage examples, migration guides, deprecation notices
tools
Setup, install, and onboard new developers to Reactive Data Client monorepo - nvm, yarn, build, test, getting started guide