Skip to content

reactive/data-client / .agents/skills/data-client-setup

data-client-setup

Verified

Install and set up @data-client/react or @data-client/vue in a project. Detects project type (NextJS, Expo, React Native, Vue, plain React) and protocol (REST, GraphQL, custom), then follows the bundled protocol-specific setup guide.

FileKindSize
SKILL.mdskill md13.9 KB
evals/evals.jsonconfig12.6 KB
references.jsonconfig523 B
references/DataClientPlugin.mdmarkdown6.6 KB
references/DataProvider.mdmarkdown6.6 KB
references/data-client-endpoint-setup.mdmarkdown8.5 KB
references/data-client-endpoint-setup/references/Endpoint.mdmarkdown20.9 KB
references/data-client-endpoint-setup/references/Endpoint.vue.mdmarkdown20.5 KB
references/data-client-graphql-setup.mdmarkdown4.8 KB
references/data-client-graphql-setup/references/auth.mdmarkdown1.9 KB
references/data-client-rest-setup.mdmarkdown7.6 KB
references/data-client-rest-setup/references/RestEndpoint.mdmarkdown45.2 KB
references/data-client-rest-setup/references/RestEndpoint.vue.mdmarkdown46.1 KB
references/data-client-rest-setup/references/auth.mdmarkdown9.4 KB
references/data-client-rest-setup/references/auth.vue.mdmarkdown9.7 KB
references/data-client-rest-setup/references/axios-migration.mdmarkdown25.4 KB
references/data-client-rest-setup/references/axios-migration.vue.mdmarkdown25.5 KB
references/data-client-rest-setup/references/django.mdmarkdown2.3 KB
references/data-client-rest-setup/references/fetch-migration.mdmarkdown4.0 KB
references/data-client-rest-setup/references/got-migration.mdmarkdown4.5 KB
references/data-client-rest-setup/references/hookifyResource.mdmarkdown6.0 KB
references/data-client-rest-setup/references/hookifyResource.vue.mdmarkdown6.3 KB
references/data-client-rest-setup/references/ky-migration.mdmarkdown3.9 KB
references/data-client-rest-setup/references/resource.mdmarkdown27.0 KB
references/data-client-rest-setup/references/resource.vue.mdmarkdown27.1 KB
references/data-client-rest-setup/references/superagent-migration.mdmarkdown4.1 KB
references/getDefaultManagers.mdmarkdown6.1 KB
references/getDefaultManagers.vue.mdmarkdown3.8 KB
references/installation.mdmarkdown4.0 KB
references/installation.vue.mdmarkdown2.7 KB
references/tanstack-query-migration.mdmarkdown31.1 KB

references/data-client-graphql-setup/references/auth.md

View on GitHub
<!-- Generated by `yarn build:skills` from docs/graphql/auth.md (react). Edit the source doc, not this file. -->

# GraphQL Authentication

## Cookie Auth

Here's an example using simple cookie auth:

```ts title="schema/endpoint.ts"
import { GQLEndpoint } from '@data-client/graphql';

class CookieGQLEndpoint extends GQLEndpoint<any> {
  getRequestInit(variables: any): RequestInit {
    return {
      ...super.getRequestInit(variables),
      credentials: 'same-origin',
    };
  }
}

export const gql = new CookieGQLEndpoint(
  'https://nosy-baritone.glitch.me',
);
export default gql;
```

## Access Tokens

Here we'll keep the access token in a module variable and send it in a header. Endpoints made with
`gql.query()` and `gql.mutation()` copy `gql` when they are created, so a value set on `gql` afterward
would not reach them; a module variable is read on every request.

```ts title="schema/endpoint.ts"
import { GQLEndpoint } from '@data-client/graphql';

let accessToken = '';
export function setAccessToken(token: string) {
  accessToken = token;
}

export const gql = new GQLEndpoint('https://nosy-baritone.glitch.me', {
  getHeaders(headers: HeadersInit): HeadersInit {
    return {
      ...headers,
      'Access-Token': accessToken,
    };
  },
});
export default gql;
```

Then be sure to set the access token upon login:

```ts
import { setAccessToken } from 'schema/endpoint';

function Auth() {
  const handleLogin = useCallback(
    async e => {
      const { accessToken } = await login(new FormData(e.target));
      // success!
      setAccessToken(accessToken);
    },
    [login],
  );

  return <AuthForm onSubmit={handleLogin} />;
}
```

## 401 Logout Handling

In case a users authorization expires, the server will typically responsd to indicate
as such. The standard way of doing this is with a 401. [LogoutManager](https://dataclient.io/docs/api/LogoutManager)
can be used to easily trigger any de-authorization cleanup.
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall