{"_id":"@pothos/selection-mapper","_rev":"4-0cf6b6dbfb9b6eb08e9110f17725fe99","name":"@pothos/selection-mapper","dist-tags":{"latest":"0.3.1"},"versions":{"0.1.0":{"name":"@pothos/selection-mapper","version":"0.1.0","keywords":["pothos","graphql","schema","typescript","plugin"],"author":{"name":"Michael Hayes"},"license":"ISC","_id":"@pothos/selection-mapper@0.1.0","maintainers":[{"name":"hayes","email":"michael@hayes.io"}],"homepage":"https://github.com/hayes/pothos#readme","bugs":{"url":"https://github.com/hayes/pothos/issues"},"dist":{"shasum":"2fc934a48863c079825b3d06875a3c717f295b61","tarball":"https://registry.npmjs.org/@pothos/selection-mapper/-/selection-mapper-0.1.0.tgz","fileCount":86,"integrity":"sha512-CAXsJDqmYU+u9OLHHsJHd1jNp+mLjG8yXxxpW1ovQrsXbNIds8r2AUoIwlbOnIznWSAuonlChZjPk6EEaah0mA==","signatures":[{"sig":"MEQCIEiUXg7VPRv375vjLPZSC/dwFHhL2oC+4xrCrPAfE4JdAiAJ0HoJdUmWBphKypNu6ptq1pLAaigp8gvtWwDAHC+R3Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":450713},"main":"./lib/index.js","_from":"file:/tmp/pothos-selection-mapper-release-artifacts/pothos-selection-mapper-0.1.0.tgz","types":"./dts/index.d.ts","module":"./esm/index.js","exports":{"import":{"default":"./esm/index.js"},"require":{"types":"./dts/index.d.ts","default":"./lib/index.js"}},"scripts":{"test":"pnpm vitest run","type":"tsc --project tsconfig.type.json","build":"pnpm build:clean && pnpm build:cjs && pnpm build:dts && pnpm build:esm","build:cjs":"swc src -d lib --config-file .swcrc -C module.type=commonjs --strip-leading-paths","build:dts":"tsc","build:esm":"cp -r dts/* esm/ && swc src -d esm --config-file .swcrc -C module.type=es6 --strip-leading-paths","build:clean":"git clean -dfX esm lib"},"_npmUser":{"name":"hayes","email":"michael@hayes.io"},"_resolved":"/tmp/pothos-selection-mapper-release-artifacts/pothos-selection-mapper-0.1.0.tgz","_integrity":"sha512-CAXsJDqmYU+u9OLHHsJHd1jNp+mLjG8yXxxpW1ovQrsXbNIds8r2AUoIwlbOnIznWSAuonlChZjPk6EEaah0mA==","repository":{"url":"git+https://github.com/hayes/pothos.git","type":"git","directory":"packages/selection-mapper"},"_npmVersion":"11.19.0","description":"shared selection-to-query walker for Pothos ORM plugins","directories":{},"_nodeVersion":"26.7.0","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.4","graphql":"^17.0.1","graphql-tag":"^2.12.6","@pothos/core":"4.14.0","@pothos/test-utils":"2.2.1"},"peerDependencies":{"graphql":"^16.10.0 || ^17.0.0","@pothos/core":"*"},"_npmOperationalInternal":{"tmp":"tmp/selection-mapper_0.1.0_1789111156290_0.05184128833834434","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@pothos/selection-mapper","version":"0.2.0","keywords":["pothos","graphql","schema","typescript","plugin"],"author":{"name":"Michael Hayes"},"license":"ISC","_id":"@pothos/selection-mapper@0.2.0","maintainers":[{"name":"hayes","email":"michael@hayes.io"}],"homepage":"https://github.com/hayes/pothos#readme","bugs":{"url":"https://github.com/hayes/pothos/issues"},"dist":{"shasum":"abd873d59e7ecf363576d0bf84fa122fdacd9b4d","tarball":"https://registry.npmjs.org/@pothos/selection-mapper/-/selection-mapper-0.2.0.tgz","fileCount":114,"integrity":"sha512-R/MiHNomcQq0Z1oGlu25wJcES6gB2XqHWdyIQiSKJr57248Wlz+peX/I67yOWdEt1XUhm1OrwYHDsPn5NW6hGw==","signatures":[{"sig":"MEUCICbYIeWcmidT6p1yzLaboqh6tzwUwp0vAz3xTMTVr9YTAiEA5pQco5PdpvkWnRQeqKcQtH2nd4GqKcuegVrnuB2Kafg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIFY9Wi7cqjk1xX0KNuAlzKyHExQJOSnn2NmiDIyFVICtAiALqc4NlIp0mX4zReVqHThLKHOwkgTr/yLkWeNCJwhu6g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@pothos%2fselection-mapper@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":558524},"main":"./lib/index.js","_from":"file:pothos-selection-mapper-0.2.0.tgz","types":"./dts/index.d.ts","module":"./esm/index.js","exports":{"import":{"default":"./esm/index.js"},"require":{"types":"./dts/index.d.ts","default":"./lib/index.js"}},"scripts":{"test":"pnpm vitest run","type":"tsc --project tsconfig.type.json","build":"pnpm build:clean && pnpm build:cjs && pnpm build:dts && pnpm build:esm","build:cjs":"swc src -d lib --config-file .swcrc -C module.type=commonjs --strip-leading-paths","build:dts":"tsc","build:esm":"cp -r dts/* esm/ && swc src -d esm --config-file .swcrc -C module.type=es6 --strip-leading-paths","build:clean":"git clean -dfX esm lib"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"9fb9396e-8e97-4436-9e88-5dd290d81280"}},"_resolved":"/tmp/89ca18b46ef7102d5ebe1bffee65bc84/pothos-selection-mapper-0.2.0.tgz","_integrity":"sha512-R/MiHNomcQq0Z1oGlu25wJcES6gB2XqHWdyIQiSKJr57248Wlz+peX/I67yOWdEt1XUhm1OrwYHDsPn5NW6hGw==","repository":{"url":"git+https://github.com/hayes/pothos.git","type":"git","directory":"packages/selection-mapper"},"_npmVersion":"11.19.1","description":"shared selection-to-query walker for Pothos ORM plugins","directories":{},"_nodeVersion":"24.22.2","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.4","graphql":"^17.0.1","graphql-tag":"^2.12.6","@pothos/core":"4.17.0","@pothos/test-utils":"2.3.0","@graphql-tools/executor":"^1.5.2"},"peerDependencies":{"graphql":"^16.10.0 || ^17.0.0","@pothos/core":"*"},"_npmOperationalInternal":{"tmp":"tmp/selection-mapper_0.2.0_1794282893350_0.6072155185619904","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@pothos/selection-mapper","version":"0.3.0","keywords":["pothos","graphql","schema","typescript","plugin"],"author":{"name":"Michael Hayes"},"license":"ISC","_id":"@pothos/selection-mapper@0.3.0","maintainers":[{"name":"hayes","email":"michael@hayes.io"}],"homepage":"https://github.com/hayes/pothos#readme","bugs":{"url":"https://github.com/hayes/pothos/issues"},"dist":{"shasum":"2143b8beeaf922084f9562640372f49ee3b86734","tarball":"https://registry.npmjs.org/@pothos/selection-mapper/-/selection-mapper-0.3.0.tgz","fileCount":114,"integrity":"sha512-mZp5mW+j10N3I4HBzGntloj+D4h+Qztv/kM578EwSAAoGkVVImowLXvcW21Llmj9n0rStRYhBcdKGiHQu5xnqQ==","signatures":[{"sig":"MEUCIQDyB1qVXeMfT7rWPTKDvtvcwvUq+ugfhE4yFnjN8EhzDAIgK1Bq2mTnOkpTDjbOZNqB6XFYWEDgjAYt0ANwc5fm6Dc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIArhJ+UtDKUVLjVRV7zUPcR/8CGl2y4wzlWfkgyx4Z6hAiEAkJhuNpo2fWWK8k3uWCsAiO526j5l0K3/Y4LCjCoDgDs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@pothos%2fselection-mapper@0.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":546931},"main":"./lib/index.js","_from":"file:pothos-selection-mapper-0.3.0.tgz","types":"./dts/index.d.ts","module":"./esm/index.js","exports":{"import":{"default":"./esm/index.js"},"require":{"types":"./dts/index.d.ts","default":"./lib/index.js"}},"scripts":{"test":"pnpm vitest run","type":"tsc --project tsconfig.type.json","build":"pnpm build:clean && pnpm build:cjs && pnpm build:dts && pnpm build:esm","build:cjs":"swc src -d lib --config-file .swcrc -C module.type=commonjs --strip-leading-paths","build:dts":"tsc","build:esm":"cp -r dts/* esm/ && swc src -d esm --config-file .swcrc -C module.type=es6 --strip-leading-paths","build:clean":"git clean -dfX esm lib"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"9fb9396e-8e97-4436-9e88-5dd290d81280"}},"_resolved":"/tmp/f564c2bb3784a834266823f8f32fa058/pothos-selection-mapper-0.3.0.tgz","_integrity":"sha512-mZp5mW+j10N3I4HBzGntloj+D4h+Qztv/kM578EwSAAoGkVVImowLXvcW21Llmj9n0rStRYhBcdKGiHQu5xnqQ==","repository":{"url":"git+https://github.com/hayes/pothos.git","type":"git","directory":"packages/selection-mapper"},"_npmVersion":"11.19.1","description":"shared selection-to-query walker for Pothos ORM plugins","directories":{},"_nodeVersion":"24.22.2","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.4","graphql":"^17.0.1","graphql-tag":"^2.12.6","@pothos/core":"4.17.0","@pothos/test-utils":"2.3.0","@graphql-tools/executor":"^1.5.2"},"peerDependencies":{"graphql":"^16.10.0 || ^17.0.0","@pothos/core":"*"},"_npmOperationalInternal":{"tmp":"tmp/selection-mapper_0.3.0_1794329646798_0.3473550744889531","host":"s3://npm-registry-packages-npm-production"}},"0.3.1":{"_id":"@pothos/selection-mapper@0.3.1","bugs":{"url":"https://github.com/hayes/pothos/issues"},"dist":{"shasum":"8ce6cf13a46ec1d32dd7b5f99affb6434752f6fa","tarball":"https://registry.npmjs.org/@pothos/selection-mapper/-/selection-mapper-0.3.1.tgz","fileCount":114,"integrity":"sha512-M0bfitqeZSRNXLxDF51Nog24YQMQ0ERVfGH8ABWrVP8h+7rDBfaDX2Nf/kl6ajW3g6bxhLLfeoiEr091UObcsQ==","signatures":[{"sig":"MEUCIQCHPzyD23qTwwFKxexGzsM/rLSdM4p2QW2ViJZAQD5QngIgfjf5pXB5udOzDL+II2SW2FrPBwcsiqQtSn34bGB1lyY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICGtgsfLURSzdPMKte5H2D9w7Cb0DbkHhn+iZqs7SmNYAiEAhN9DX6iDQujHYGO1BmYZePXVwlpKZxIcpGunMX7EfHQ="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@pothos%2fselection-mapper@0.3.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":547629},"main":"./lib/index.js","name":"@pothos/selection-mapper","_from":"file:pothos-selection-mapper-0.3.1.tgz","types":"./dts/index.d.ts","author":{"name":"Michael Hayes"},"module":"./esm/index.js","exports":{"import":{"default":"./esm/index.js"},"require":{"types":"./dts/index.d.ts","default":"./lib/index.js"}},"license":"ISC","scripts":{"test":"pnpm vitest run","type":"tsc --project tsconfig.type.json","build":"pnpm build:clean && pnpm build:cjs && pnpm build:dts && pnpm build:esm","build:cjs":"swc src -d lib --config-file .swcrc -C module.type=commonjs --strip-leading-paths","build:dts":"tsc","build:esm":"cp -r dts/* esm/ && swc src -d esm --config-file .swcrc -C module.type=es6 --strip-leading-paths","build:clean":"git clean -dfX esm lib"},"version":"0.3.1","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"6f9a66c5-59cb-463e-a3e6-39fe385ff6de"}},"homepage":"https://github.com/hayes/pothos#readme","keywords":["pothos","graphql","schema","typescript","plugin"],"_resolved":"/tmp/a095762c4ca8695b29026e21818fc0c0/pothos-selection-mapper-0.3.1.tgz","_integrity":"sha512-M0bfitqeZSRNXLxDF51Nog24YQMQ0ERVfGH8ABWrVP8h+7rDBfaDX2Nf/kl6ajW3g6bxhLLfeoiEr091UObcsQ==","repository":{"url":"git+https://github.com/hayes/pothos.git","type":"git","directory":"packages/selection-mapper"},"_npmVersion":"11.19.1","description":"shared selection-to-query walker for Pothos ORM plugins","directories":{},"maintainers":[{"name":"hayes","email":"michael@hayes.io"}],"_nodeVersion":"24.22.3","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.4","graphql":"^17.0.1","graphql-tag":"^2.12.6","@pothos/core":"4.18.1","@pothos/test-utils":"2.3.0","@graphql-tools/executor":"^2.0.1"},"peerDependencies":{"graphql":"^16.10.0 || ^17.0.0","@pothos/core":"*"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/selection-mapper_0.3.1_1795469684690_0.8343989772102116"}}},"time":{"created":"2026-09-11T07:19:16.122Z","modified":"2026-11-23T21:34:45.456Z","0.1.0":"2026-09-11T07:19:16.480Z","0.2.0":"2026-11-10T03:54:53.456Z","0.3.0":"2026-11-10T16:54:06.944Z","0.3.1":"2026-11-23T21:34:44.803Z"},"bugs":{"url":"https://github.com/hayes/pothos/issues"},"author":{"name":"Michael Hayes"},"license":"ISC","homepage":"https://github.com/hayes/pothos#readme","keywords":["pothos","graphql","schema","typescript","plugin"],"repository":{"url":"git+https://github.com/hayes/pothos.git","type":"git","directory":"packages/selection-mapper"},"description":"shared selection-to-query walker for Pothos ORM plugins","maintainers":[{"name":"hayes","email":"michael@hayes.io"}],"readme":"# @pothos/selection-mapper\n\nThe selection-to-query walker shared by `@pothos/plugin-prisma` and `@pothos/plugin-drizzle`. It\nturns the selection set a resolver receives into the ORM plugin's own query format — through\nfragments, variants, directives and indirect includes — and records the loader mappings the\nplugins' field resolvers look up at resolve time.\n\nThis package is an implementation detail of those plugins. Its exports exist for them and change\nwith them: it is not a supported public API, and its versions carry no compatibility promise of\ntheir own. Use the plugins.\n\nThe surface is what those plugins import and nothing more: `Plan` (with the statics `Plan.fromInfo`\nand `Plan.forParentRow`), `Adapter` and `NodeAdapter`, the loader-map helpers (`cacheKey`,\n`forOperation`, `getLoaderMapping`, `setLoaderMappings`, `setRowFieldMapping`, `setRowMappings`),\n`mappingParentTypes`, `selectedFieldNames` and `deepEqual`. Each plugin builds the query it passes\nto a resolver itself. Prisma's `queryFromInfo` and drizzle's differ, so neither is here.\n\n## Vocabulary\n\n- **Selection** — what the GraphQL document asks for: a `SelectionNode`, a selection set, a\n  fragment. Always the input side; graphql-js owns the word.\n- **Query** — what the ORM is told to load, in the ORM's own format (prisma\n  `{ select, include, ...args }`, drizzle `DBQueryConfig`). Opaque to the walker, which hands\n  queries to the adapter and returns what the adapter serializes. The `Query` type parameter.\n- **Model** — the adapter's description of one table or prisma model. One object per model, so\n  model identity is model equality.\n- **Node** — one level of the query being built (a model, its columns, its relations, its computed\n  values), and the tree of them one root accumulates into. The adapter owns the shape; the walker\n  reads only `node.model`.\n- **Plan** — what a traversal collected for one root: the model it loads, the selection it starts\n  from, and the merges it collected, in order. A plan holds no node.\n- **Merge** — one item in a plan's list: a type's selection, a variant's, a nested selection's\n  relation query, or a field's, each with the query the adapter produced for it.\n- **Play** — to fold a plan's merges into a fresh node, in order, behind a seed selection. Every\n  merge is offered to the node being built, so this is where one is accepted or rejected and the\n  only place a mapping is recorded. A plan can be played any number of times, behind a different\n  seed each time, and a play owns its node, so a caller may merge into what it gets back.\n- **Computed value** — what a node holds that is neither a column nor a relation: a value the ORM\n  computes per row (prisma's `_count` keys, drizzle's `extras`). `node.computed` in the shared\n  contract; each ORM keeps its own word for it in what its users read.\n- **Mapping** — what a play records for a field whose merge it took, so the field's resolver can\n  find its data in the loaded row; absent means the resolver loads its own data.\n- **Position** — where a field is: a link of `{ parent, type, field, node }` running back to the\n  field an entry point was called for, handed to a select function and recorded with the field's\n  mapping. `walkParent` is the same link as the shared walk holds it.\n\n## The adapter contract\n\nAn ORM plugin subclasses `Adapter<Model, Query, NodeType>`. Six members must be answered: three\ntranslate the schema — `modelFor` (a type's `Model`), `typeSelection` and `fieldSelection` (what a\ntype and a field select, in the ORM's own `Query` format) — and three accumulate — `createNode`\nfor a model, `mergeQuery` into one, `toQuery` for the node written back. The traversal reads\nnothing of a node but its `model`, and nothing of a query at all.\n\nThe four members below those are the merge rules, and each is inherited with the answer an adapter\nthat never shares a slot between two consumers wants: `canMergeQuery` is true, `firstConflict` is\nnone, and `mergeNode` and `canMergeNode` round-trip through `toQuery`. `canMergeQuery` and\n`firstConflict` ask the same thing of different callers: one is the yes or no a play gates a merge\non, the other names the first offending key for an error message. An adapter that gives every\nconsumer its own slot therefore writes six methods and nothing more.\n\n`MergeOptions` says how one merge differs from a plain one: `asQuery` (a relation query adds no\ncolumns), `lenient` (conflicting keys are left out rather than refused), `ignoreArgs` (the node's\nown top-level arguments are not compared), and the `alias` the query came from, so an adapter may\nmerge same-named relations into one node (prisma, drizzle) or keep one slot per selected field.\n`skipDeferredFragments` defaults to true.\n\n`NodeAdapter<Model, Query>` is what the prisma and drizzle adapters extend: the node tree of\n`node.ts` (columns, relations, computed values, arguments) with every merge rule this package\nowns. A subclass writes `visitQuery`, the key loop of its own query, reported key by key to a\n`QueryVisitor`; `toQuery`, the node written back; and optionally `computedConflicts` when its\ncomputed values are not compared by value — three methods on top of the three translation ones.\nThe visitor is reused down the tree, so a merge allocates only what the subclass's own key loop\nalready allocated. An ORM whose query is not a tree of columns, relations and computed values\nextends `Adapter` directly.\n\n## What an adapter must uphold\n\n- A field's `query` may be async, and what is built from it is then a promise. Every API that\n  takes one returns a `MaybePromise`, and a caller either awaits it or hands it on.\n- A merge holds the query the adapter produced for it by reference, and a play merges that same\n  object however many times the plan is played. A select function that returns a query and then\n  mutates it changes what a later play builds. Nothing copies it, because a query is opaque to\n  this package and could only be copied by round-tripping it through the adapter on every field.\n- Every play records its loader mappings on the request context, which pothos requires to be an\n  object, per execution: operations and subscription events sharing a context don't see each\n  other's. An execution is told apart by the root link of its path under graphql-js and\n  `@graphql-tools/executor` (Yoga), which build a path chain for each execution and subscription\n  event. There each root field has a path chain, and so a cache, of its own, which is enough\n  because a mapping is only read beneath the root field that recorded it. `getAbortSignal` can't\n  tell executions apart: `@graphql-tools/executor` 2 builds a new one for every resolver, and the\n  signal it returns is the caller's, shared by every event of a subscription. Under graphql-jit, which builds a new path for\n  every resolver, it is told apart by its `variableValues`, coerced afresh for each execution and\n  event. The plugins pass `getLoaderMapping` the resolver's `info`. An adapter whose resolvers\n  read a loaded row another way simply never looks them up.\n- Every select function is handed the `Position` of the field it plans: the field's node, the type\n  it was walked on, and a link to the position of the field the plan hangs beneath. The walker\n  reads none of it — an adapter that wants a path or a list of segments walks `parent` and\n  materializes its own — and records it with the field's mapping, so a resolver can ask the same\n  question the select path asked.\n- Reading `parent` during planning stops the walk it reads through from being shared, so each\n  place the field appears is walked again with its own path. `walkParent` reads the shared walk's\n  parents without that cost; they are the first invocation's, so use it only for a name that must\n  agree with itself, not for where a field really is.\n","readmeFilename":"README.md"}