{"name":"@graphiql/plugin-collections","version":"1.0.0-beta.0","keywords":["react","graphql","graphiql","plugin","collections"],"license":"MIT","_id":"@graphiql/plugin-collections@1.0.0-beta.0","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"}],"homepage":"https://github.com/graphql/graphiql/tree/master/packages/graphiql-plugin-collections#readme","bugs":{"url":"https://github.com/graphql/graphiql/issues?q=issue+label:@graphiql/plugin-collections"},"dist":{"shasum":"98dfdf73dc1c771a6bf1ad8a95bbc8f6fc4e9a13","tarball":"http://registry-npm.ywwl.com/@graphiql/plugin-collections/download/@graphiql/plugin-collections-1.0.0-beta.0.tgz","fileCount":57,"integrity":"sha512-rOosOtvoBx8WLrM1a0Jf1/CVS7/8PbTo2LBUd5EotbGzej9Q73S3gdu4prDENRx3Y9WIJv0I7WfEVPXewAfqeQ==","signatures":[{"sig":"MEYCIQCiigbDV8z6svc0yTlYha7Wpra4hwhG3/kF9VDK20L4lAIhAJkonCVRfsXJMs/qhL7SYQxy77FhaGNh2S8X4kYPpIIW","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@graphiql%2fplugin-collections@1.0.0-beta.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":235065,"size":55223,"noattachment":false,"key":"/@graphiql/plugin-collections/-/@graphiql/plugin-collections-1.0.0-beta.0.tgz"},"types":"dist/index.d.ts","exports":{".":"./dist/index.js","./style.css":"./dist/style.css","./package.json":"./package.json"},"gitHead":"97ade1b6f1dd0fa9644675fb5cfcdf882b9d4366","scripts":{"dev":"vite build --watch --emptyOutDir=false","test":"vitest run","build":"vite build","types:check":"tsgo --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c629800f-4aca-4f88-9b75-d03d51b41213"}},"repository":{"url":"git+https://github.com/graphql/graphiql.git","type":"git","directory":"packages/graphiql-plugin-collections"},"_npmVersion":"11.17.0","description":"A first-party operation collections plugin for GraphiQL.","directories":{},"sideEffects":["*.css"],"_nodeVersion":"24.19.0","dependencies":{"zod":"^4.0.0","zustand":"^5"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"vite":"^6.3.4","react":"^19.1.0","graphql":"^16.9.0","react-dom":"^19.1.0","@graphiql/react":"^1.0.0-beta.0","vite-plugin-dts":"^4.5.3","vite-plugin-svgr":"^4.3.0","@testing-library/dom":"^10.4.0","@vitejs/plugin-react":"^4.4.1","@testing-library/react":"^16.3.0","@testing-library/jest-dom":"^6.6.3"},"peerDependencies":{"react":"^18 || ^19","graphql":"^15.5.0 || ^16.0.0 || ^17.0.0","react-dom":"^18 || ^19","@graphiql/react":"^1.0.0-beta.0"},"_npmOperationalInternal":{"tmp":"tmp/plugin-collections_1.0.0-beta.0_1788019876473_0.5090005707474885","host":"s3://npm-registry-packages-npm-production"},"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":1788019876604,"_cnpm_publish_time":1788019876604,"dist-tags":{"beta":"1.0.0-beta.4","latest":"1.0.1","rc":"1.0.0-rc.1"}}