All Projects → graphql → Vscode Graphql

graphql / Vscode Graphql

Licence: mit
VSCode GraphQL extension (autocompletion, go-to definition, syntax highlighting)

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Vscode Graphql

Vscode Restclient
REST Client Extension for Visual Studio Code
Stars: ✭ 3,289 (+656.09%)
Mutual labels:  graphql, vscode, vscode-extension
Firestore Apollo Graphql
An example of a GraphQL setup with a Firebase Firestore backend. Uses Apollo Engine/Server 2.0 and deployed to Google App Engine.
Stars: ✭ 371 (-14.71%)
Mutual labels:  graphql, apollo
Fraql
GraphQL fragments made simple ⚡️
Stars: ✭ 433 (-0.46%)
Mutual labels:  graphql, apollo
Apollo Cache Hermes
A cache implementation for Apollo Client, tuned for performance
Stars: ✭ 425 (-2.3%)
Mutual labels:  graphql, apollo
Vue Fullstack Graphql
Starter projects for fullstack applications based on Vue.js & GraphQL.
Stars: ✭ 352 (-19.08%)
Mutual labels:  graphql, apollo
Vscode Php Intellisense
Advanced PHP IntelliSense for Visual Studio Code 🆚💬
Stars: ✭ 358 (-17.7%)
Mutual labels:  vscode, vscode-extension
Graphql Up
Get a ready-to-use GraphQL API for your schema
Stars: ✭ 415 (-4.6%)
Mutual labels:  graphql, apollo
Aws Lambda Graphql
Use AWS Lambda + AWS API Gateway v2 for GraphQL subscriptions over WebSocket and AWS API Gateway v1 for HTTP
Stars: ✭ 313 (-28.05%)
Mutual labels:  graphql, apollo
Iceworks
Visual Intelligent Development Pack(可视化智能开发套件)
Stars: ✭ 390 (-10.34%)
Mutual labels:  vscode, vscode-extension
Vscode Syncing
⚡️ VSCode Extension - Sync all of your VSCode settings across multiple devices.
Stars: ✭ 395 (-9.2%)
Mutual labels:  vscode, vscode-extension
Graphql Ws
Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client.
Stars: ✭ 398 (-8.51%)
Mutual labels:  graphql, apollo
Chrome Vs Code
A web browser integrated in VS Code editor tabs. ☢️ experimental ☢️
Stars: ✭ 351 (-19.31%)
Mutual labels:  vscode, vscode-extension
Graphback
Graphback - Out of the box GraphQL server and client
Stars: ✭ 323 (-25.75%)
Mutual labels:  graphql, apollo
Apollo Upload Examples
A full stack demo of file uploads via GraphQL mutations using Apollo Server and apollo-upload-client.
Stars: ✭ 358 (-17.7%)
Mutual labels:  graphql, apollo
Artemis
Build dart types from GraphQL schemas and queries
Stars: ✭ 317 (-27.13%)
Mutual labels:  graphql, apollo
Villus
🏎 A tiny and fast GraphQL client for Vue.js
Stars: ✭ 378 (-13.1%)
Mutual labels:  graphql, apollo
Grand Stack Starter
Simple starter project for GRANDstack full stack apps
Stars: ✭ 419 (-3.68%)
Mutual labels:  graphql, apollo
Graphql Starter
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, and Material UI.
Stars: ✭ 3,377 (+676.32%)
Mutual labels:  graphql, vscode
Gatsby Woocommerce Themes
⚡ A Gatsby Theme for WooCommerce E-commerce site Gatsby WooCommerce WordPress
Stars: ✭ 306 (-29.66%)
Mutual labels:  graphql, apollo
Awesome Vscode
🎨 A curated list of delightful VS Code packages and resources.
Stars: ✭ 19,659 (+4419.31%)
Mutual labels:  vscode, vscode-extension

VSCode GraphQL

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.

💡 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.

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 [email protected] we support [email protected]. You can read more about that here. Because it now uses cosmicconfig there are plenty of new options for loading config files:

graphql.config.json
graphql.config.js
graphql.config.yaml
graphql.config.yml
.graphqlrc (YAML or JSON)
.graphqlrc.json
.graphqlrc.yaml
.graphqlrc.yml
.graphqlrc.js
graphql property in package.json

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 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

// .graphqlrc.yml
schema: "schema.graphql"
documents: "src/**/*.{graphql,js,ts,jsx,tsx}"

Advanced Example

// graphql.config.js
module.exports = {
  projects: {
    app: {
      schema: ["src/schema.graphql", "directives.graphql"],
      documents: ["**/*.{graphql,js,ts,jsx,tsx}", "my/fragments.graphql"],
      extensions: {
        endpoints: {
          default: {
            url: "http://localhost:8000",
            headers: { Authorization: `Bearer ${process.env.API_TOKEN}` },
          },
        },
      }
    },
    db: {
      schema: "src/generated/db.graphql",
      documents: ["src/db/**/*.graphql", "my/fragments.graphql"],
      extensions: {
        codegen: [
          {
            generator: "graphql-binding",
            language: "typescript",
            output: {
              binding: "src/generated/db.ts",
            },
          },
        ],
        endpoints: {
          default: {
            url: "http://localhost:8080",
            headers: { Authorization: `Bearer ${process.env.API_TOKEN}` },
          },
        },
      },
    },
  },
}

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:

"vscode-graphql.useSchemaFileDefinitions": true,

you can also use graphql config if you need to mix and match these settings:

projects:
  project1:
    schema: project1/schema/schema.graphql
    documents: project1/queries/**/*.{graphql,tsx,jsx,ts,js}
    extensions:
      languageService:
        useSchemaFileDefinitions: true
  project2:
    schema: https://api.spacex.land/graphql/
    documents: project2/queries.graphql
    extensions:
      endpoints:
        default:
          url: https://api.spacex.land/graphql/

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:

"[typescriptreact]": {
  "editor.suggest.filteredTypes": {
    "snippet": false
  }
},
"[javascriptreact]": {
  "editor.suggest.filteredTypes": {
    "snippet": false
  }
}

"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!

You can search a folder for any of the matching config file names listed above:

"graphql-config.load.baseDir": "./config"

Or a specific filepath:

"graphql-config.load.filePath": "./config/my-graphql-config.js"

Or a different configName that allows different formats:

"graphql-config.load.baseDir": "./config",
"graphql-config.load.configName": "acme"

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:

const myQuery = `#graphql
  query {
    something
  }
`

or

const myQuery = `
  #graphql
  query {
    something
  }
`

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 in documents.
  • 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

  1. Clone the repository - https://github.com/graphql/vscode-graphql
  2. npm install
  3. Open it in VSCode
  4. Go to the debugging section and run the launch program "Extension"
  5. This will open another VSCode instance with extension enabled
  6. Open a project with a graphql config file - "🔌 graphql" in VSCode status bar indicates that the extension is in use
  7. Logs for GraphQL language service will appear in output section under GraphQL Language Service GraphQL Language Service Logging

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 [email protected].

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].