{"name":"codemirror-graphql","version":"0.5.7","license":"BSD-3-Clause","_id":"codemirror-graphql@0.5.7","maintainers":[{"name":"leebyron","email":"lee@leebyron.com"}],"contributors":[{"name":"Hyohyeon Jeong","email":"asiandrummer@fb.com"},{"url":"http://leebyron.com/","name":"Lee Byron","email":"lee@leebyron.com"}],"homepage":"https://github.com/graphql/codemirror-graphql","bugs":{"url":"https://github.com/graphql/codemirror-graphql/issues"},"dist":{"shasum":"5165eb08e2a85f8e754be3b946487262098be208","tarball":"http://registry-npm.ywwl.com/codemirror-graphql/download/codemirror-graphql-0.5.7.tgz","integrity":"sha512-j/y9k6S+t/dXeSN0bjkzE1iSvEHYzPw+jJkN+XXY7HDRbTUHqQgYjGUIE02a0eGjukKG+dN9zk3H+5kxRwou+g==","signatures":[{"sig":"MEUCIFHB5O/T+9rdwAf8wnd1dwb5I/xKIPt0h7DwOtTOtrmKAiEAwYfbgmzIoYMNIzy8cvlI2LDGoZ+U7DQZn04BcsF6TOo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":19971,"noattachment":false,"key":"/codemirror-graphql/-/codemirror-graphql-0.5.7.tgz"},"_from":".","babel":{"loose":["es6.classes","es6.destructuring","es6.modules","es6.properties.computed","es6.spread","es6.templateLiterals"]},"files":["hint.js","mode.js","lint.js","utils","variables","results","README.md","LICENSE"],"_shasum":"5165eb08e2a85f8e754be3b946487262098be208","gitHead":"8bd87fe8a631c7be2f03e3968f93c1aa5383f38e","options":{"mocha":"--full-trace --require resources/mocha-bootload src/**/__tests__/**/*-test.js"},"scripts":{"lint":"eslint src","test":"npm run lint && npm run testonly","build":"babel src --ignore __tests__ --out-dir .","check":"flow check","watch":"babel --optional runtime resources/watch.js | node","testonly":"mocha $npm_package_options_mocha","prepublish":". ./resources/prepublish.sh","preversion":". ./resources/checkgit.sh && npm test"},"_npmUser":{"name":"leebyron","email":"lee@leebyron.com"},"repository":{"url":"git+ssh://git@github.com/graphql/codemirror-graphql.git","type":"git"},"_npmVersion":"3.10.3","description":"GraphQL mode and helpers for CodeMirror.","directories":{},"_nodeVersion":"6.4.0","devDependencies":{"chai":"3.5.0","sane":"1.3.4","babel":"5.8.23","jsdom":"8.3.0","mocha":"2.4.5","eslint":"1.10.3","graphql":"0.7.0","flow-bin":"0.22.1","babel-core":"5.8.23","codemirror":"5.13.4","chai-subset":"1.2.2","babel-eslint":"4.1.8"},"peerDependencies":{"graphql":"^0.6.0 || ^0.7.0","codemirror":"^5.6.0"},"_npmOperationalInternal":{"tmp":"tmp/codemirror-graphql-0.5.7.tgz_1472424437819_0.9417220815084875","host":"packages-16-east.internal.npmjs.com"},"readme":"# GraphQL mode for CodeMirror\n\n[![NPM](https://img.shields.io/npm/v/codemirror-graphql.svg?style=flat-square)](https://npmjs.com/codemirror-graphql)\n![npm downloads](https://img.shields.io/npm/dm/codemirror-graphql?label=npm%20downloads)\n[![License](https://img.shields.io/npm/l/codemirror-graphql.svg?style=flat-square)](LICENSE)\n[Discord Channel](https://discord.gg/cffZwk8NJW)\n\n**NOTE: For CodeMirror 6, use [cm6-graphql](/packages/cm6-graphql/) instead**\n\nProvides CodeMirror with a parser mode for GraphQL along with a live linter and\ntypeahead hinter powered by your GraphQL Schema.\n\n![Demo .gif of GraphQL Codemirror Mode](https://raw.githubusercontent.com/graphql/graphiql/main/packages/codemirror-graphql/resources/example.gif)\n\n### Getting Started\n\n```sh\nnpm install --save codemirror-graphql\n```\n\nCodeMirror helpers install themselves to the global CodeMirror when they are\nimported.\n\n```ts\nimport type { ValidationContext, SDLValidationContext } from 'graphql';\n\nimport CodeMirror from 'codemirror';\nimport 'codemirror/addon/hint/show-hint';\nimport 'codemirror/addon/lint/lint';\nimport 'codemirror-graphql/hint';\nimport 'codemirror-graphql/lint';\nimport 'codemirror-graphql/mode';\n\nCodeMirror.fromTextArea(myTextarea, {\n  mode: 'graphql',\n  lint: {\n    schema: myGraphQLSchema,\n    validationRules: [ExampleRule],\n  },\n  hintOptions: {\n    schema: myGraphQLSchema,\n  },\n});\n```\n\n## External Fragments Example\n\nIf you want to have autocompletion for external fragment definitions, there's a\nnew configuration setting available\n\n```ts\nimport CodeMirror from 'codemirror';\nimport 'codemirror/addon/hint/show-hint';\nimport 'codemirror/addon/lint/lint';\nimport 'codemirror-graphql/hint';\nimport 'codemirror-graphql/lint';\nimport 'codemirror-graphql/mode';\n\nconst externalFragments = /* GraphQL */ `\n  fragment MyFragment on Example {\n    id: ID!\n    name: String!\n  }\n   fragment AnotherFragment on Example {\n    id: ID!\n    title: String!\n  }\n`;\n\nCodeMirror.fromTextArea(myTextarea, {\n  mode: 'graphql',\n  lint: {\n    schema: myGraphQLSchema,\n  },\n  hintOptions: {\n    schema: myGraphQLSchema,\n    // here we use a string, but\n    // you can also provide an array of FragmentDefinitionNodes\n    externalFragments,\n  },\n});\n```\n\n### Custom Validation Rules\n\nIf you want to show custom validation, you can do that too! It uses the\n`ValidationRule` interface.\n\n```ts\nimport type { ValidationRule } from 'graphql';\n\nimport CodeMirror from 'codemirror';\nimport 'codemirror/addon/hint/show-hint';\nimport 'codemirror/addon/lint/lint';\nimport 'codemirror-graphql/hint';\nimport 'codemirror-graphql/lint';\nimport 'codemirror-graphql/mode';\n\nconst ExampleRule: ValidationRule = context => {\n  // your custom rules here\n  const schema = context.getSchema();\n  const document = context.getDocument();\n  return {\n    NamedType(node) {\n      if (node.name.value !== node.name.value.toLowercase()) {\n        context.reportError('only lowercase type names allowed!');\n      }\n    },\n  };\n};\n\nCodeMirror.fromTextArea(myTextarea, {\n  mode: 'graphql',\n  lint: {\n    schema: myGraphQLSchema,\n    validationRules: [ExampleRule],\n  },\n  hintOptions: {\n    schema: myGraphQLSchema,\n  },\n});\n```\n\nBuild for the web with [webpack](http://webpack.github.io/) or\n[browserify](http://browserify.org/).\n","publish_time":1472424438886,"_cnpm_publish_time":1472424438886,"dist-tags":{"alpha":"2.0.9-alpha.1","beta":"3.0.0-beta.1","canary":"2.2.4-canary-be24c1cc.0","latest":"3.0.1","next":"2.0.0-next.2","rc":"3.0.0-rc.1"}}