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
880 stars 97 forks source link

ID scalar type #634

Closed glebsts closed 1 year ago

glebsts commented 1 year ago

Hi there, First of all, thank you for great products!

I was composing a graphql payload for my tests having field of ID type, and when I Ctrl+clicked this type it brought me to plugin docs saying:

When expected as an input type, any string (such as "4") or integer (such as 4) input value will be accepted as an ID

So I bravely left 4 as my ID field. It broke on deserialization during test run, saying string was expected (using gengql for Go), so I went to graphql.org for truth and found there:

ID: The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable.

Suggestion: improve docs removing mention of integer as a good value for standard ID scalar type.

vepanimas commented 1 year ago

Hi, @glebsts. You can definitely specify an integer for the ID scalar type, your case should be related to the specific graphql implementation used, e.g. gengql.

Input Coercion When expected as an input type, any string (such as "4") or integer (such as 4 or -4) input value should be coerced to ID as appropriate for the ID formats a given GraphQL service expects. Any other input value, including float input values (such as 4.0), must raise a request error indicating an incorrect type.