{"name":"@graphiql/react","version":"0.37.1","keywords":["react","graphql","sdk","monaco-editor","monaco-graphql","monaco"],"license":"MIT","_id":"@graphiql/react@0.37.1","maintainers":[{"name":"benjie","email":"npm@benjiegillam.com"},{"name":"mjmahone","email":"mahoney.mattj@gmail.com"},{"name":"leebyron","email":"lee@leebyron.com"},{"name":"i1g","email":"ivan.goncharov.ua@gmail.com"},{"name":"acao","email":"rikki.schulte@gmail.com"}],"homepage":"https://github.com/graphql/graphiql/tree/master/packages/graphiql-react#readme","bugs":{"url":"https://github.com/graphql/graphiql/issues?q=issue+label:@graphiql/react"},"dist":{"shasum":"533d55907fbbdb48533678a4ae04ccd9a2f78841","tarball":"http://registry-npm.ywwl.com/@graphiql/react/download/@graphiql/react-0.37.1.tgz","fileCount":195,"integrity":"sha512-28XtNUzzQeQ2NFS26tG/F6d3SGm/nNrXtKpGhPmCNfLRYiUeaieAond3t9UsSJ8GFgf1NnJHiJDD3kFSpqVDng==","signatures":[{"sig":"MEUCIQDxwpXvOyLjgrUemlksfdCPVIrswcd6HVACEYRJ3XDhmwIgdCmxKmEtCCy/pKcIO+bMtabYF3OYioLtJ/0+6IxC12c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":915957,"size":409913,"noattachment":false,"key":"/@graphiql/react/-/@graphiql/react-0.37.1.tgz"},"types":"dist/index.d.ts","browser":{"//":"Prevents esm.sh from injecting Node.js globals like `process`, which can break browser features (e.g., Mac `Cmd` key) when loading from CDN.","buffer":false,"process":false},"exports":{".":"./dist/index.js","./font/*":"./font/*","./style.css":"./dist/style.css","./package.json":"./package.json","./setup-workers/*":{"types":"./dist/setup-workers/*.d.ts","import":"./dist/setup-workers/*.js"}},"gitHead":"0d9e51aa6452de1a1dee1ff1d1dae6df923f389f","scripts":{"dev":"vite build --watch --emptyOutDir=false","test":"vitest --typecheck","build":"vite build","types:check":"tsc --noEmit"},"_npmUser":{"name":"acao","email":"rikki.schulte@gmail.com"},"repository":{"url":"git+https://github.com/graphql/graphiql.git","type":"git","directory":"packages/graphiql-react"},"_npmVersion":"10.8.2","description":"[Changelog](https://github.com/graphql/graphiql/blob/main/packages/graphiql-react/CHANGELOG.md) | [API Docs](https://graphiql-test.netlify.app/typedoc/modules/graphiql_react.html) | [NPM](https://www.npmjs.com/package/@graphiql/react)","directories":{},"sideEffects":["dist/setup-workers/*"],"_nodeVersion":"20.19.3","dependencies":{"clsx":"^1.2.1","zustand":"^5","prettier":"^3.5.3","get-value":"^3.0.1","set-value":"^4.1.0","markdown-it":"^14.1.0","jsonc-parser":"^3.3.1","framer-motion":"^12.12","monaco-editor":"^0.52.2","monaco-graphql":"^1.7.2","@graphiql/toolkit":"^0.11.3","@radix-ui/react-dialog":"^1.1","@radix-ui/react-tooltip":"^1.2","graphql-language-service":"^5.5.0","@radix-ui/react-dropdown-menu":"^2.1","@radix-ui/react-visually-hidden":"^1.2"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^6.3.4","react":"^19.1.0","graphql":"^16.9.0","react-dom":"^19.1.0","typescript":"^4.6.3","vite-plugin-dts":"^4.5.3","@types/get-value":"^3.0.5","@types/react-dom":"^19.1.2","@types/set-value":"^4.0.1","vite-plugin-svgr":"^4.3.0","@types/markdown-it":"^14.1.2","@vitejs/plugin-react":"^4.4.1","@babel/helper-string-parser":"^7.19.4","babel-plugin-react-compiler":"19.1.0-rc.1"},"peerDependencies":{"react":"^18 || ^19","graphql":"^15.5.0 || ^16.0.0 || ^17.0.0","react-dom":"^18 || ^19","react-compiler-runtime":"19.1.0-rc.1"},"_npmOperationalInternal":{"tmp":"tmp/react_0.37.1_1752947025408_0.9636631173439245","host":"s3://npm-registry-packages-npm-production"},"readme":"[Changelog](https://github.com/graphql/graphiql/blob/main/packages/graphiql-react/CHANGELOG.md)\n|\n[API Docs](https://graphiql-test.netlify.app/typedoc/modules/graphiql_react.html)\n| [NPM](https://www.npmjs.com/package/@graphiql/react)\n\n# `@graphiql/react`\n\nA React SDK for building integrated GraphQL developer experiences for the web.\n\n## Purpose\n\nThis package contains a set of building blocks that allow its users to build\nGraphQL IDEs with ease. It's the set of components that make up Graph*i*QL, the\nfirst and official GraphQL IDE, owned and maintained by the GraphQL Foundation.\n\nThere are two kinds of building blocks that this package provides: Stateful\ncontext providers for state management and simple UI components.\n\n## Getting started\n\nAll the state for your GraphQL IDE lives in multiple contexts. The easiest way\nto get started is by using the `GraphiQLProvider` component that renders all the\nindividual providers.\n\n`GraphiQLProvider` needs either a `transport` or a `fetcher` prop (the two are\nmutually exclusive) to know how to run GraphQL requests against a given\nendpoint. A `transport` is an object with a `send(request)` method; you can\neasily create one using the `createTransport` function from the\n`@graphiql/toolkit` package. `fetcher` is the older, deprecated-but-still-supported\nalternative: a plain function that returns an execution result directly, with\nno access to the underlying HTTP response.\n\n```jsx\nimport { GraphiQLProvider } from '@graphiql/react';\nimport { createTransport } from '@graphiql/toolkit';\n\nconst transport = createTransport({\n  url: 'https://my.graphql.api/graphql',\n});\n\nfunction MyGraphQLIDE() {\n  return (\n    <GraphiQLProvider transport={transport}>\n      <div className=\"graphiql-container\">Hello GraphQL</div>\n    </GraphiQLProvider>\n  );\n}\n```\n\nInside the provider you can now use any UI component provided by\n`@graphiql/react`. For example, you can render an operation editor like this:\n\n```jsx\nimport { QueryEditor } from '@graphiql/react';\n\nfunction MyGraphQLIDE() {\n  return (\n    <GraphiQLProvider transport={transport}>\n      <div className=\"graphiql-container\">\n        <QueryEditor />\n      </div>\n    </GraphiQLProvider>\n  );\n}\n```\n\nThe package also ships the necessary CSS that all its UI components need. You\ncan import them from `@graphiql/react/style.css`.\n\n> **Note**: In order for these styles to apply, the UI components need to be\n> rendered inside an element that has a class name `graphiql-container`.\n\nBy default, the UI components will try to use the\n[Roboto](https://fonts.google.com/specimen/Roboto) font for regular text and the\n[Fira Code](https://fonts.google.com/specimen/Fira+Code) font for mono-space\ntext. If you want to use the default fonts you can load them using these files:\n\n- `@graphiql/react/font/roboto.css`\n- `@graphiql/react/font/fira-code.css`.\n\nYou can, of course, use any other method to load these fonts (for example, loading\nthem from Google Fonts).\n\nFurther details on how to use `@graphiql/react` can be found in the reference\nimplementation of a GraphQL IDE - Graph*i*QL - in the\n[`graphiql` package](https://github.com/graphql/graphiql/blob/main/packages/graphiql/src/components/GraphiQL.tsx).\n\n## Available Stores\n\nGraphiQL uses a set of state management stores, each responsible for a specific part of the IDE's\nbehavior. These stores contain all logic related to state management and can be accessed via custom\nReact hooks.\n\n### Core Hooks\n\n- **`useMonaco`**: Access `monaco-editor` exports and the `monaco-graphql` instance. Designed for safe use in SSR environments.\n- **`useGraphiQL`**: Access the current state.\n- **`useGraphiQLActions`**: Trigger actions that mutate the state. This hook **never** rerenders.\n\nThe `useGraphiQLActions` hook **exposes all actions** across store slices.\nThe `useGraphiQL` hook **provides access to the following store slices**:\n\n| Store Slice                              | Responsibilities                                                                                          |\n| ---------------------------------------- | --------------------------------------------------------------------------------------------------------- |\n| [`storage`](./src/stores/storage.ts)     | Provides a storage API that can be used to persist state in the browser (by default using `localStorage`) |\n| [`editor`](./src/stores/editor.ts)       | Manages **query**, **variables**, **headers**, and **response** editors and tabs                          |\n| [`execution`](./src/stores/execution.ts) | Handles the execution of GraphQL requests                                                                 |\n| [`plugin`](./src/stores/plugin.ts)       | Manages plugins and the currently active plugin                                                           |\n| [`schema`](./src/stores/schema.ts)       | Fetches, validates, and stores the GraphQL schema                                                         |\n| [`theme`](./src/stores/theme.ts)         | Manages the current theme and provides a method to update it                                              |\n\n### Usage Example\n\n```js\nimport { useGraphiQL, useGraphiQLActions } from '@graphiql/react';\n\n// Get an action to fetch the schema and an action to change theme\nconst { introspect, setTheme } = useGraphiQLActions();\n\n// Use a selector to access specific parts of the state like current schema and theme\nconst { schema, theme } = useGraphiQL(state => ({\n  schema: state.schema,\n  theme: state.theme,\n}));\n```\n\nAll store properties are documented using TSDoc comments. If you're using an\nIDE like VSCode for development, these descriptions will show up in auto-complete\ntooltips. All these descriptions can also be found in the\n[API Docs](https://graphiql-test.netlify.app/typedoc/modules/graphiql_react.html).\n\n## Theming\n\nAll the components from `@graphiql/react` have been designed with customization\nin mind. We achieve this using CSS variables.\n\nAs of v6 the customization surface is the OKLCH design-token set in the\n[`tokens.css` file](https://github.com/graphql/graphiql/blob/main/packages/graphiql-react/src/style/tokens.css).\n\n### Colors\n\nGraphiQL's UI colors come from the v6 OKLCH design tokens documented below. The\nv5 `--color-*` HSL variables are **deprecated** and kept only for backward\ncompatibility — see [Deprecated: v5 HSL variables](#deprecated-v5-hsl-variables).\n\n#### OKLCH tokens (v6)\n\nColors are defined as\n[OKLCH](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch)\ncomponent triplets — `L% C H` (lightness, chroma, hue) — stored without the\n`oklch()` wrapper so callers can add alpha at the use site:\n\n```css\nbackground: oklch(var(--bg-canvas));\ncolor: oklch(var(--fg-default) / 0.6);\n```\n\nThe tokens are scoped to `[data-theme='dark']` and `[data-theme='light']`\nrather than a media query, so a given variable resolves correctly regardless of\nwhich theme is active. The full set, defined in `tokens.css`, with when to reach\nfor each:\n\n**Backgrounds** — surfaces, ordered by how they stack:\n\n- `--bg-canvas` — the primary content surface: editors, side panels, the active tab. The base layer everything else sits on.\n- `--bg-elevated` — bars and floating chrome above the canvas: the tab strip, panel and response headers, tooltips, dropdown menus, popovers.\n- `--bg-subtle` — recessed fills _inside_ a surface: text inputs, secondary-button faces, segmented-control tracks, inline code.\n- `--bg-overlay` — transient interaction layers painted on top of a surface: hover, selected, and pressed states.\n\n**Borders** — increasing prominence:\n\n- `--border-default` — the standard divider and component outline; your default choice.\n- `--border-muted` — a fainter separator for low-emphasis internal divisions (menu-item rules, quiet section breaks).\n- `--border-strong` — the most visible edge, for inputs and dividers that must read clearly against busy content.\n\n**Foreground** — text and icon emphasis, brightest to faintest:\n\n- `--fg-strong` — high-emphasis text: headings, active or selected labels.\n- `--fg-default` — body text; the default content color.\n- `--fg-muted` — secondary text and resting icons: labels, captions, metadata.\n- `--fg-subtle` — tertiary text and quieter icons, one step below muted.\n- `--fg-disabled` — text and icons of disabled controls.\n- `--fg-dim` — the faintest marks: decorative or comment-level.\n\n**Accents** — the raw hue palette for syntax and status. You rarely set these directly; components and the `--type-*` tokens assign the roles (links and focus rings → `--accent-blue`, errors → `--accent-red`, success → `--accent-green`, deprecation → `--accent-orange`, and so on). The full set: `--accent-blue`, `--accent-green`, `--accent-green-light`, `--accent-yellow`, `--accent-orange`, `--accent-red`, `--accent-purple`, `--accent-pink`.\n\n**Type-name categories** — `--type-composite`, `--type-scalar`, `--type-enum`, `--type-input`. Color GraphQL type names by kind; see the note below.\n\n**Run button** — `--btn-primary` and `--btn-primary-border`: fill and border for the primary action (Run). A fixed mid-tone green tuned to keep light text legible in both themes — reserve it for the main call-to-action rather than general buttons.\n\n**Radii** — `--radius-sm` (4px; small controls: buttons, inputs, chips), `--radius-md` (6px; menus and cards), `--radius-lg` (8px; dialogs and large panels).\n\n**Shadow** — `--shadow-popover`: the elevation shadow for floating surfaces (menus, tooltips, dialogs).\n\n**Type-name categories.** In the schema-aware plugins (doc explorer, query\nbuilder), type names are colored by GraphQL kind rather than a single color:\nobject/interface/union share `--type-composite`, scalars use `--type-scalar`,\nenums use `--type-enum`, and input objects use `--type-input`. By default each\naliases an `--accent-*` token, so you can retint either the accent or the\n`--type-*` token directly. (In the light theme `--type-input` isn't an alias —\n`--accent-yellow` is only AA-contrast-safe as a background fill, not as text, so\nit gets its own darker gold.)\n\nIf you're building a plugin that renders type names and want it to match,\n`@graphiql/react` exports a `typeCategory(type)` helper that maps any\n`GraphQLType` to `'scalar' | 'enum' | 'input' | 'composite'` (unwrapping list\nand non-null wrappers first). Apply the corresponding `--type-*` token to your\nmarkup; the internal attribute and class names GraphiQL uses for this are not\npart of the public API.\n\n#### Deprecated: v5 HSL variables\n\n> **Deprecated (v6):** The v5 `--color-*` HSL variables (`--color-primary`,\n> `--color-neutral`, `--color-base`, and so on) described below are **deprecated\n> as of v6** and are no longer read by any component. They remain defined —\n> frozen at their v5 values — for backward compatibility, but overriding them no\n> longer re-themes GraphiQL. Retheme with the OKLCH tokens above instead; the\n> [v6 migration guide](https://github.com/graphql/graphiql/blob/main/docs/migration/graphiql-6.0.0.md#migrating---color--overrides)\n> maps each v5 variable to its v6 replacement.\n\nThe deprecated v5 colors are defined using the\n[HSL format](https://en.wikipedia.org/wiki/HSL_and_HSV): all CSS variables for\ncolors are defined as a list of the three values that make up HSL (hue,\nsaturation and lightness).\n\nThis approach allowed `@graphiql/react` to use transparent colors by passing the\nvalue of the CSS variable in the `hsla` function. The v6 OKLCH tokens keep the\nsame idea — the triplet is composed with `oklch(var(--x) / <alpha>)` — so\ntransparency still works at the call site.\n\n## Development\n\nIf you want to develop with `@graphiql/react` locally - in particular when\nworking on the `graphiql` package - all you need to do is run `pnpm dev` in the\npackage folder in a separate terminal. This will build the package using Vite.\nWhen using it in combination with `pnpm dev:graphiql` (running in the repo\nroot) this will give you auto-reloading when working on `graphiql` and\n`@graphiql/react` simultaneously.\n","publish_time":1752947025686,"_cnpm_publish_time":1752947025686,"dist-tags":{"alpha":"0.37.6-alpha.2","beta":"1.0.0-beta.4","canary":"0.37.3-canary-67317292.0","latest":"1.0.1","next":"1.0.0-next.2","rc":"1.0.0-rc.4"}}