Note: The primary maintainer @acao is on hiatus until December 2020
GraphQL extension VSCode built with the aim to tightly integrate the GraphQL Ecosystem with VSCode for an awesome developer experience.
Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications. Visual Studio Code Insiders is the pre-release build of Visual Studio Code. Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. It's free, build on open source and available on your favorite platform - Linux, macOS, and Windows. Visual Studio Code was first announced on April 29, 2015, by Microsoft at the 2015 Build conference. A Preview build was released shortly thereafter. On November 18, 2015, Visual Studio Code was released under the MIT License, having its source code available.
💡 Note: This extension no longer supports .prisma
files. If you are using this extension with GraphQL 1, please rename your datamodel from datamodel.prisma
to datamodel.graphql
and this extension will pick that up.
Visual Studio Code Insiders Build
Features
Lots of new improvements happening! We now have a CHANGELOG.md
General features
- 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 - Load the extension inside
gql
/graphql
fenced code blocks in markdown files - execute query/mutation/subscription operation, embedded or in graphql files
- pre-load schema and document defintitions
- Support
graphql-config
files with one project and multiple projects - the language service re-starts on changes to vscode settings and/or graphql config!
.graphql
, .gql
file extension support
- syntax highlighting (type, query, mutation, interface, union, enum, scalar, fragments, directives)
- autocomplete suggestions
- validation against schema
- snippets (interface, type, input, enum, union)
- hover support
- go to definition support (input, enum, type)
- outline support
gql
/graphql
tagged template literal support for tsx, jsx, ts, js
- syntax highlighting (type, query, mutation, interface, union, enum, scalar, fragments, directives)
- autocomplete suggestions
- validation against schema
- snippets
- hover support
- go to definition for fragments and input types
- outline support
Usage
Install the VSCode GraphQL Extension.
(Watchman is no longer required, you can uninstall it now)
This extension requires a graphql-config file.
As of vscode-graphql@0.3.0
we support graphql-config@3
. You can read more about that here. Because it now uses cosmicconfig
there are plenty of new options for loading config files:
the file needs to be placed at the project root by default, but you can configure paths per project. see the FAQ below for details.
Previous versions of this extension support graphql-config@2
format, which follows legacy configuration patterns
To support language features like 'go-to definition' across multiple files, please include documents
key in the graphql-config default or /per project (this was include
in 2.0).
Configuration Examples
Simple Example
Advanced Example
Notice that documents
key supports glob pattern and hence ['**/*.graphql']
is also valid.
Frequently Asked Questions
Go to definition is using generated_schema.graphql
, not my schema source files
Ah yes, this is now the default behavior used by most users, who do not have source SDL files.If you're using an 'SDL first' methodology, such as with apollo, you'll want to enable useSchemaFileDefinitions
.Add this to your settings:
you can also use graphql config if you need to mix and match these settings:
The extension fails with errors about duplicate types
Make sure that you aren't including schema files in the documents
blob
The extension fails with errors about missing scalars, directives, etc
Make sure that your schema
pointers refer to a complete schema!
In JSX and TSX files I see completion items I don't need
The way vscode lets you filter these out is on the user end
So you'll need to add something like this to your global vscode settings:
'Execute Query/Mutation/Subscription' always fails
The best way to make 'execute ' codelens work is to add endpoints config to the global graphql config or the project config.
The config example above shows how to configure endpoints.
If there is an issue with execution that has to do with your server, the error response should show now in the results panel
My graphql config file is not at the root
Good news, we have configs for this now!
Visual Studio Code Insiders Wsl
You can search a folder for any of the matching config file names listed above:
Or a specific filepath:
Or a different configName
that allows different formats:
which would search for ./config/.acmerc
, .config/.acmerc.js
, .config/acme.config.json
, etc matching the config paths above
If you have multiple projects, you need to define one top-level config that defines all project configs using projects
How do I highlight an embedded graphql string
If you aren't using a template tag function, and just want to use a plain string, you can use an inline #graphql
comment:
or
Known Issues
- template replacement inside a graphql string will break graphql parsing. If you want to help improve partial parsing support, you can contribute to the parser efforts in
graphql
reference implementation. You can now re-use fragments across your project source, if you include the files indocuments
. - the output channel occasionally shows 'definition not found' when you first start the language service, but once the definition cache is built for each project, definition lookup will work. so if a 'peek definition' fails when you first start, just try clicking it again.
Development
This plugin uses the GraphQL language server
- Clone the repository - https://github.com/graphql/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
- Logs for GraphQL language service will appear in output section under GraphQL Language Service
Contributing back to this project
This repository is managed by EasyCLA. Project participants must sign the free (GraphQL Specification Membership agreement before making a contribution. You only need to do this one time, and it can be signed by individual contributors or their employers.
To initiate the signature process please open a PR against this repo. The EasyCLA bot will block the merge if we still need a membership agreement from you.
You can find detailed information here. If you have issues, please email operations@graphql.org.
If your company benefits from GraphQL and you would like to provide essential financial support for the systems and people that power our community, please also consider membership in the GraphQL Foundation.
License
MIT
Version | OS | Last Seen |
---|---|---|
1.56.0-insider | 2021-04-02 | |
1.56.0-insider | 2021-04-01 | |
1.55.0-insider | 2021-03-08 | |
1.55.0-insider | 2021-03-05 | |
1.54.0-insider | 2021-02-05 | |
1.54.0-insider | 2021-02-05 | |
1.53.0-insider | 2020-12-22 | |
1.53.0-insider | 2020-12-16 | |
1.52.0-insider | 2020-12-09 | |
1.52.0-insider | 2020-11-07 | |
1.51.0-insider | 2020-10-18 | |
1.51.0-insider | 2020-10-10 | |
1.50.0-insider | 2020-10-07 | |
1.50.0-insider | 2020-09-12 | |
1.49.0-insider | 2020-09-02 | |
1.49.0-insider | 2020-08-18 | |
1.48.0-insider | 2020-07-16 | |
1.48.0-insider | 2020-07-15 | |
1.47.0-insider | 2020-06-18 | |
1.47.0-insider | 2020-06-13 | |
1.46.0-insider | 2020-05-17 | |
1.46.0-insider | 2020-05-08 | |
1.45.0-insider | 2020-04-16 | |
1.45.0-insider | 2020-04-12 | |
1.44.0-insider | 2020-03-19 | |
1.44.0-insider | 2020-03-15 | |
1.43.0-insider | 2020-02-16 | |
1.42.0-insider | 2019-12-27 | |
1.42.0-insider | 2019-12-16 | |
1.41.0-insider | 2019-11-28 | |
1.41.0-insider | 2019-11-11 | |
1.40.0-insider | 2019-10-13 | |
1.39.0-insider | 2019-09-10 | |
1.38.0-insider | 2019-09-09 | |
1.39.0-insider | 2019-09-05 | |
1.38.0-insider | 2019-08-13 | |
1.37.0-insider | 2019-07-12 | |
1.37.0-insider | 2019-07-05 | |
1.36.0-insider | 2019-07-05 | |
1.36.0-insider | 2019-06-07 | |
1.35.0-insider | 2019-05-19 | |
1.35.0-insider | 2019-05-18 | |
1.34.20-insider | 2019-05-11 | |
1.34.20-insider | 2019-05-10 | |
1.34.0-insider | 2019-04-12 | |
1.34.0-insider | 2019-04-09 | |
1.33.0-insider | 2019-03-13 | |
1.33.0-insider | 2019-03-09 | |
1.32.0-insider | 2019-02-13 | |
1.32.0-insider | 2019-02-11 | |
1.31.0-insider | 2018-12-14 | |
1.31.0-insider | 2018-12-13 | |
1.30.0-insider | 2018-11-19 | |
1.30.0-insider | 2018-11-14 | |
1.29.0-insider | 2018-10-27 | |
1.29.0-insider | 2018-10-12 | |
1.28.0-insider | 2018-09-09 | |
1.28.0-insider | 2018-09-07 | |
1.27.0-insider | 2018-08-20 | |
1.27.0-insider | 2018-08-14 | |
1.26.0-insider | 2018-07-12 | |
1.26.0-insider | 2018-07-08 | |
1.25.0-insider | 2018-06-14 | |
1.25.0-insider | 2018-06-08 | |
1.24.0-insider | 2018-05-10 | |
1.24.0-insider | 2018-05-05 | |
1.22.0-insider | 2018-04-16 | |
1.23.0-insider | 2018-04-15 | |
1.23.0-insider | 2018-04-07 | |
1.22.0-insider | 2018-03-09 | |
1.21.0-insider | 2018-02-24 | |
1.21.0-insider | 2018-02-10 | |
1.20.0-insider | 2018-01-02 | |
1.20.0-insider | 2017-12-19 | |
1.19.0-insider | 2017-11-19 | |
1.19.0-insider | 2017-11-10 | |
1.18.0-insider | 2017-10-23 | |
1.18.0-insider | 2017-10-07 | |
1.17.0-insider | 2017-09-21 | |
1.17.0-insider | 2017-09-08 | |
1.16.0-insider | 2017-08-16 | |
1.16.0-insider | 2017-08-14 | |
1.15.0-insider | 2017-07-14 | |
1.15.0-insider | 2017-07-12 | |
1.14.0-insider | 2017-06-25 | |
1.14.0-insider | 2017-06-12 | |
1.13.0-insider | 2017-06-01 | |
1.13.0-insider | 2017-05-26 | |
1.12.0-insider | 2017-04-20 | |
1.12.0-insider | 2017-04-15 | |
1.11.0-insider | 2017-03-05 | |
1.10.0-insider | 2017-02-12 | |
1.10.0-insider | 2017-02-06 | |
1.9.0-insider | 2016-12-23 | |
1.9.0-insider | 2016-12-16 | |
1.6.0-insider | 2016-11-24 | |
1.8.0-insider | 2016-11-18 | |
1.8.0-insider | 2016-11-16 | |
1.7.0-insider | 2016-10-16 | |
1.7.0-insider | 2016-10-16 | |
1.6.0-insider | 2016-09-09 | |
1.5.0-insider | 2016-08-31 | |
1.4.0-insider | 2016-08-30 | |
1.4.0-insider | 2016-07-26 | |
1.3.0-insider | 2016-06-09 | |
1.3.0-insider | 2016-06-08 | |
1.1.0-insider | 2016-05-07 | |
1.0.0-insider | 2016-04-29 | |
1.0.1-insider | 2016-04-21 | |
0.10.13-insider | 2016-04-14 | |
0.10.14-insider | 2016-04-05 | |
0.10.14-insider | 2016-04-04 | |
0.10.13-insider | 2016-04-04 | |
0.10.12-insider | 2016-03-21 | |
0.10.8-insider | 2016-02-16 |