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

Omittable can now be serialized as json #2839

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

endSly
Copy link
Contributor

@endSly endSly commented Nov 7, 2023

The Omittable struct lacks the necessary JSON unmarshaller and marshaller implementations. As a result, instances of this struct are serialized as empty JSON objects ({}) even when they contain data.

For instance, consider the following Go struct:

struct {
	ID     graphql.Omittable[*string]     `json:"id,omitempty"`
	Bool   graphql.Omittable[*bool]       `json:"bool,omitempty"`
	Str    graphql.Omittable[*string]     `json:"str,omitempty"`
}

This struct is being serialized as:

{
  "id": {},
  "bool": {},
  "str": {},
}

I have:

  • Added tests covering the bug / feature (see testing)
  • Updated any relevant documentation (see docs)

@coveralls
Copy link

Coverage Status

coverage: 76.16% (+0.1%) from 76.039%
when pulling 302dbc8 on endSly:omittable-json
into 132ec1c on 99designs:master.

@StevenACoffman StevenACoffman merged commit c0ca509 into 99designs:master Nov 7, 2023
18 checks passed
@StevenACoffman
Copy link
Collaborator

Thanks! I appreciate you adding this, and I'm looking forward to more PRs from you!

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.

3 participants