# Linear issue api optimize response react native

> Trim GraphQL issue payloads before JSON.parse on device. For "linear issue api optimize response react native", store LINEAR_API_KEY in Secret Vault, call https://api.linear.app/graphql from a Worker, and let React Native hit only https://realcomposer.com/v1/workspace/optimize-linear-issue-response-react-native with an rc_live_ client token. POST upstream calls are not stored in caches.default; clients must send JSON bodies and headers forward unchanged.

- Canonical page: https://realcomposer.com/recipes/optimize-linear-issue-response-react-native
- Client platform: React Native
- Upstream services: Linear
- Category: Payload Slimmer
- JSON version: https://realcomposer.com/recipes/optimize-linear-issue-response-react-native.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=optimize-linear-issue-response-react-native&via=agent

## Problem: Linear JSON bloat on React Native

Oversized Linear payloads inflate parse time and mobile data charges for React Native users.

- Main-thread JSON parse stalls on low-end phones
- Accidentally exposing PII fields to the client
- Downstream components re-render on unused keys

## Solution steps

1. **Add vault secrets for this pipeline**: Store LINEAR_API_KEY in the vault. React Native never embeds the raw secret, only a revocable rc_live_ client token.

2. **Target the real upstream URL**: Configure headersTemplate to inject vault secrets, target https://api.linear.app/graphql, and Map only the UI fields in output mapping so clients never download audit or nested blobs.

3. **Call from React Native**: Allowed origins on the token should list every React Native host that calls this URL.

```
const res = await fetch('https://realcomposer.com/v1/workspace/optimize-linear-issue-response-react-native', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
});
```

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Linear issue api optimize response react native",
  "method": "POST",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "linear",
      "upstreamUrlTemplate": "https://api.linear.app/graphql",
      "httpMethod": "POST",
      "headersTemplate": {
        "Authorization": "{{secrets.LINEAR_API_KEY}}",
        "Content-Type": "application/json"
      },
      "timeoutMs": 10000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "issueId",
        "sourcePath": "data.issue.id",
        "type": "string",
        "sourceStep": "linear"
      },
      {
        "targetPath": "title",
        "sourcePath": "data.issue.title",
        "type": "string",
        "sourceStep": "linear"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X POST "https://realcomposer.com/v1/workspace/optimize-linear-issue-response-react-native" \
  -H "Authorization: Bearer rc_live_client_token" \
  -H "Content-Type: application/json" \
  -d '{"model":"example"}'
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_optimize",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "optimize-linear-issue-response-react-native"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "issueId": "sample",
  "title": "sample"
}
```

## FAQ

### Is it safe to log Linear responses in React Native?

Store LINEAR_API_KEY for optimize-linear-issue-response-react-native. React Native never sees decrypted values.

### When does edge caching apply to this recipe?

optimize-linear-issue-response-react-native vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body.

### What happens if an upstream step times out?

Rotate vault secrets for optimize-linear-issue-response-react-native anytime; clients keep the same rc_live_ token.
