{"_id":"@graphiql/plugin-collections@1.0.1","bugs":{"url":"https://github.com/graphql/graphiql/issues?q=issue+label:@graphiql/plugin-collections"},"dist":{"shasum":"7867ae84a9e0244bbf4927381256f8feaa3835f1","tarball":"http://registry-npm.ywwl.com/@graphiql/plugin-collections/download/@graphiql/plugin-collections-1.0.1.tgz","fileCount":58,"integrity":"sha512-R/h9UitMBfcBpFw4ZRS/232mKNF/+sjl4U0HWFjx9NSgGiEJlWdRxGXWiXtPguscWIv9Gx+rIHwxBv3nQiQJgA==","signatures":[{"sig":"MEUCIQDfUhjVKk9NEkJubTXXk2pthCv+TnEdwcS0qbqGov77IAIgT1dO+JuuMkD762R/3YL2TZ8yc2UBjOIiBbzdqm/EDas=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCgEr3vhnULjPTBQBG0yk4D/DJfsTlKH6CHSRv4riPcLgIgSjksPFT2zVTSTn4w1LoFCtCgRlmydQrzXArQ78SI99o="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@graphiql%2fplugin-collections@1.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":231263,"size":57664,"noattachment":false,"key":"/@graphiql/plugin-collections/-/@graphiql/plugin-collections-1.0.1.tgz"},"name":"@graphiql/plugin-collections","_from":"file:graphiql-plugin-collections-1.0.1.tgz","types":"dist/index.d.ts","exports":{".":"./dist/index.js","./style.css":"./dist/style.css","./package.json":"./package.json"},"license":"MIT","scripts":{"dev":"vite build --watch --emptyOutDir=false","test":"vitest run","build":"pnpm types:check && vite build","types:check":"tsc --noEmit"},"version":"1.0.1","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"c629800f-4aca-4f88-9b75-d03d51b41213"}},"homepage":"https://github.com/graphql/graphiql/tree/master/packages/graphiql-plugin-collections#readme","keywords":["react","graphql","graphiql","plugin","collections"],"_resolved":"/tmp/f3f071dbf2b776fe05bb07ad845fab88/graphiql-plugin-collections-1.0.1.tgz","_integrity":"sha512-R/h9UitMBfcBpFw4ZRS/232mKNF/+sjl4U0HWFjx9NSgGiEJlWdRxGXWiXtPguscWIv9Gx+rIHwxBv3nQiQJgA==","repository":{"url":"git+https://github.com/graphql/graphiql.git","type":"git","directory":"packages/graphiql-plugin-collections"},"_npmVersion":"11.19.1","description":"A first-party operation collections plugin for GraphiQL.","directories":{},"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"}],"sideEffects":["*.css"],"_nodeVersion":"24.22.1","dependencies":{"zod":"^4.6.6","zustand":"^5"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^8.3.5","react":"^19.1.0","graphql":"^17.0.2","react-dom":"^19.1.0","typescript":"npm:@typescript/typescript6@^6.0.2","@types/react":"^19","@graphiql/react":"^1.0.1","vite-plugin-dts":"^5.1.2","@types/react-dom":"^19","vite-plugin-svgr":"^5.2.0","@typescript/native":"npm:typescript@^7.0.2","@testing-library/dom":"^10.4.0","@vitejs/plugin-react":"^6.1.2","@storybook/react-vite":"^10.3.6","@testing-library/react":"^16.3.0","@testing-library/jest-dom":"^7.0.1"},"peerDependencies":{"react":"^18 || ^19","graphql":"^16.11.0 || ^17.0.0","react-dom":"^18 || ^19","@graphiql/react":"^1.0.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-collections_1.0.1_1793588372725_0.3972217878104106"},"readme":"# @graphiql/plugin-collections\n\nA first-party operation collections plugin for GraphiQL. Save named GraphQL operations into collections and reuse them later, with drag-and-drop reordering, clipboard sharing, and JSON import/export that merges by id instead of duplicating.\n\n## Installation\n\n```sh\nnpm install @graphiql/plugin-collections\n```\n\nMake sure the peer dependencies are installed too:\n\n```sh\nnpm install react react-dom graphql @graphiql/react\n```\n\n## Usage\n\nThe collections plugin is installed by default in GraphiQL, so an unmodified `<GraphiQL>` already shows a Collections rail icon. Use `COLLECTIONS_PLUGIN` when you pass a custom `plugins` array and want to keep the default collections configuration. Use `collectionsPlugin(options)` to supply a custom storage backend or restrict what users can do.\n\n> **Note:** passing the `plugins` prop replaces the default plugin set, so include the others you want alongside it.\n\n```jsx\nimport { GraphiQL } from 'graphiql';\nimport { createTransport } from '@graphiql/toolkit';\nimport { COLLECTIONS_PLUGIN } from '@graphiql/plugin-collections';\nimport 'graphiql/style.css';\nimport '@graphiql/plugin-collections/style.css';\n\nconst transport = createTransport({\n  url: 'https://swapi-graphql.netlify.app/.netlify/functions/index',\n});\n\nfunction GraphiQLWithCollections() {\n  return <GraphiQL transport={transport} plugins={[COLLECTIONS_PLUGIN]} />;\n}\n```\n\n## Options\n\n```ts\ncollectionsPlugin({\n  storage, // custom persistence backend; see below\n  readOnly, // default false\n  allowImportExport, // default true\n  allowReplace, // default true\n});\n```\n\n| Option              | Default              | Effect                                                                                                                                 |\n| ------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |\n| `storage`           | localStorage adapter | A custom `CollectionsStorage` (see [Custom storage](#custom-storage)).                                                                 |\n| `readOnly`          | `false`              | Hides every write affordance (create, rename, delete, reorder, save, import). Export and copy stay available so users can still share. |\n| `allowImportExport` | `true`               | When `false`, hides the import/export dialog button and turns off paste/drop import.                                                   |\n| `allowReplace`      | `true`               | When `false`, hides the destructive \"replace everything\" import mode and leaves only merge.                                            |\n\n## Import and merge behavior\n\nCollections and the operations inside them carry stable UUIDs that survive export and import. On import, the plugin reconciles by id instead of duplicating:\n\n- A new operation is added. An operation you already have is updated in place wherever you keep it, even if you've moved it to a different collection. A missing parent collection is recreated.\n- Re-importing an unchanged export does nothing, so you never get duplicates.\n- When an incoming operation differs from your local copy, a dialog lets you apply the changes, keep your versions, or review each operation one at a time. Merge never deletes.\n\nAn operation can also be shared on its own with \"Copy operation\". It travels as a one-item collection envelope stamped with its parent collection, so the recipient can re-home it on import.\n\n## Custom storage\n\nPersistence is pluggable through the `CollectionsStorage` interface:\n\n```ts\ntype CollectionsStorage = {\n  storageKey?: string;\n  load(): Promise<Collection[]>;\n  save(collections: Collection[]): Promise<void>;\n};\n```\n\nThe default writes to `localStorage` under the key `graphiql:collections`. To use a different key, pass an adapter from the exported `createLocalStorageAdapter` factory:\n\n```ts\nimport {\n  collectionsPlugin,\n  createLocalStorageAdapter,\n} from '@graphiql/plugin-collections';\n\nconst collections = collectionsPlugin({\n  storage: createLocalStorageAdapter('my-key'),\n});\n```\n\nTo back collections with your own service (REST, a database, a team-shared store), implement the interface and pass it as `storage`:\n\n```ts\nimport { collectionsPlugin } from '@graphiql/plugin-collections';\nimport type {\n  Collection,\n  CollectionsStorage,\n} from '@graphiql/plugin-collections';\n\nconst apiStorage: CollectionsStorage = {\n  async load() {\n    const res = await fetch('/api/collections');\n    return (await res.json()) as Collection[];\n  },\n  async save(collections) {\n    const response = await fetch('/api/collections', {\n      method: 'PUT',\n      headers: { 'content-type': 'application/json' },\n      body: JSON.stringify(collections),\n    });\n    if (!response.ok) {\n      throw new Error(`Saving collections failed (${response.status})`);\n    }\n  },\n};\n\nconst collections = collectionsPlugin({ storage: apiStorage });\n```\n\n`load()` runs once when the panel first mounts. `save()` receives the full collection list after mutations. For toolbar or keyboard saves, its promise must resolve only after the write commits. A rejection keeps the operation dirty and shows an error in GraphiQL. Other collection editing actions still update the UI immediately.\n\n### Team-shared backends and sync\n\nThe plugin has no opinion about conflict resolution or synchronization; that lives in your storage adapter. Because every operation and collection has a stable id, your adapter can diff successive `save()` snapshots and reconcile them however it needs to, whether that is a plain backend write, a last-write-wins policy, or a CRDT such as Yjs or Automerge. The plugin itself stays a CRUD UI over a serializable model.\n\nThe plugin does not react to remote changes on its own. When your backend reports an external change, call `reload()` to re-read storage and refresh the UI:\n\n```ts\nimport { collectionsStore } from '@graphiql/plugin-collections';\n\nawait collectionsStore.getState().actions.reload();\n```\n\n## Programmatic access\n\nThe store and its React hook are exported for programmatic access:\n\n```ts\nimport {\n  collectionsStore, // the vanilla zustand store\n  useCollectionsStore, // React hook: useCollectionsStore(selector)\n} from '@graphiql/plugin-collections';\n\nconst { actions } = collectionsStore.getState();\n\n// Replace the in-memory collections (e.g. after merging remote state).\n// Does NOT write back to storage.\nactions.setCollections(nextCollections);\n\n// Re-read from the configured storage and refresh the UI.\nawait actions.reload();\n```\n\n`actions` also exposes the full CRUD surface (`createCollection`, `addItem`, `updateItem`, `deleteItem`, `moveItem`, `renameCollection`, and so on) plus `exportCollections` / `exportCollection` / `exportItem` and the two-phase `analyzeImport` / `applyImport`.\n\n## Exports\n\n- `COLLECTIONS_PLUGIN` — the default plugin configuration\n- `collectionsPlugin(options?)` — the plugin factory for custom configuration\n- `collectionsStore`, `useCollectionsStore` — the store and its React hook\n- `createLocalStorageAdapter(key)`, `localStorageAdapter` — built-in storage\n- `CollectionsSaveDialog` — the save dialog component\n- Types: `Collection`, `CollectionItem`, `CollectionsStorage`, `CollectionsConfig`, `ActiveOperation`\n","publish_time":1793588372799,"_cnpm_publish_time":1793588372799,"dist-tags":{"beta":"1.0.0-beta.4","latest":"1.0.1","rc":"1.0.0-rc.1"}}