doomemacs/modules/lang/graphql
Henrik Lissner 1abcf913aa
revert: fix(docs): set mode in file-local vars
emacs-straight/org-mode@e22b4eb7aa introduced a breaking change that
made it impossible to rely on .dir-locals.el to change org-mode buffers
in $EMACSDIR to doom-docs-org-mode (without infinite recursion), so we
used file-local variables in 7e400ab.

emacs-straight/org-mode@215de6176b reverted that change, so we can use
.dir-locals.el again, and this is my preference, since it requires less
boilerplate across our hundreds of org files.

Ref: emacs-straight/org-mode@215de6176b
Ref: emacs-straight/org-mode@e22b4eb7aa
Revert: 7e400abdc0
2022-08-07 19:08:07 +02:00
..
autoload.el module: add :lang graphql 2022-04-03 16:38:57 +02:00
config.el fix(graphql): remove *Messages* spam 2022-04-06 14:31:45 +02:00
packages.el fix(graphql): truncated pin 2022-06-17 19:37:41 +02:00
README.org revert: fix(docs): set mode in file-local vars 2022-08-07 19:08:07 +02:00

:lang graphql

Description   unfold

This module adds GraphQL support to Doom Emacs.

It includes:

  • Code completion
  • LSP support (+lsp)

    • Diagnostics (GraphQL syntax linting/validations) (spec-compliant)
    • Autocomplete suggestions (spec-compliant)
    • Hyperlink to fragment definitions and named types (type, input, enum) definitions (spec-compliant)
    • Outline view support for queries and SDL
    • Symbols support across the workspace
  • Local schema viewer
  • Org-babel exporter (requires :lang org)

Module flags

+lsp
Enable LSP support for graphql-mode. Requires :tools lsp and a langserver (graphql-language-service-cli).

Hacks

TODO Changelog

This module does not have a changelog yet.

Installation

Enable this module in your doom! block.

This module has no direct requirements, but the +lsp flag requires a supported LSP server.

Usage

Sending queries

When visiting a graphql buffer, you have access to the ability to send the current query with C-c C-c which will prompt you for an optional variables file, then execute the query and return a buffer of the results.

It's also possible to send queries using org-babel using a block such as the ones below (executing correctly will require :lang org)

{
    "continentCode": "AF"
}
query GetContinents($continentCode: String!) {
  continent(code: $continentCode) {
    name
    code
  }
}
{
  "data": {
    "continent": {
      "name": "Africa",
      "code": "AF"
    }
  }
}

Viewing docs

With this module, there are 3 ways to view schemas:

  • +graphql-doc-open-config which uses a local .graphqlconfig file to seed endpoints to query
  • graphql-doc which prompts you to select an endpoint based on ones added manually by graphql-doc-add-api
  • graphql-doc-open-url which prompts to to manually enter an endpoint url

When using the doc viewer, there are a few bindings for navigating around.

Key Command Description
C-j forward-button Follow a forward button
C-k backward-button Follow a backward button
<backspace> graphql-doc-go-back Go back to a previous page
mouse-1 - Follow the next label under point
RET - Follow the next label under point

Configuration

Most of the "magic" in the module relies on a properly configured .graphqlconfig file, so follow the examples linked to create an appropriate setup.

LSP configuration is handled through GraphQL Config to handle custom directives/documents/validation etc.

These files will also be useful to other editors, so it would be worth checking them into version control.

Frequently asked questions

This module has no FAQs yet. Ask one?

TODO Appendix

🔨 This module has no appendix yet. Write one?