Coder Social home page Coder Social logo

maxwell2022 / graphql-for-vscode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kumarharsh/graphql-for-vscode

0.0 1.0 0.0 892 KB

GraphQL syntax highlighting, linting, auto-complete, and more!

Home Page: https://marketplace.visualstudio.com/items?itemName=kumar-harsh.graphql-for-vscode

License: MIT License

HTML 18.47% Shell 5.24% Gherkin 2.69% JavaScript 2.68% OCaml 2.67% Vue 5.07% Ruby 2.91% TypeScript 60.28%

graphql-for-vscode's Introduction

Logo

Graphql For VSCode

Latest Release Installs Rating

Semantic Release


VSCode extension for GraphQL schema authoring & consumption.

A preview of the extension

What's in the Box?

  • Go to Definition: Just F12 or Ctrl+Click on any graphql type, and you'll jump right to it's definition.

    Go to Definition

  • Autocomplete: Uses the @playlyfe/gql library to read your whole graphql schema definitions and provide you with autocomplete support while writing & editing your .gql files.

    Autocomplete

  • Schema Validation: The extension also validates your schema, so that you catch errors early.

  • Linting: This extension uses a similar method as used by the Codemirror graphql project for linting.

  • Great Syntax Highlighting: Now, your graphql queries, mutations and gql files will look as beautiful as the rest of your code with an awesome syntax highlighter. It works not just with your .gql/.graphql schema files, but also within your code - supports syntax highlighting within:

    • Javascript
    • Typescript
    • Vue
    • Ruby
    • Cucumber
    • ReasonML/OCaml
    • Markdown fenced code-blocks
    • (Submit a PR to support your language!)
  • Snippets: Some commonly used snippets are provided which help while writing mutations and queries, such as defining types, interfaces and input types.

Setting it Up

  1. Ensure that you have the @playlyfe/gql library (v2.x) installed and available to this extension. If you've installed the library in a folder other than the workspace root, then add the path to the node_modules directory as a setting:

    {
      "graphqlForVSCode.nodePath": "ui/node_modules"
    }
  2. Ensure you have watchman installed and available in your path. Watchman watches your gql files and provides up-to-date suggestions. For users on Windows, get the latest build mentioned in this issue and add the location of watchman.exe to your environment path.

  3. Create a .gqlconfig file (required by the @playlyfe/gql package).

    A minimal example:

    The .gqlconfig is a JSON file with only one required key: schema.files which is the path to your *.gql files relative to your workspace root.

    /* .gqlconfig */
    {
      schema: {
        files: 'schemas/**/*.gql'
      }
    }

    You can use the string files: "**/*.gql" instead if you want to find any .gql file recursively in the workspace dir.

    To see the full configuration, check out the GQL project's docs.

  4. To enable autocomplete support within your code, add these lines to your .gqlconfig file. The query section of the config contains an array of file config with matchers. You can add more files by directing the EmbeddedQueryParser to run when your code within the startTag and endTag matches:

    /* .gqlconfig */
    {
      schema: {
        files: "schemas/**/*.gql"
      },
      query: {
        files: [ /* define file paths which you'd like the gql parser to watch and give autocomplete suggestions for */
          {
            match: 'ui/src/**/*.js', // for js
            parser: ['EmbeddedQueryParser', { startTag: 'Relay\\.QL`', endTag: '`' }],
            isRelay: true,
          },
          {
            match: 'features/**/*.feature', // for gherkin
            parser: ['EmbeddedQueryParser', { startTag: 'graphql request\\s+"""', endTag: '"""' }],
          },
          {
            "match": "lib/**/*.rb", // sample config you might use for Ruby-aware highlighting (inside `<<-GRAPHQL` heredocs)
            "parser": ["EmbeddedQueryParser", { "startTag": "<<-GRAPHQL", "endTag": "GRAPHQL" }]
          },
          {
            match: 'fixtures/**/*.gql',
            parser: 'QueryParser',
          },
        ],
      },
    }

    Again, refer to GQL docs for details about configuring your .gqlconfig.

Future Plans

  • Tests: Figure out tests.

Contributing

  • If you have a suggestion or a problem, please open an issue.
  • If you'd like to improve the extension:
    • If you've made any improvements to the extension, send a Pull Request!
    • The instructions to run and debug the extension are here

Hacking

If you're making changes to the extension, then run yarn dev inside this directory, then just press F5 to launch the Extension Development Host instance of vscode. Whenever you make a change, press Reload to reload the EDH instance.

Major Contributors

  • Mayank Agarwal - added autocomplete, goto definition, schema validation support

Changelog

  • Latest changes are available on the releases page.
  • Older changelogs can be found here.

Happy Querying!

graphql-for-vscode's People

Contributors

afduarte avatar ajhyndman avatar alloy avatar dependabot-preview[bot] avatar flakeparadigm avatar greenkeeper[bot] avatar huxpro avatar kachkaev avatar kamilkisiela avatar kumarharsh avatar mayank1791989 avatar mjbvz avatar mzikherman avatar orta avatar rofrol avatar spencerhakim avatar timrs2998 avatar ulrikstrid avatar yashcr07 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.