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

Plugin gives schema validation errors for values of an extended scalar type

Open luispollo opened this issue 2 years ago • 2 comments

Given the following directive in a schema:

scalar JSON

"Custom Annotation"
directive @annotate(
  name: String!
  inputs: JSON
) repeatable on OBJECT | FIELD_DEFINITION | INPUT_OBJECT | INPUT_FIELD_DEFINITION

The plugin will flag the usage of the @annotate directive as invalid syntax in the usage site, for example:

type MyType {
  prop: String @annotate(name: "MyAnnotation", inputs: {value: ["test"]})
}

Errors reported:

  • 'prop' uses an illegal value for the argument 'inputs' on directive 'annotate'. Argument value is of type 'ObjectValue', expected a scalar
  • Unknown field "value" on input type "JSON"

Note that JSON is an extended scalar I've registered in my application. I'm guessing the problem has something to do with the fact that it requires registration at runtime, so I'm not sure how that would work with an IntelliJ plugin.

To Reproduce

  1. In an IntelliJ project, create a GraphQL schema file recognized by the plugin
  2. Add the definitions above
  3. The editor will highlight the usage site with a syntax error

Expected behavior No syntax errors are reported.

Screenshots image image

Version and Environment Details

  • Operating system: MacOS Darwin lpollo-mac.local 21.6.0 Darwin Kernel Version 21.6.0: Thu Sep 29 20:13:56 PDT 2022; root:xnu-8020.240.7~1/RELEASE_ARM64_T6000 arm64
  • IDE name and version: IntelliJ IDEA 2022.3 (Ultimate Edition), Build #IU-223.7571.182, built on November 29, 2022
  • Plugin version: 3.3.0

luispollo avatar Dec 07 '22 18:12 luispollo

To add to the above description, the main issue is the fact that JSON is not recognized as a scalar when used with graphql-extended-scalars library : https://github.com/graphql-java/graphql-java-extended-scalars

srinivasankavitha avatar Dec 07 '22 18:12 srinivasankavitha

Any updates on this? Facing the same issue

torbenkeller avatar Jun 30 '24 15:06 torbenkeller