graphql-spqr icon indicating copy to clipboard operation
graphql-spqr copied to clipboard

To write GraphQL types and field's argument description without changing name.

Open ttyniwa opened this issue 5 years ago • 1 comments

To write GraphQL types and field's argument description without changing name. Add @GraphQLArgument name default as empty string.

before:

@GraphQLArgument(name="", description="arg1 description") String arg1

after:

@GraphQLArgument(description="arg1 description") String arg1

ttyniwa avatar Oct 09 '19 13:10 ttyniwa

BTW, GraphQLQuery, Mutation, Subscription has default value as empty string. https://github.com/leangen/graphql-spqr/blob/master/src/main/java/io/leangen/graphql/annotations/GraphQLQuery.java#L17

I think it's better to make the same correction to GraphQLArgument for consistency.

ttyniwa avatar Oct 09 '19 13:10 ttyniwa

BTW, GraphQLQuery, Mutation, Subscription has default value as empty string. https://github.com/leangen/graphql-spqr/blob/master/src/main/java/io/leangen/graphql/annotations/GraphQLQuery.java#L17

I think it's better to make the same correction to GraphQLArgument for consistency.

The reason for this inconsistency is Java will normally lose argument names (unless you tell the compiler to reserve them), where as the method names are always kept. So method-level annotations always have a safe default, whereas parameter annotation normally don't, so the mandatory name in @GraphQLArgument was meant to encourage the users not to ignore this.

But I agree that it can also also be annoying, e.g. when you know you have parameter names preserved and want to add descriptions. So I agree with you and will merge your PR.

kaqqao avatar Apr 13 '23 17:04 kaqqao