0

I have added leangen/graphql-spqr as described in the readme. Before we had a custom implementation of graphql types like in customtype.types.gql.

After implementation, everything works fine, except the type which are called e.g. OperatorInput, are named in the autogenerated graphql doc like "OperatorInputInput". I tried to Change it like this in the declaration:

@GraphQLArgument(name = "OperatorInput", description = "Required fields for Operator") OperatorInput operator

But it wasn't applied. Do you know any workaround?

John Conde
  • 217,595
  • 99
  • 455
  • 496
AlwinF
  • 1

1 Answers1

0

This is intended. Keep in mind that in GraphQL's type system, input and output types are strictly different. Let's say you have this in Java:

public Book saveBook(Book in) {...}

The Book that is the return type and the Book that is the argument type are 2 different types in GraphQL, and must have unique names. So Input is added automatically to make the names unique.

If you're 100% sure you want to override this, register a custom TypeInfoGenerator via GraphQLSchemaGenerator#withTypeInfoGenerator. You can inherit from DefaultTypeInfoGenerator and override generateInputTypeName. BUT! Do pay attention that if you end up producing the same name for 2 different types, all hell breaks loose. So maybe only drop the suffix Input if the classname already ends with Input and never ever use such classes for output.

Btw @GraphQLArgument sets the name of the argument, not the name of the type of the argument.

kaqqao
  • 12,984
  • 10
  • 64
  • 118
  • 1
    @kaqqaio thank you so much. This makes sense! – AlwinF Mar 13 '21 at 17:24
  • For me it does not make sense at all. I don't really understand why the framework changes any naming convention for me. Right now I have a situation when I'm rewriting an old backend created in Spring Boot and because of this I can't keep the same schema structure. I'm sorry but in my opinion this is a nonsense to make it a default behavior. – Łukasz Grabski Mar 21 '21 at 18:19
  • Another point is: lets say I have this mentioned Book DTO/entity or however we will call it - then I will need to have the same name for input and output: Book, which makes it very invoventient inconvenient to use in java code as I will need to do qualified name for one of them : – Łukasz Grabski Mar 21 '21 at 18:29