Js-graphql-intellij-plugin: Indentation in gql` string literals is wrong, unconfigurable

Created on 5 Jun 2019  路  10Comments  路  Source: jimkyndemeyer/js-graphql-intellij-plugin

Version and Environment Details

__Operation system__: macOS 10.14.5

__IDE name and version__: InteliJ IDEA Ultimate 2019.1.3

__Plugin version__: v2.1.0

Expected Behaviour

I should be able to configure the number of spaces used for indentation in .graphql files and in gql string literals. These two indentation setups should be the same.

Actual Behaviour

In my current setup I have my JS files set to indent code at 2 spaces. When these files include gql string literals the indentation within that gql code is 4 spaces. In my fully GraphQL files like thing.graphql the indentation is handled with 2 spaces.

In this issue #180 there is a mention of the GraphQL pane in the Preferences > Code Style. I don't see this pane any longer. Was it removed, or do I have something misconfigured? Forgive me if this is something wrong about my install. I couldn't find any details about how to set this in past issues or the existing documentation.

Steps to Reproduce / Link to Repo with Reproduction and Instructions

Create a .js file, add a gql string literal. If you have your Javascript indent spaces set to 2 spaces, the gql fragment will still get set to 4 spaces.

Most helpful comment

Hmm, it appears the the "Other File Types" setting only applies to .graphql files and not injected GraphQL in JavaScript.

I haven't changed anything between 2.0 and 2.1 so not sure what's going on. Could be a change in how the IntelliJ platform formats injected languages.

It's likely that the code style page for GraphQL needs to be reintroduced to fix this.

All 10 comments

I faced with same issue. Seems like it happens after upgrade plugin to 2.1 from 2.0 or idea to 2019.1.3 from EAP

Same here. After updating WebStorm to 2019.1.3 have got 4 spaces indentation in string literals with no possibility to configure

Same issue for me (using windows).

The dedicated code style tab was lost in the 1.x to 2.x migration.

For now, the GraphQL indentation is controlled by the following setting:

image

@jimkyndemeyer

screencast 2019-06-13 11-18-56 gif sb-779b8554-bYSWsX

Seems like this option is not working too.

@EugeneDraitsev Try with tab size 1:

image

I tried invalidate cache and restart idea, different values here, but it still works like Tab Size: 4 and Indent: 4
screencast 2019-06-13 12-05-50 gif sb-779b8554-FeU3VC

Hmm, it appears the the "Other File Types" setting only applies to .graphql files and not injected GraphQL in JavaScript.

I haven't changed anything between 2.0 and 2.1 so not sure what's going on. Could be a change in how the IntelliJ platform formats injected languages.

It's likely that the code style page for GraphQL needs to be reintroduced to fix this.

Fixed in 2.2.0 pending JetBrains approval: Added Code Style settings page to control indentation

I can confirm with the updated plugin that this fixes the problem. Thanks for getting it fixed so quickly.

Was this page helpful?
0 / 5 - 0 ratings