JetBrains / js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
MIT License
879 stars 97 forks source link

Allow deprecation of input values (field args, directive args, input fields) #507

Closed honza-zidek closed 2 years ago

honza-zidek commented 2 years ago

Describe the bug An unexpected error message "... tried to use a directive 'deprecated' in the 'INPUT_FIELD_DEFINITION' location but that is illegal"

To Reproduce

  1. In IntelliJ, create a *.graphqls file
  2. Type
    input MyData {
    name: String
    surname: String
    familyName: String @deprecated
    city: String
    }
  3. You get an error on the line familyName: "'familyName' tried to use a directive 'deprecated' in the 'INPUT_FIELD_DEFINITION' location but that is illegal"

Expected behavior I don't think that @deprecated is illegal there - please explain or fix.

Screenshots image

Version and Environment Details IntelliJ IDEA 2021.2.3 (Ultimate Edition) Build #IU-212.5457.46, built on October 12, 2021 Runtime version: 11.0.12+7-b1504.40 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 10 10.0 Non-Bundled Plugins: com.intellij.lang.jsgraphql (3.0.0), com.haulmont.jpab (5.8-212)

vepanimas commented 2 years ago

Hi @honza-zidek! Thank you for the report. This RFC https://github.com/graphql/graphql-spec/pull/805 is in-progress, in the latest published draft spec https://spec.graphql.org/draft/#sec--deprecated is still defined as

directive @deprecated(
  reason: String = "No longer supported"
) on FIELD_DEFINITION | ENUM_VALUE

What GraphQL implementation do you use on the server-side, does it already support this?

honza-zidek commented 2 years ago

@vepanimas: as for the GraphQL implementation:

<dependency>
    <groupId>com.graphql-java-kickstart</groupId>
    <artifactId>graphql-spring-boot-starter</artifactId>
    <version>11.0.0</version>
</dependency>

<dependency>
    <groupId>com.graphql-java-kickstart</groupId>
    <artifactId>graphql-webclient-spring-boot-starter</artifactId>
    <version>1.0.0</version>
</dependency>

<plugin>
    <groupId>io.github.kobylynskyi</groupId>
    <artifactId>graphql-codegen-maven-plugin</artifactId>
    <version>5.1.0</version>
</plugin>
@javax.annotation.processing.Generated(
    value = "com.kobylynskyi.graphql.codegen.GraphQLCodegen",
    date = "2021-11-25T15:13:51+0100"
)
public class MyDataDTO implements java.io.Serializable {
input MyData {
    private String name;
    private String surname;
    @Deprecated
    private String familyName;
    private String city;
    ...
}
honza-zidek commented 2 years ago

@vepanimas

... in the latest published draft spec https://spec.graphql.org/draft/#sec--deprecated is still defined as

directive @deprecated(
  reason: String = "No longer supported"
) on FIELD_DEFINITION | ENUM_VALUE

What do you mean by "still defined"? I think it is just "defined" :) The text "No longer supported" just explains why something is deprecated, not that the feature is not supported :)

And I believe that INPUT_FIELD_DEFINITION is a subset of FIELD_DEFINITION, so it should be valid there, too.

vepanimas commented 2 years ago

@honza-zidek in the left part of the mentioned PR, you can see how it was defined earlier ("still" defined in the current draft specification, because it hasn't been merged yet), in the right part - how it will be defined in the future.

rfc

Also, INPUT_FIELD_DEFINITION has no relation to FIELD_DEFINITION, it can't be treated as a "subset". This is one of the reasons why this RFC exists at all, and you couldn't use a deprecation directive on the input field before.

vepanimas commented 2 years ago

https://github.com/graphql-java/graphql-java/pull/2186

ndwhelan commented 2 years ago

I've just ran into this issue. Would y'all be receptive to a PR?

FreekVanDooren commented 2 years ago

I've just ran into this issue. Would y'all be receptive to a PR?

Me too. I've never tried to do anything with plugins, so not sure how to test any changes... Would there be more involved in this than changing https://github.com/JetBrains/js-graphql-intellij-plugin/blob/master/resources/definitions/Specification.graphql#L60 to

directive @deprecated(reason: String = "No longer supported") on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE

?

ndwhelan commented 2 years ago

I don't think so, but I also have no experience building IntelliJ plugins. I guess I can deal with a red squiggly line... Not sure JetBrains is very invested in this plug-in.

On Wed, Aug 17, 2022, 7:10 AM FreekVanDooren @.***> wrote:

I've just ran into this issue. Would y'all be receptive to a PR?

Me too. I've never tried to do anything with plugins, so not sure how to test any changes... Would there be more involved in this than changing https://github.com/JetBrains/js-graphql-intellij-plugin/blob/master/resources/definitions/Specification.graphql#L60 to

directive @deprecated(reason: String = "No longer supported") on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE

?

— Reply to this email directly, view it on GitHub https://github.com/JetBrains/js-graphql-intellij-plugin/issues/507#issuecomment-1217925566, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHINQY45UZECLV2K5OBCJTVZTJCHANCNFSM5IYUEWXA . You are receiving this because you commented.Message ID: @.***>

FreekVanDooren commented 2 years ago

Not sure JetBrains is very invested in this plug-in.

Don't know about that @vepanimas responded pretty quickly back in November.

I guess I can deal with a red squiggly line...

Red squiggly lines are haunting me in my dreams... 😥

ajkerr commented 2 years ago

Would be awesome to cut a new version of the plugin to get this new feature!