{"name":"graphql-language-service-server","version":"2.14.7","keywords":["graphql","language server","LSP","vue","svelte","typescript"],"license":"MIT","_id":"graphql-language-service-server@2.14.7","maintainers":[{"name":"benjie","email":"npm@benjiegillam.com"},{"name":"mjmahone","email":"mahoney.mattj@gmail.com"},{"name":"leebyron","email":"lee@leebyron.com"},{"name":"i1g","email":"ivan.goncharov.ua@gmail.com"},{"name":"acao","email":"rikki.schulte@gmail.com"},{"name":"schickling","email":"schickling.j@gmail.com"},{"name":"fb","email":"opensource+npm@fb.com"},{"name":"wincent","email":"greg@hurrell.net"},{"name":"kassens","email":"jkassens@fb.com"},{"name":"orta","email":"orta.therox@gmail.com"},{"name":"asiandrummer","email":"asiandrummer@gmail.com"},{"name":"lostplan","email":"sol@twitter.com"},{"name":"mgadda","email":"mgadda@gmail.com"},{"name":"ags-","email":"agomezs@fb.com"}],"contributors":[{"url":"https://greg.hurrell.net","name":"Greg Hurrell","email":"greg@hurrell.net"},{"name":"Hyohyeon Jeong","email":"asiandrummer@fb.com"},{"url":"https://leebyron.com","name":"Lee Byron","email":"lee@leebyron.com"}],"homepage":"https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-server#readme","bugs":{"url":"https://github.com/graphql/graphiql/issues?q=issue+label:lsp-server"},"dist":{"shasum":"f445bcd1f2538bc14fb53919e307134d513d8e2b","tarball":"http://registry-npm.ywwl.com/graphql-language-service-server/download/graphql-language-service-server-2.14.7.tgz","fileCount":183,"integrity":"sha512-mH8aj7WgvaZnxUojyec44IYlTIH0bG+Vafbi4zV7YuNex8buVNXup+4Cj5EebqveKTkrlOWSYPQkWd3qpJEeWw==","signatures":[{"sig":"MEUCIQD9wtMktUsC9BI3px6MOSAX5sZhqEr4wY51QPMbuu1fqQIgacBcqqYF9g2EdmnYuOGZhVRTVEMDeyRGaxrhc6FXPTg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":690067,"size":114824,"noattachment":false,"key":"/graphql-language-service-server/-/graphql-language-service-server-2.14.7.tgz"},"main":"dist/index.js","module":"esm/index.js","COMMENT":"please do not remove dependencies without thorough testing. many dependencies are not imported directly, as they are peer dependencies","gitHead":"10f571cbb3714422eb167ebf9496d2ebe4932404","scripts":{"types:check":"tsc --noEmit"},"typings":"esm/index.d.ts","_npmUser":{"name":"acao","email":"rikki.schulte@gmail.com"},"repository":{"url":"git+https://github.com/graphql/graphiql.git","type":"git","directory":"packages/graphql-language-service-server"},"_npmVersion":"10.8.2","description":"Server process backing the GraphQL Language Service","directories":{},"_nodeVersion":"20.19.1","dependencies":{"vue":"^3.2.0","glob":"^7.2.0","dotenv":"10.0.0","mkdirp":"^1.0.4","svelte":"^4.2.19","fast-glob":"^3.2.7","lru-cache":"^10.2.0","nullthrows":"^1.0.0","svelte2tsx":"^0.7.0","typescript":"^5.3.3","vscode-uri":"^3.0.2","@babel/types":"^7.23.5","@babel/parser":"^7.23.6","source-map-js":"1.0.2","graphql-config":"5.0.3","vscode-jsonrpc":"^8.0.1","@astrojs/compiler":"^2.10.1","node-abort-controller":"^3.0.1","vscode-languageserver":"^8.0.1","cosmiconfig-toml-loader":"^1.0.0","graphql-language-service":"^5.3.1","vscode-languageserver-types":"^3.17.2","@graphql-tools/code-file-loader":"8.0.3"},"_hasShrinkwrap":false,"devDependencies":{"graphql":"^16.9.0","mock-fs":"^5.2.0","cross-env":"^7.0.2","@types/glob":"^8.1.0","@types/mkdirp":"^1.0.1","@types/mock-fs":"^4.13.4","debounce-promise":"^3.1.2"},"peerDependencies":{"graphql":"^16.0.0"},"_npmOperationalInternal":{"tmp":"tmp/graphql-language-service-server_2.14.7_1748257083518_0.4246991553654993","host":"s3://npm-registry-packages-npm-production"},"readme":"# graphql-language-service-server\n\n[![NPM](https://img.shields.io/npm/v/graphql-language-service-server.svg?style=flat-square)](https://npmjs.com/graphql-language-service-server)\n![npm downloads](https://img.shields.io/npm/dm/graphql-language-service-server?label=npm%20downloads)\n[![License](https://img.shields.io/npm/l/graphql-language-service-server.svg?style=flat-square)](LICENSE)\n\n[Changelog](https://github.com/graphql/graphiql/blob/main/packages/graphql-language-service-server/CHANGELOG.md)\n|\n[API Docs](https://graphiql-test.netlify.app/typedoc/modules/graphql_language_service_server.html)\n| [Discord Channel](https://discord.gg/PXaRYrpgK4)\n\nServer process backing the\n[GraphQL Language Service](https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service).\n\nGraphQL Language Service Server provides an interface for building GraphQL\nlanguage services for IDEs.\n\nPartial support for\n[Microsoft's Language Server Protocol](https://github.com/Microsoft/language-server-protocol)\nis in place, with more to come in the future.\n\nSupported features include:\n\n- Diagnostics (GraphQL syntax linting/validations) (**spec-compliant**)\n- Autocomplete suggestions (**spec-compliant**)\n- Hyperlink to fragment definitions and named types (type, input, enum)\n  definitions (**spec-compliant**)\n- Outline view support for queries\n- Support for `gql` `graphql` and other template tags inside javascript,\n  typescript, jsx, ts, vue and svelte files, and an interface to allow custom\n  parsing of all files.\n\n## Installation and Usage\n\n### Dependencies\n\n- An LSP compatible client with its own file watcher, that sends watch\n  notifications to the server, such as vscode, nvim, or sublime-lsp.\n- Node.js `^18.18.0 || >=20.9.0` or later is required.\n- (for now) a graphql config file is required\n\n### Installation\n\n```bash\nnpm install graphql-language-service-server\n# or\nyarn add graphql-language-service-server\n```\n\nWe also provide a CLI interface to this server, see\n[`graphql-language-service-cli`](../graphql-language-service-cli/)\n\n### Usage\n\nInitialize the GraphQL Language Server with the `startServer` function:\n\n```ts\nimport { startServer } from 'graphql-language-service-server';\n\nawait startServer({\n  method: 'node',\n});\n```\n\nIf you are developing a service or extension, this is the LSP language server\nyou want to run.\n\nWhen developing vscode extensions, just the above is enough to get started for\nyour extension's `ServerOptions.run.module`, for example.\n\n`startServer` function takes the following parameters:\n\n| Parameter      | Required                                             | Description                                                                       |\n| -------------- | ---------------------------------------------------- | --------------------------------------------------------------------------------- |\n| port           | `true` when method is `socket`, `false` otherwise    | port for the LSP server to run on                                                 |\n| method         | `false`                                              | `socket`, `streams`, or `node` (ipc)                                              |\n| config         | `false`                                              | custom `graphql-config` instance from `loadConfig` (see example above)            |\n| configDir      | `false`                                              | the directory where graphql-config is found                                       |\n| extensions     | `false`                                              | array of functions to transform the graphql-config and add extensions dynamically |\n| parser         | `false`                                              | Customize _all_ file parsing by overriding the default `parseDocument` function   |\n| fileExtensions | `false`. defaults to `['.js', '.ts', '.tsx, '.jsx']` | Customize file extensions used by the default LSP parser                          |\n\n### GraphQL configuration file\n\nYou _must_ provide a graphql config file\n\nCheck out [graphql-config](https://graphql-config.com/introduction) to learn the\nmany ways you can define your graphql config\n\n#### `.graphqlrc` or `.graphqlrc.yml/yaml` or `graphql.config.yml`\n\n```yaml\nschema: 'packages/api/src/schema.graphql'\ndocuments: 'packages/app/src/components/**/*.{tsx,ts}'\nextensions:\n  endpoints:\n    example:\n      url: 'http://localhost:8000'\n  customExtension:\n    foo: true\n```\n\n#### `.graphqlrc` or `.graphqlrc.json` or `graphql.config.json`\n\n```json\n{\n  \"schema\": \"https://localhost:8000\"\n}\n```\n\n#### `graphql.config.js` or `.graphqlrc.js`\n\n```js\nmodule.exports = { schema: 'https://localhost:8000' };\n```\n\n#### custom `startServer`\n\nuse graphql config [`loadConfig`](https://graphql-config.com/load-config) for\nfurther customization:\n\n```ts\nimport { loadConfig } from 'graphql-config'; // 3.0.0 or later!\n\n// with required params\nconst config = await loadConfig();\n\nawait startServer({\n  method: 'node',\n  // or instead of configName, an exact path (relative from rootDir or absolute)\n\n  // deprecated for: loadConfigOptions.rootDir. root directory for graphql config file(s), or for relative resolution for exact `filePath`. default process.cwd()\n  // configDir: '',\n  loadConfigOptions: {\n    // any of the options for graphql-config@3 `loadConfig()`\n    schema: await config.getSchema(),\n    // rootDir is same as `configDir` before, the path where the graphql config file would be found by cosmic-config\n    rootDir: 'config/',\n    // or - the relative or absolute path to your file\n    filePath: 'exact/path/to/config.js', // (also supports yml, json, ts, toml)\n    // myPlatform.config.js/json/yaml works now!\n    configName: 'myPlatform',\n  },\n});\n```\n\n<span id=\"custom-graphql-config\" />\n\n#### Custom `graphql-config` features\n\nThe graphql-config features we support are:\n\n```js\nmodule.exports = {\n  extensions: {\n    // add customDirectives (legacy). you can now provide multiple schema pointers to config.schema/project.schema, including inline strings. same with scalars or any SDL type that you'd like to append to the schema\n    customDirectives: ['@myExampleDirective'],\n    // a function that returns an array of validation rules, ala https://github.com/graphql/graphql-js/tree/main/src/validation/rules\n    // note that this file will be loaded by the vscode runtime, so the node version and other factors will come into play\n    customValidationRules: require('./config/customValidationRules'),\n    schemaCacheTTL: 1000, // reduce or increase minimum schema cache lifetime from 30000ms (30 seconds). you may want to reduce this if you are developing fullstack with network schema\n    languageService: {\n      // this is enabled by default if non-local files are specified in the project `schema`\n      // NOTE: this will disable all definition lookup for local SDL files\n      cacheSchemaFileForLookup: true,\n      // undefined by default which has the same effect as `true`, set to `false` if you are already using // `graphql-eslint` or some other tool for validating graphql in your IDE. Must be explicitly `false` to disable this feature, not just \"falsy\"\n      enableValidation: true,\n      // (experimental) enhanced auto expansion of graphql leaf fields and arguments\n      fillLeafsOnComplete: true,\n      // enable GraphQL.js 17 experimental fragment arguments across language features\n      experimentalFragmentArguments: true,\n      // instead of jumping directly to the SDL file, you can override definition peek/jump results to point to different files or locations\n      // (for example, source files for your schema in any language!)\n      // based on Relay vscode's pathToLocateCommand\n      // see LocateCommand type!\n      locateCommand(projectName, typePath, info) {\n        // pass more info, such as GraphQLType with the ast node. info.project is also available if you need it\n        const { path, range } = ourLookupUtility(\n          projectName,\n          typePath,\n          info.type.node,\n        );\n        return { uri: path, range }; // range.start.line/range.end.character/etc, base 1\n        // you can also return relay LSP style\n        // return '/path/to/file.py:20:1'; // (range: 20:1 20:1 )\n        // return '/path/to/file.py'; // (range: 1:1 1:1)\n      },\n    },\n  },\n};\n```\n\nor for multi-project workspaces:\n\n```ts\n// graphql.config.ts\nexport default {\n  projects: {\n    myProject: {\n      schema: [\n        // internally in `graphql-config`, an attempt will be made to combine these schemas into one in-memory schema to use for validation, lookup, etc\n        'http://localhost:8080',\n        './my-project/schema.graphql',\n        './my-project/schema.ts',\n        '@customDirective(arg: String!)',\n        'scalar CustomScalar',\n      ],\n      // project specific defaults\n      extensions: {\n        languageService: {\n          cacheSchemaFileForLookup: true,\n          enableValidation: false,\n        },\n      },\n    },\n    anotherProject: {\n      schema: {\n        'http://localhost:8081': {\n          customHeaders: { Authorization: 'Bearer example' },\n        },\n      },\n    },\n  },\n  // global defaults for all projects\n  extensions: {\n    languageService: {\n      cacheSchemaFileForLookup: false,\n      enableValidation: true,\n    },\n  },\n};\n```\n\nYou can specify any of these settings globally as above, or per project. Read\nthe graphql-config docs to learn more about this!\n\nFor secrets (headers, urls, etc), you can import `dotenv()` and set a base path\nas you wish in your `graphql-config` file to pre-load `process.env` variables.\n\n### Troubleshooting notes\n\n- you may need to manually restart the language server for some of these\n  configurations to take effect\n- graphql-config's multi-project support is not related to multi-root workspaces\n  in vscode - in fact, each workspace can have multiple graphql config projects,\n  which is what makes multi-root workspaces tricky to support. coming soon!\n\n<span id=\"workspace-configuration\" />\n\n### Workspace Configuration\n\nThe LSP Server reads config by sending `workspace/configuration` method when it\ninitializes.\n\nNote: We still do not support LSP multi-root workspaces but will tackle this\nvery soon!\n\nMany LSP clients beyond vscode offer ways to set these configurations, such as\nvia `initializationOptions` in nvim.coc. The options are mostly designed to\nconfigure graphql-config's load parameters, the only thing we can't configure\nwith graphql config. The final option can be set in `graphql-config` as well\n\n| Parameter                                 | Default                                           | Description                                                                                                                                                                                                                                                                                         |\n| ----------------------------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `graphql-config.load.baseDir`             | workspace root or process.cwd()                   | the path where graphql config looks for config files                                                                                                                                                                                                                                                |\n| `graphql-config.load.filepath`            | `null`                                            | exact filepath of the config file.                                                                                                                                                                                                                                                                  |\n| `graphql-config.load.configName`          | `graphql`                                         | config name prefix instead of `graphql`                                                                                                                                                                                                                                                             |\n| `graphql-config.load.legacy`              | `true`                                            | backwards compatibility with `graphql-config@2`                                                                                                                                                                                                                                                     |\n| `graphql-config.dotEnvPath`               | `null`                                            | backwards compatibility with `graphql-config@2`                                                                                                                                                                                                                                                     |\n| `vscode-graphql.cacheSchemaFileForLookup` | `true` if `schema` contains non-SDL files or URLs | generate an SDL file based on your graphql-config schema configuration for definition lookup and other features. enabled by default when your `schema` config are URLs or introspection JSON, or if you have any non-local SDL files in `schema`                                                    |\n| `vscode-graphql.schemaCacheTTL`           | `30000`                                           | an integer value in milliseconds for the desired minimum cache lifetime for all schemas, which also causes the generated file to be re-written. set to 30s by default. effectively a \"lazy\" form of polling. if you are developing a schema alongside client queries, you may want to decrease this |\n| `vscode-graphql.debug`                    | `false`                                           | show more verbose log output in the output channel                                                                                                                                                                                                                                                  |\n\nall the `graphql-config.load.*` configuration values come from static\n`loadConfig()` options in graphql config.\n\n(more coming soon!)\n\n### Architectural Overview\n\nGraphQL Language Service currently communicates via Stream transport with the\nIDE server. GraphQL server will receive/send RPC messages to perform language\nservice features, while caching the necessary GraphQL artifacts such as fragment\ndefinitions, GraphQL schemas etc. More about the server interface and RPC\nmessage format below.\n\nThe IDE server should launch a separate GraphQL server with its own child\nprocess for each `.graphqlrc.yml` file the IDE finds (using the nearest ancestor\ndirectory relative to the file currently being edited):\n\n```\n./application\n\n  ./productA\n    .graphqlrc.yml\n    ProductAQuery.graphql\n    ProductASchema.graphql\n\n  ./productB\n    .graphqlrc.yml\n    ProductBQuery.graphql\n    ProductBSchema.graphql\n```\n\nA separate GraphQL server should be instantiated for `ProductA` and `ProductB`,\neach with its own `.graphqlrc.yml` file, as illustrated in the directory\nstructure above.\n\nThe IDE server should manage the lifecycle of the GraphQL server. Ideally, the\nIDE server should spawn a child process for each of the GraphQL Language Service\nprocesses necessary, and gracefully exit the processes as the IDE closes. In\ncase of errors or a sudden halt the GraphQL Language Service will close as the\nstream from the IDE closes.\n\n### Server Interface\n\nGraphQL Language Server uses [JSON-RPC](http://www.jsonrpc.org/specification) to\ncommunicate with the IDE servers. Microsoft's language server currently supports\ntwo communication transports: Stream (stdio) and IPC. For IPC transport, the\nreference guide to be used for development is\n[the language server protocol](https://microsoft.github.io/language-server-protocol/specification)\ndocumentation.\n\nFor each transport, there is a slight difference in JSON message format,\nespecially in how the methods to be invoked are defined - below are the\ncurrently supported methods for each transport (will be updated as progress is\nmade):\n\n|                      | Stream                       | IPC                                         |\n| -------------------: | ---------------------------- | ------------------------------------------- |\n|          Diagnostics | `getDiagnostics`             | `textDocument/publishDiagnostics`           |\n|       Autocompletion | `getAutocompleteSuggestions` | `textDocument/completion`                   |\n|              Outline | `getOutline`                 | `textDocument/outline`                      |\n|     Document Symbols | `getDocumentSymbols`         | `textDocument/symbols`                      |\n|    Workspace Symbols | `getWorkspaceSymbols`        | `workspace/symbols`                         |\n|     Go-to definition | `getDefinition`              | `textDocument/definition`                   |\n| Workspace Definition | `getWorkspaceDefinition`     | `workspace/definition`                      |\n|          File Events | Not supported yet            | `didOpen/didClose/didSave/didChange` events |\n","publish_time":1748257083732,"_cnpm_publish_time":1748257083732,"dist-tags":{"alpha":"2.14.10-alpha.0","beta":"3.0.0-beta.1","canary":"2.14.9-canary-be24c1cc.0","latest":"3.0.1","next":"2.5.0-alpha.5","rc":"3.0.0-rc.2"}}