Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphql Scheme Generation adds type subfix (like "_Int") #28249

Open
daviddavidgit opened this issue Sep 28, 2022 · 9 comments
Open

Graphql Scheme Generation adds type subfix (like "_Int") #28249

daviddavidgit opened this issue Sep 28, 2022 · 9 comments
Labels

Comments

@daviddavidgit
Copy link

Describe the bug

Graphql schema generation adds a type subfix (like "_Int") at the generated schema type names.

I have following classes (taken from SmallRye GraphQL extension guide)

public class Id<T> {
    public T id;
}

public class Film extends Id<Integer> {
    public String title;
    public Integer episodeID;
    public String director;
    public LocalDate releaseDate;
}

Accessing the schema through the introspect gives not the expected schema.

Expected behavior

Output of Introspect:

type Film {
  director: String
  episodeID: Int
  id: Int
  "ISO-8601"
  releaseDate: Date
  title: String
}

"Query root"
type Query {
  "Get all Films from a galaxy far far away"
  allFilms: [Film]
}

Actual behavior

Output of Introspect:

type Film_Int {
  director: String
  episodeID: Int
  id: Int
  "ISO-8601"
  releaseDate: Date
  title: String
}

"Query root"
type Query {
  "Get all Films from a galaxy far far away"
  allFilms: [Film_Int]
}

How to Reproduce?

I have created a small reproducer: https://github.com/daviddavidgit/quarkus-simple-graphql-schema-generation
It is based on: https://quarkus.io/guides/smallrye-graphql

Output of uname -a or ver

Linux david-ThinkPad-X1-Extreme-Gen-3 5.14.0-1051-oem #58-Ubuntu SMP Fri Aug 26 05:50:00 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "11.0.16" 2022-07-19 OpenJDK Runtime Environment (build 11.0.16+8-post-Ubuntu-0ubuntu122.04) OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.10.0

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6

Additional information

With Quarkus 2.9.0 it still worked.
With Quarkus 2.12.3 it does not work.

The problem might be in the SchemaPrinter of graphql-java.

@daviddavidgit daviddavidgit added the kind/bug Something isn't working label Sep 28, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 28, 2022

/cc @jmartisk, @phillip-kruger

@phillip-kruger
Copy link
Member

It's because you extends a type with a generic int type. This is how we handle generics in graphql

@daviddavidgit
Copy link
Author

ok thank you.
What is the reason for this change?

@peschee
Copy link

peschee commented Sep 28, 2022

This is how we handle generics in graphql

Is this documented somewhere (e.g. in a changelog)?

@phillip-kruger
Copy link
Member

Hi @peschee @ daviddavidgit, not in a changelog a.f.a.i.k. It's been in for a while, so you must be changing from a very old version ? It was not really a change, but rather a new feature: "Support generics" (smallrye/smallrye-graphql#281)

@daviddavidgit
Copy link
Author

According to my small reproducer this feature seems to be added since Quarkus 2.10.0.

@phillip-kruger
Copy link
Member

I'll have a look, maybe support for interfaces/ abstract objects was added. In either way, what you see as the output is the correct generation.

@jmartisk
Copy link
Contributor

Hmmm, to me, it doesn't sound right that we append the type parameter to the name. Or is there a particular reason?
The fact that a Film has an Int ID is an internal detail, no reason to put it into the type name.
It even seems that you can't override it using @Name. When you add a @Name on the Film class, it still appends _Int to the value from that annotation.

@phillip-kruger
Copy link
Member

@jmartisk maybe check what changes in the version mentioned. I do recall bugs logged about this, especially w.r.t mongo usage. But that feels longer ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants