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

Add EnableClientJsonOmitemptyTag to Config #253

Merged
merged 8 commits into from
Dec 18, 2024

Conversation

abe-tetsu
Copy link
Contributor

@abe-tetsu abe-tetsu commented Dec 18, 2024

EnableClientJsonOmitemptyTag is a boolean value that controls whether to add the omitempty option to JSON tags.

While gqlgen includes this as a configuration option, gqlgenc does not.
As a result, it has not been possible to control the presence of omitempty on the client side.

This PR introduces EnableClientJsonOmitemptyTag to address this limitation.

  • Before the addition:
type Order struct {
	ID             string         "json:\"id\" graphql:\"id\""
	OrganizationID string         "json:\"organizationID\" graphql:\"organizationID\""
	LineItem       *OrderLineItem "json:\"orderLineItem,omitempty\" graphql:\"orderLineItem\""
}
  • After the addition (when EnableClientJsonOmitemptyTag is set to false):
type Order struct {
	ID             string         "json:\"id\" graphql:\"id\""
	OrganizationID string         "json:\"organizationID\" graphql:\"organizationID\""
	LineItem       *OrderLineItem "json:\"orderLineItem\" graphql:\"orderLineItem\""
}

@abe-tetsu abe-tetsu marked this pull request as draft December 18, 2024 09:04
@abe-tetsu abe-tetsu marked this pull request as ready for review December 18, 2024 10:07
@abe-tetsu abe-tetsu changed the title Add EnableModelJsonOmitemptyTag to Config Add EnableClientJsonOmitemptyTag to Config Dec 18, 2024
@Yamashou Yamashou merged commit 9193658 into Yamashou:master Dec 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants