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

interface implements interface does not produce the correct schema during introspection #677

Open kawazoe opened 11 months ago

kawazoe commented 11 months ago

Describe the bug When an interface implements another interface, the schema produced by the plugin is missing the deeper interface declaration. This results in invalid schemas, even though other tools like Banana Cake Pop produces the correct schema.

To Reproduce Use the plugin to Get API Schema From Endpoint for an endpoint with the following schema

interface IFoo {
  foo: String;
}

interface IBar implements IFoo {
  bar: String;
}

type Foo implements IFoo {
  foo: String;
}

type Bar implements IBar {
  foo: String;
  bar: String;
}

Expected behavior The schema produced by the plugin should be exactly the same and include the IFoo implementation at line 5.

Actual behavior The schema looks like this:

interface IFoo {
  foo: String;
}

interface IBar {
  bar: String;
}

type Foo implements IFoo {
  foo: String;
}

type Bar implements IBar {
  foo: String;
  bar: String;
}

Version and Environment Details Operation system: macOS 13.4 IDE name and version: WebStorm 2023.2 (beta), also validated with 2023.1 (stable) Plugin version: 4.0.1

Additional context I have noticed this issue when trying to define an interface that implements Node in a HotChocolate project. BananaCakePop produces the correct schema, but the plugin doesn't.

Scriptodude commented 11 months ago

If I may append to the issue.

The data of the extended interface is actually inserted into the final interface generated by the plugin rather than using the extension.

As an example a schema defined as follow:

interface A {
  A: int!
}

interface B extends A {
  B: string!
}

produces in the plugin:

interface A {
  A: int!
}

interface B {
  A: Int!
  B: string!
}

So B is not longer an "A" according to the generated schema, leading to weird behaviors and very subtile bugs.