{"id":22886394,"url":"https://github.com/theGlenn/graphql-resolved","last_synced_at":"2025-08-11T21:31:46.094Z","repository":{"id":57253601,"uuid":"135091684","full_name":"theGlenn/graphql-resolved","owner":"theGlenn","description":":shipit: Framework agnostic GraphQL resolvers composition","archived":false,"fork":false,"pushed_at":"2018-06-08T16:23:02.000Z","size":93,"stargazers_count":17,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-01T21:35:41.581Z","etag":null,"topics":["authentication","graphql","graphql-application","graphql-schema","graphql-server","javascript","nodejs","resolvers"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/theGlenn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-28T00:27:17.000Z","updated_at":"2019-08-29T08:21:11.000Z","dependencies_parsed_at":"2022-08-31T22:20:14.635Z","dependency_job_id":null,"html_url":"https://github.com/theGlenn/graphql-resolved","commit_stats":null,"previous_names":["theglenn/graphql-resolvers-chain"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theGlenn%2Fgraphql-resolved","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theGlenn%2Fgraphql-resolved/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theGlenn%2Fgraphql-resolved/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theGlenn%2Fgraphql-resolved/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theGlenn","download_url":"https://codeload.github.com/theGlenn/graphql-resolved/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229399696,"owners_count":18067079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["authentication","graphql","graphql-application","graphql-schema","graphql-server","javascript","nodejs","resolvers"],"created_at":"2024-12-13T20:18:30.463Z","updated_at":"2024-12-13T20:18:31.841Z","avatar_url":"https://github.com/theGlenn.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\u003cimg src=\"https://imgur.com/rdP6rmb.png\" /\u003e\u003c/div\u003e\n\n# :shipit: graphql-resolved :shipit:\n\u003e Provides a **middleware**-like capability to your GraphQL api by enabling the combination of multiple resolvers through a simple and expressive API. \n\nResolvers solved :shipit:\n\n[![NPM][npm-image]][npm-url]\n\n[![Build Status][travis-image]][travis-url]\n[![npm version](https://badge.fury.io/js/graphql-resolved.svg)](https://badge.fury.io/js/graphql-resolved)\n\n[npm-url]: https://nodei.co/npm/graphql-resolved/\n[npm-image]: https://nodei.co/npm/graphql-resolved.png?downloads=true\u0026downloadRank=true\u0026stars=true\n\n[travis-image]: https://travis-ci.com/theGlenn/graphql-resolved.svg?branch=master\n[travis-url]: https://travis-ci.com/theGlenn/graphql-resolved\n\n## Installing\n\n```bash\nnpm i graphql-resolved --save\n```\n\n##### or\n\n```bash\nyarn add graphql-resolved\n```\n\n## Usage\n### Create your first resolver using the `chain`, `protect` or `apply` api\n\n#### `chain`\nReturn a resolver that is the sum of the ones in the supplied array.\n*The execution order follows the order from left to right*.\nThe last resolver being the one to return the final expect value.\n```chain([1, 2, 3, 4])``` \n\n```ts\nimport { chain } from 'graphql-resolved';\nimport { isAuthenticated, isAdmin, isTopContributer } from './auth/resolvers';\nimport * as UserResolvers from './user/resolvers';\n\nconst getMe = chain([isAuthenticated, UserResolvers.getMe])\n\nconst Query = {\n  getMe\n}\n\nconst resolvers = {\n  Query,\n}\n```\n\n#### `apply`\nApplies a list of `resolvers` to each of those supplied by the `to` object.\n- `resolvers` *The execution order follows the order from left to right*.\n```ts\nconst allUserResolvers = apply({ resolvers: [isAuthenticated], to: UserResolvers })\nconst Query = {\n  ...allUserResolvers\n}\n```\n\n#### `protect`\nThe protect key work take three arguments:\n- `it` (Optional) a resolver function, if supplied `protect` returns a new resolver function\n- `all`(Optional) a map of resolvers, if supplied `protect` returns an object with the exact same resolvers names as keys\n- `using` a list of resolvers to apply(*The order matters from left to right*).\n\n```ts\nconst getMe = protect({\n  it: UserResolvers.getMe,\n  using: [isAuthenticated]\n});\n\nconst adminResolvers = protect({\n  all: { PostResolvers.deletePost, PostResolvers.correctPost },\n  using: [isAuthenticated, isAdmin]\n});\n\nconst Query = {\n  getMe\n  ...adminResolvers\n}\n```\n\n## Tests\n\n```bash\nnpm test\n```\n\n##### or\n\n```bash\nyarn test\n```\n\n## Contributing\n\nPlease feel free to drop an issue or propose a feature or pull request.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FtheGlenn%2Fgraphql-resolved","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FtheGlenn%2Fgraphql-resolved","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FtheGlenn%2Fgraphql-resolved/lists"}