GraphQL extension VSCode built with the aim to tightly integrate the GraphQL Ecosystem with VSCode for an awesome developer experience.
- Load the extension on detecting
graphql-config file
at root level or in a parent level directory - Load the extension in
.graphql
,.gql files
- Load the extension on detecting
gql
tag in js, ts, jsx, tsx, vue files - Support
graphql-config file
with one project and multiple projects
- syntax highlighting (type, query, mutation, interface, union, enum, scalar, fragments)
- autocomplete suggestions
- validation against schema
- snippets (interface, type, input, enum, union)
- hover support
- go to definition support (input, enum, type)
- syntax highlighting (type, query, mutation, interface, union, enum, scalar, fragments)
- autocomplete suggestions
- validation against schema
- snippets
Just install the VSCode GraphQL Extension. This extension adds syntax highlighting and IntelliSense for graphql files and gql
tags.
This extension requires a valid .graphqlconfig.yml
file in the project root. You can read more about that here.
To support language features like "go-to definition" across multiple files, please include includes
key in the graphql-config per project. For example,
projects:
app:
schemaPath: src/schema.graphql
includes: ["**/*.graphql"]
extensions:
endpoints:
default: http://localhost:4000
db:
schemaPath: src/generated/db.graphql
includes: ["**/*.graphql"]
extensions:
codegen:
- generator: graphql-binding
language: typescript
output:
binding: src/generated/db.ts
Notice that includes
key supports glob pattern and hence
["**/*.graphql"]
is also valid.
If you want to use a workspace version of TypeScript however, you must manually install the plugin along side the version of TypeScript in your workspace:
npm install --save-dev ts-graphql-plugin
Then add a plugins
section to your tsconfig.json
or jsconfig.json
{
"compilerOptions": {
"plugins": [
{
"name": "ts-graphql-plugin"
}
]
}
}
Finally, run the Select TypeScript version
command in VS Code to switch to use the workspace version of TypeScript for VS Code's JavaScript and TypeScript language support. You can find more information about managing typescript versions in the VS Code documentation.
Testing GraphQL Language Features
- Clone the repository - https://github.com/prismagraphql/vscode-graphql
npm install
- Open it in VSCode
- Go to the debugging section and run the launch program "Extension"
- This will open another VSCode instance with extension enabled
- Open a project with a graphql config file - ":electric_plug: graphql" in VSCode status bar indicates that the extension is in use
Testing TypeScript GraphQL Plugin Features
- Go to
vscode-graphql/ts-graphql-plugin
npm install
andnpm link
- Use
npm link ts-graphql-plugin
in the folder that you have opened to test things in extension host - this is required for development - Switch to use workspace typescript - this is required for development
MIT