Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/shared/skills/resources_graphql/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import { createProxyFetch } from "@major-tech/resource-client/next";

const client = new ApolloClient({
link: new HttpLink({
uri: "/", // proxy resolves to the resource's configured endpoint
uri: () => "", // use the configured endpoint without adding a slash
fetch: createProxyFetch({
baseUrl: process.env.MAJOR_API_BASE_URL!,
resourceId: "<graphql-resource-id>",
Expand All @@ -92,7 +92,7 @@ const client = new ApolloClient({

**Key points:**

- **`uri: "/"`** the proxy reads the endpoint from the resource at request time; you do not (and should not) hardcode the upstream URL on the client.
- **`proxyFetch("")`** uses the configured endpoint without adding a slash. In Apollo use `uri: () => ""`; plain `uri: ""` falls back to `/graphql`.
- **Auth is injected server-side** — never set `Authorization` on the Apollo link; the proxy strips reserved request headers and replaces them with the resource's configured auth (`bearer`, `apiKey`, or `none`).
- **Resource ID must be static** — `createProxyFetch` is detected by the query extractor only when `resourceId` is a string literal; dynamic IDs are skipped at deploy time.
- **Next.js**: use Apollo on the server (RSC, Route Handlers, Server Actions) so the JWT stays out of the browser. For client-side Apollo, route the request through your own server endpoint.
Expand Down
Loading