js-graphql-intellij-plugin icon indicating copy to clipboard operation
js-graphql-intellij-plugin copied to clipboard

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

Open honza-zidek opened this issue 3 years ago • 6 comments

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
}
  1. 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)

honza-zidek avatar Nov 25 '21 14:11 honza-zidek

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?

vepanimas avatar Nov 25 '21 15:11 vepanimas

@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>
  • and yes, it seems supporting the @deprecated directive on fields. The generated code looks like this:
@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 avatar Nov 25 '21 15:11 honza-zidek

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

honza-zidek avatar Nov 25 '21 16:11 honza-zidek

@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 avatar Nov 25 '21 16:11 vepanimas

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

vepanimas avatar Nov 25 '21 17:11 vepanimas

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

ndwhelan avatar Aug 11 '22 16:08 ndwhelan

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

?

FreekVanDooren avatar Aug 17 '22 12:08 FreekVanDooren

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: @.***>

ndwhelan avatar Aug 17 '22 14:08 ndwhelan

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

FreekVanDooren avatar Aug 18 '22 07:08 FreekVanDooren

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

ajkerr avatar Sep 14 '22 01:09 ajkerr