{"_id":"graphql-annotations","_rev":"3-cf40d03653450f3d089cd05278aefb2e","name":"graphql-annotations","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"graphql-annotations","version":"0.0.1","description":"Annotate a GraphQL Schema","author":{"name":"Guillaume Chau","email":"guillaume.b.chau@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Akryum/graphql-annotations.git"},"bugs":{"url":"https://github.com/Akryum/graphql-annotations/issues"},"homepage":"https://github.com/Akryum/graphql-annotations#readme","main":"src/index.js","scripts":{"lint":"eslint .","test:unit":"jest","test:types":"tsc","test:all":"yarn run lint && yarn run test:unit && yarn run test:types","prepublishOnly":"yarn run test:all"},"dependencies":{"safe-eval":"^0.4.1"},"devDependencies":{"eslint":"^5.12.1","eslint-plugin-node":"^8.0.1","eslint-plugin-vue-libs":"^3.0.0","jest":"^24.0.0","typescript":"^3.2.2"},"gitHead":"d3fe7766d5b49cd011963fe830b7d09cb916993b","_id":"graphql-annotations@0.0.1","_npmVersion":"6.1.0","_nodeVersion":"10.4.1","_npmUser":{"name":"akryum","email":"guillaume.b.chau@gmail.com"},"dist":{"integrity":"sha512-SSW2Wab0VSgNZs3LQzCVjzV0SyDvdUZ/MPakh3EsV1RER0fEy9ffUgATYKbbpwgeP2TBioh4f8jfGEOKTLkVHA==","shasum":"9272d74191976ced97e59b8107d106a02d2f8e80","tarball":"https://registry.npmjs.org/graphql-annotations/-/graphql-annotations-0.0.1.tgz","fileCount":12,"unpackedSize":168524,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcUGMFCRA9TVsSAnZWagAA/sMP/068zThONfwFkntCwKAe\nrmem/ske470w+89oR2o/2k7v1Kp/k4gRVRrakpjUO088v8y/c5ziCX2A/o30\nXifwD70YNNJKQ8Yc9aUjBzb++cNxW/ViXyFR8VKNQsNqRY8Q7X54eIeHBn1z\nKcbXTfPzJ2n6G7W9SODpvuWRSjIogEqT0GL7SZ3QKxBOHUmW26cv3TW0nFPL\nsd3mXaVqq6yAhF2nv/y2wYXvBx0PA7NRuHzczl3mf1oa6CCpN2B/A5Lrf5UL\nU/klJNfSymJKU1cLQEnHANTm9w9HhyLAZfij5snMiSwdc6zJTXyD9A0Hiila\nu1UH6p9W8Q2B/fvT0zWGnpl6wrFhw2PvvsTauPBoFaSF1eQV/lOnVyVg7/5r\n1OMG/5WGYQvcQtoTYsaBgsknPFK350avAETM/CN7T+SSOdns8E4jCmU4lx6+\nKXF3sW6saZ/81CFZZb30mugJcJZBC8zp+PZ6n/mZZMruvBWyje8WA5qoah2e\nBz34Dvi6bZwe/MGw1CzhlguA/UsKAHn6d9S7FJFqtRLe64vCYi37LGVthP9J\nlAiUtTYF6EeutluLHswAVo3GRN+Zj+hBeEkk9lOci/cv25aMDHBcpl2OZrXZ\n+EPaF0j47j7MpNcp0P8cjnNPXL/50flOiQe2Rid+eXONV6M05tGDan9e+h7l\nfiMs\r\n=sWNc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDPit+R4IjmI/9kZEh+0hRxWpEe+ex0EIj4FBaQFjI1+gIhAK3WR30wmD4pGFqvFegucYXNyK7TS/k6ReSMhWsgKcC3"}]},"maintainers":[{"name":"akryum","email":"guillaume.b.chau@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-annotations_0.0.1_1548772100797_0.3938030351004371"},"_hasShrinkwrap":false},"0.0.2":{"name":"graphql-annotations","version":"0.0.2","description":"Annotate a GraphQL Schema","author":{"name":"Guillaume Chau","email":"guillaume.b.chau@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Akryum/graphql-annotations.git"},"bugs":{"url":"https://github.com/Akryum/graphql-annotations/issues"},"homepage":"https://github.com/Akryum/graphql-annotations#readme","main":"src/index.js","typings":"typings/index.d.ts","scripts":{"lint":"eslint .","test:unit":"jest","test:types":"tsc","test:all":"yarn run lint && yarn run test:unit && yarn run test:types","prepublishOnly":"yarn run test:all"},"dependencies":{"safe-eval":"^0.4.1"},"devDependencies":{"eslint":"^5.12.1","eslint-plugin-node":"^8.0.1","eslint-plugin-vue-libs":"^3.0.0","jest":"^24.0.0","typescript":"^3.2.2"},"gitHead":"259a2d908edef20ab54cb486a06ab91890a777e2","_id":"graphql-annotations@0.0.2","_npmVersion":"6.1.0","_nodeVersion":"10.4.1","_npmUser":{"name":"akryum","email":"guillaume.b.chau@gmail.com"},"dist":{"integrity":"sha512-0MaLINQYCxW+o73w1ALyUK0aVAu3tyTIwgXFm/T6O/IF7Fu7AgQj2k8bJX998fC3a1la8Ys3shMofeOUNoCJ/Q==","shasum":"5ab5117f84dc14ad3361d0fd181bf3f9dd0a6583","tarball":"https://registry.npmjs.org/graphql-annotations/-/graphql-annotations-0.0.2.tgz","fileCount":13,"unpackedSize":168656,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcUGi4CRA9TVsSAnZWagAAFMAP/163+CuDHV+enKB6hNAS\n6eF/hcZ/vwOGJ3FuD5bkC4w1PUk23ItCCVz+/OmzHAR0BVbUzP8ZwG7LgSGR\npfzkkAFld0OYzQ1LBwRcYSJgRBeUjXBrV8SqyBr/ToPf47dmvL7VC32rK+KP\nJY4HTK7wIVlcs3n4i3pB17hxiq7vumutgB2LO0yyLuhH4MtDbbAHfLwzlT+z\nPNj55/bOFGlYc+xVnxNcYQsWZ2zVN5+nurbPiwiY2LQFUZ7B13BODjJKGFuy\nDHRefjE0vzBxKa1jGh80VCwYUs8G46tDFjy+kkIjC4IzWbC7dpTZNODqPyBh\nysBbtKHfkECY/b7FW2ga82QcC0FX+FUf+HhvY7twnaRRNVykpXLcznx5+psF\nI/joao28ukmLCeDDuqZkGuBNCHyL9F9n33xCwJAWDx9XnxNyhsLUaoiOmY08\nc+rgwELXlWBFGo81ZjBQXDBzLLhsBZnu8+BXs7rpJYDyAYi/9vT1DBAy55Zw\nmZ1oD0pysYBKmzEkJJ6jr6JVkb59lCHmxYHPFhv1dqQ+9Yro1IDsjdVJllkx\nzIfwJq+i42RWKls4JCDwpFsugqv41UGD8flXWG4uV0tto582S0xKBG/0c8el\ntbhE11NDTHRTqklp66thOwpl3Qq+cdwsMkBnD7A0RtNW8AmROW/7D4kH+IrA\nSfkL\r\n=Q1sA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDRA2k0MkZP9HhZjpKan4sylOpOxSza4OZx6cEqvPSxUwIgSMukplwZpViBHHZKfEEA2UjZz9GWHtl+qE3UWN9LSp8="}]},"maintainers":[{"name":"akryum","email":"guillaume.b.chau@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-annotations_0.0.2_1548773560352_0.10270222254603412"},"_hasShrinkwrap":false},"0.0.3":{"name":"graphql-annotations","version":"0.0.3","description":"Annotate a GraphQL Schema","author":{"name":"Guillaume Chau","email":"guillaume.b.chau@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Akryum/graphql-annotations.git"},"bugs":{"url":"https://github.com/Akryum/graphql-annotations/issues"},"homepage":"https://github.com/Akryum/graphql-annotations#readme","main":"src/index.js","typings":"typings/index.d.ts","scripts":{"lint":"eslint .","test:unit":"jest","test:types":"tsc","test:all":"yarn run lint && yarn run test:unit && yarn run test:types","prepublishOnly":"yarn run test:all"},"dependencies":{"safe-eval":"^0.4.1"},"devDependencies":{"eslint":"^5.12.1","eslint-plugin-node":"^8.0.1","eslint-plugin-vue-libs":"^3.0.0","jest":"^24.0.0","typescript":"^3.2.2"},"gitHead":"ab40c34aa158b2d51354ac73bfc46709083652cc","_id":"graphql-annotations@0.0.3","_npmVersion":"6.1.0","_nodeVersion":"10.4.1","_npmUser":{"name":"akryum","email":"guillaume.b.chau@gmail.com"},"dist":{"integrity":"sha512-PoBix+oEl4xNAmpJro40DqW9YnKDwFG6saffV7Fj95fffkXJeBIp21xjFTBtUnsJD7lNhL++j2Go8nq5DVzm4w==","shasum":"e257b07dceaa7e6fbb7fd73cca191693bd16bf98","tarball":"https://registry.npmjs.org/graphql-annotations/-/graphql-annotations-0.0.3.tgz","fileCount":16,"unpackedSize":169945,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcVaE1CRA9TVsSAnZWagAAaiQQAIzugzcbz5WNVrJzJrrZ\naP6DHAxUtW8/iu7Qukx9iKg8x1/5g/s7/n402hlKIZuX7+jl68PE1z+qc+Qc\nnwAp++4FxqvLK0vSNbu6rShIKm+2ur7g3lRePlMMu3F4UWO2pR/hmgpsHU/h\n0FofAXj95T7SjT8RHJvA2jF64UhpI4XGo3v+1M1LLeCbJ7kfEBqI7oBHAUFY\n8VfRt4vdO3E64xqyrgdCj3tbk0H91RmwfHDFa2uIzosIFQtwLVLDPSa4i3KF\nfnX4D7Zd1MuitM6OfqzrcSfxNZAHFSeK0p7ZYjdLo0fwIztbFSLXpPhM0JE0\nJL87At5PIZRduo2W57xajAwbqq16hlEIR46I6On/1+kP+ux3mCx2PWlIZRJu\nFThMwbDSPSDGmZW4fQqTYVohWJjvIDWoouFIyeNiA6MSw09vqJe0x6nssqTv\nacmZLaMyRXCqu/rAPK2hzj0hDXFDzjudYO6pvRkgsHn1IiULvWbJCovBWPI/\nla5XK6OAQN2+eeoItU3hpHFwlETN/Ks1OzMVVK58gE34X9wOoti01nPr43Fe\nEPm6DiPZNj/9VqsSoiFg9DUlhNakjRtdA3dvjcRcvjgmUd7DYRMXuEwsmFdi\n3w9mIVOkwJY6lN9dp0m6WePXxkchUgPDja+tTjvj1lTwG3QDiyd6Ba+nkOvg\ntFqW\r\n=xRRL\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDFJvrcQFK5lgqiSUUb+V3WkaQnFHpPNVYyl4h+w+5/JgIhANCdXUk8xmn6g59ezoRA1C8pCDoAql7Z2tJMZhYZF9YQ"}]},"maintainers":[{"name":"akryum","email":"guillaume.b.chau@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-annotations_0.0.3_1549115700713_0.46754668244543973"},"_hasShrinkwrap":false}},"time":{"created":"2019-01-29T14:28:20.796Z","0.0.1":"2019-01-29T14:28:20.903Z","modified":"2022-05-04T02:41:04.062Z","0.0.2":"2019-01-29T14:52:40.467Z","0.0.3":"2019-02-02T13:55:01.228Z"},"maintainers":[{"name":"akryum","email":"guillaume.b.chau@gmail.com"}],"description":"Annotate a GraphQL Schema","homepage":"https://github.com/Akryum/graphql-annotations#readme","repository":{"type":"git","url":"git+https://github.com/Akryum/graphql-annotations.git"},"author":{"name":"Guillaume Chau","email":"guillaume.b.chau@gmail.com"},"bugs":{"url":"https://github.com/Akryum/graphql-annotations/issues"},"license":"MIT","readme":"# graphql-annotations\n\n[![circleci](https://img.shields.io/circleci/project/github/Akryum/graphql-annotations/master.svg)](https://circleci.com/gh/Akryum/graphql-annotations)\n\nAnnotate a GraphQL schema\n\n<p align=\"center\">\n  <a href=\"https://www.patreon.com/akryum\" target=\"_blank\">\n    <img src=\"https://c5.patreon.com/external/logo/become_a_patron_button.png\" alt=\"Become a Patreon\">\n  </a>\n</p>\n\n## Sponsors\n\n### Silver\n\n<p align=\"center\">\n  <a href=\"https://vueschool.io/\" target=\"_blank\">\n    <img src=\"https://vueschool.io/img/logo/vueschool_logo_multicolor.svg\" alt=\"VueSchool logo\" width=\"200px\">\n  </a>\n</p>\n\n### Bronze\n\n<p align=\"center\">\n  <a href=\"https://vuetifyjs.com\" target=\"_blank\" title=\"Vuetify\">\n    <img src=\"https://cdn.discordapp.com/attachments/537832759985700914/537832771691872267/Horizontal_Logo_-_Dark.png\" width=\"100\">\n  </a>\n</p>\n\n## Installation\n\n```bash\nnpm i graphql-annotations\n```\n\n## Usage\n\n### Annotations parsing\n\nHere is a very basic example with a `namespace` (here `'db'`) and a `description` that needs to be parsed:\n\n```js\nconst { parseAnnotations } = require('graphql-annotations')\n\nconst result = parseAnnotations('db', `\n  This is a description\n  @db.length: 200\n  @db.foo: 'bar'\n  @db.unique\n  @db.index: { name: 'foo', type: 'string' }\n`)\n\nconsole.log(result)\n```\n\nThis will output an object containing the annotations:\n\n```js\n{\n  length: 200,\n  foo: 'bar',\n  unique: true,\n  index: { name: 'foo', type: 'string' }\n}\n```\n\nIn a GraphQL schema, you can use the `description` property on `GraphQLObjectType`, `GraphQLField`...\n\n```js\nconst { parseAnnotations } = require('graphql-annotations')\nconst { buildSchema, isObjectType } = require('graphql')\n\nconst schema = buildSchema(`\n  \"\"\"\n  @db.table: 'users'\n  \"\"\"\n  type User {\n    \"\"\"\n    @db.primary\n    \"\"\"\n    id: ID!\n  }\n`)\n\nconst typeMap = schema.getTypeMap()\nfor (const key in typeMap) {\n  const type = typeMap[key]\n  // Tables\n  if (isObjectType(type)) {\n    const typeAnnotations = parseAnnotations('db', type.description)\n    console.log(type.name, typeAnnotations)\n    const fields = type.getFields()\n    for (const key in fields) {\n      const field = fields[key]\n      const fieldAnnotations = parseAnnotations('db', field.description)\n      console.log(field.name, fieldAnnotations)\n    }\n  }\n}\n```\n\nWhich will output:\n\n```js\nUser { table: 'users' }\nid { primary: true }\n```\n\n### Strip annotations\n\nSometimes it will be helpful to strip the annotations from the description. For example, you may not want to display them in a GraphQL schema explorer.\n\n```js\nconst { stripAnnotations } = require('graphql-annotations')\n\nconst result = stripAnnotations('db', `\n  This is a description\n  @db.length: 200\n  @db.foo: 'bar'\n  @db.unique\n  @db.index: { name: 'foo', type: 'string' }\n`)\n\nconsole.log(result)\n```\n\nThe result will be:\n\n```js\n`\n  This is a description\n`\n```\n","readmeFilename":"README.md"}