{"id":21094443,"url":"https://github.com/graphql-community/graphql-directive-computed-property","last_synced_at":"2025-05-16T14:33:19.184Z","repository":{"id":31752629,"uuid":"128517755","full_name":"graphql-community/graphql-directive-computed-property","owner":"graphql-community","description":"GraphQL directive for create computed property","archived":false,"fork":false,"pushed_at":"2022-12-08T17:52:53.000Z","size":787,"stargazers_count":30,"open_issues_count":19,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-13T14:08:08.091Z","etag":null,"topics":["computed-properties","directive","graphql","graphql-directive"],"latest_commit_sha":null,"homepage":"","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/graphql-community.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-04-07T10:24:15.000Z","updated_at":"2023-06-12T06:56:23.000Z","dependencies_parsed_at":"2023-01-14T19:42:17.354Z","dependency_job_id":null,"html_url":"https://github.com/graphql-community/graphql-directive-computed-property","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-community%2Fgraphql-directive-computed-property","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-community%2Fgraphql-directive-computed-property/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-community%2Fgraphql-directive-computed-property/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-community%2Fgraphql-directive-computed-property/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-community","download_url":"https://codeload.github.com/graphql-community/graphql-directive-computed-property/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225433465,"owners_count":17473599,"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":["computed-properties","directive","graphql","graphql-directive"],"created_at":"2024-11-19T22:17:30.689Z","updated_at":"2024-11-19T22:17:31.270Z","avatar_url":"https://github.com/graphql-community.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# graphql-directive-computed-property\n\n[![Version][version-badge]][package]\n[![downloads][downloads-badge]][npmtrends]\n[![PRs Welcome][prs-badge]][prs]\n[![MIT License][license-badge]][build]\n\n# Introduction\n\nThe directive allows creating a computed property from fields where is defined.\n\n# Table of Contents\n\n* [Introduction](#introduction)\n* [Installation](#installation)\n* [Usage](#Usage)\n* [Parameters](#parameters)\n* [Contributing](#contributing)\n* [LICENSE](#license)\n\n# Installation\n\n```\nyarn add graphql-directive-computed-property\n```\n\n_This package requires [graphql](https://www.npmjs.com/package/graphql) and [graphql-tools](https://www.npmjs.com/package/graphql-tools) as peer dependency_\n\n# Usage\n\n```js\nconst { makeExecutableSchema } = require('graphql-tools');\nconst computedDirective = require('graphql-directive-computed-property');\n\nconst typeDefs = `\n  type User {\n    firstName: String\n    lastName: String\n    fullName: String @computed(value: \"$firstName $lastName\")\n  }\n\n  type Query {\n    me: User\n  }\n`;\n\nconst resolvers = {\n  Query: {\n    me: () =\u003e ({\n      firstName: 'John',\n      lastName: 'Doe',\n    }),\n  },\n};\n\nmodule.exports = makeExecutableSchema({\n  typeDefs,\n  resolvers,\n  schemaDirectives: {\n    computed: computedDirective,\n  },\n});\n```\n\nQuery: \n\n```graphql\nquery {\n  me {\n    fullName\n  }\n}\n```\n\nResult: \n\n```js\n{\n  fullName: 'John Doe'\n}\n```\n### Computed property work well with other directives like [@rest](https://www.npmjs.com/package/graphql-directive-rest):\n\nExample:\n\n```admin: String @rest(url: \"${URL_TO_API}\") @computed(value: \"Are you admin? $admin\")```\n\n\n# Directive Parameters\n\nDirective params:\n\n### `value`: String\n\nThe calculated value. It can contain other fields from the type in which it is defined.\n\nExample: \n\n`@computed(value: \"$firstName $lastName\")` \n\n`@computed(value: \"$price $\")` \n\n## Contributing\n\nI would love to see your contribution. ❤️\n\nFor local development (and testing), all you have to do is to run `yarn` and then `yarn dev`. This will start the Apollo server and you are ready to contribute :tada:\n\nRun yarn test (try `--watch` flag) for unit tests (we are using Jest)\n\n# LICENSE\n\nThe MIT License (MIT) 2018 - Luke Czyszczonik - \u003cmailto:lukasz.czyszczonik@gmail.com\u003e\n\n[npm]: https://www.npmjs.com/\n[node]: https://nodejs.org\n[build-badge]: https://img.shields.io/travis/graphql-community/graphql-directive-computed-property.svg?style=flat-square\n[build]: https://travis-ci.org/graphql-community/graphql-directive-computed-property\n[coverage-badge]: https://img.shields.io/codecov/c/github/graphql-community/graphql-directive-computed-property.svg?style=flat-square\n[coverage]: https://codecov.io/github/graphql-community/graphql-directive-computed-property\n[version-badge]: https://img.shields.io/npm/v/graphql-directive-computed-property.svg?style=flat-square\n[package]: https://www.npmjs.com/package/graphql-directive-computed-property\n[downloads-badge]: https://img.shields.io/npm/dm/graphql-directive-computed-property.svg?style=flat-square\n[npmtrends]: http://www.npmtrends.com/graphql-directive-computed-property\n[license-badge]: https://img.shields.io/npm/l/graphql-directive-computed-property.svg?style=flat-square\n[license]: https://github.com/graphql-community/graphql-directive-computed-property/blob/master/LICENSE\n[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square\n[prs]: http://makeapullrequest.com\n[donate-badge]: https://img.shields.io/badge/$-support-green.svg?style=flat-square\n[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square\n[coc]: https://github.com/graphql-community/graphql-directive-computed-property/blob/master/CODE_OF_CONDUCT.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-community%2Fgraphql-directive-computed-property","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-community%2Fgraphql-directive-computed-property","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-community%2Fgraphql-directive-computed-property/lists"}