{"id":49395276,"url":"https://github.com/flesch/graphql-flatten-path","last_synced_at":"2026-04-28T15:47:13.776Z","repository":{"id":48023312,"uuid":"169800148","full_name":"flesch/graphql-flatten-path","owner":"flesch","description":"Flatten a GraphQL resolver's `info.path` into an array of field names.","archived":false,"fork":false,"pushed_at":"2023-01-03T16:21:25.000Z","size":198,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-19T06:08:16.371Z","etag":null,"topics":["apollo","apollo-server","flatten","graphql","nodejs","path","resolvers","traversal"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flesch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-08T21:16:49.000Z","updated_at":"2021-11-15T08:54:28.000Z","dependencies_parsed_at":"2023-02-01T07:46:34.137Z","dependency_job_id":null,"html_url":"https://github.com/flesch/graphql-flatten-path","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/flesch/graphql-flatten-path","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flesch%2Fgraphql-flatten-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flesch%2Fgraphql-flatten-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flesch%2Fgraphql-flatten-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flesch%2Fgraphql-flatten-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flesch","download_url":"https://codeload.github.com/flesch/graphql-flatten-path/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flesch%2Fgraphql-flatten-path/sbom","scorecard":{"id":403053,"data":{"date":"2025-08-11","repo":{"name":"github.com/flesch/graphql-flatten-path","commit":"48f731d830d353d0033826fb4f805d24fe3afe58"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/3 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"32 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T20:31:47.380Z","repository_id":48023312,"created_at":"2025-08-18T20:31:47.381Z","updated_at":"2025-08-18T20:31:47.381Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32387923,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo","apollo-server","flatten","graphql","nodejs","path","resolvers","traversal"],"created_at":"2026-04-28T15:47:12.947Z","updated_at":"2026-04-28T15:47:13.768Z","avatar_url":"https://github.com/flesch.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphql-flatten-path\n\nThe `info` argument of a GraphQL resolver [can often be mysterious](https://www.prisma.io/blog/graphql-server-basics-demystifying-the-info-argument-in-graphql-resolvers-6f26249f613a/), but it doesn't have to be! `graphql-flatten-path` will \"flatten\" that path taken through each resolver, resulting in a one dimensional array of `fieldNames`.\n\n![flatten](https://user-images.githubusercontent.com/13259/52522115-90c9fc00-2c46-11e9-8803-4d1570374d51.png)\n\n## Install\n\nTo get started, add `graphql-flatten-path` to your project:\n\n\u003cdiv\u003e\n  \u003cpre\u003e$ npm install --save \u003ca href=\"https://www.npmjs.com/package/graphql-flatten-path\"\u003egraphql-flatten-path\u003c/a\u003e\u003c/pre\u003e\n\u003c/div\u003e\n\n## Usage\n\n`graphql-flatten-path` is helpful when you're re-using resolvers or extending and stitching parts of a schema together, and need to know how the current field is nested under its ancestors.\n\nIt can be cumbersome to traverse a field's ancestors using `info.path`, which looks something like this:\n\n```js\n{\n  \"prev\": {\n    \"prev\": {\n      \"prev\": {\n        \"key\": \"merchant\"\n      },\n      \"key\": \"transactions\"\n    },\n    \"key\": 1\n  },\n  \"key\": \"amount\"\n}\n```\n\nInstead, include `graphql-flatten-path` in your resolver to flatten `info.path` to an array of field names.\n\n```diff\n  import { graphql } from 'graphql';\n+ import flatten from 'graphql-flatten-path';\n\n  const resolvers = {\n    Query: {\n      merchant: async (parent, args, context, info) =\u003e {\n+       const path = flatten(info.path, info.operation);\n+       // path =\u003e ['query', 'merchant']\n        return context.db.getMerchants();\n      },\n      transactions: async (parent, args, context, info) =\u003e {\n+       const path = flatten(info.path);\n+       // path =\u003e ['transactions', index]\n        return context.db.transactions;\n      },\n    },\n    Transaction: {\n      amount: async (parent, args, context, info) =\u003e {\n+       const path = flatten(info.path, info.operation);\n+       // path =\u003e ['query', 'merchant', 'transactions', 1, 'amount']\n+       //      or ['query', 'transactions', index, 'amount']\n        return formatCurrency(parent.amount);\n      },\n    },\n  };\n```\n\nFor a more advanced use case, take a look at the [included example project](https://github.com/flesch/graphql-flatten-path/blob/master/example) that uses `graphql-flatten-path` inside a \"[middleware](https://github.com/prisma/graphql-middleware/)\" function to log the execution time of each resolver (and show a warning if a resolver took too long).\n\n```\nWARNING: query.merchant ==\u003e 980ms ∙ exceeds the threshold by 80ms!\nINFO: query.merchant.id ==\u003e 427ms\nINFO: query.merchant.name ==\u003e 682ms\nINFO: query.merchant.transactions ==\u003e 749ms\nINFO: query.merchant.transactions.0.id ==\u003e 412ms\nINFO: query.merchant.transactions.1.amount ==\u003e 438ms\nINFO: query.merchant.transactions.1.id ==\u003e 453ms\nINFO: query.merchant.transactions.0.amount ==\u003e 504ms\nWARNING: query.merchant.transactions.1.date ==\u003e 929ms ∙ exceeds the threshold by 29ms!\n```\n\n## Motivation\n\nNot to say this module doesn't have merit, but it could have been as simple as something like this:\n\n```js\nimport find from 'find-key';\nexport default function (path) =\u003e {\n  return find(path, 'key');\n};\n```\n\n🙀 So why didn't I use an existing library like [find-key](https://github.com/simon-p-r/find-key)? Because I wanted to write something in Typescript and I like recursion, and I wanted to write something in Typescript and I like recursion.\n\n## Contributing\n\n[**graphql-flatten-path**](https://npm.im/graphql-flatten-path) is maintained by [John Flesch](mailto:john@fles.ch). Contributions are very much welcome!\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2019 John Flesch \u003cjohn@fles.ch\u003e (https://github.com/flesch)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\u003cp align=\"center\"\u003e\u003cbr /\u003e\u003csup\u003e🐶 Made with \u003ca href=\"https://www.instagram.com/murphythebeast/\"\u003ea 7lb chiweenie\u003c/a\u003e on my lap — near Chicago, IL\u003c/sup\u003e\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflesch%2Fgraphql-flatten-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflesch%2Fgraphql-flatten-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflesch%2Fgraphql-flatten-path/lists"}