Skip to content

Commit

Permalink
MissingPackageResult field in CheckPackageVersionUpdateInput made Nul…
Browse files Browse the repository at this point in the history
…lable (#485)

* MissingPackageResult field in CheckPackageVersionUpdateInput made Nullable

* add NewNullOf and revert NewNull behavior

* Update scalar.go

better NewNullOf description

Co-authored-by: Kyle <[email protected]>

---------

Co-authored-by: Kyle <[email protected]>
  • Loading branch information
davidbloss and rocktavious authored Oct 22, 2024
1 parent 7833c1d commit 68ee5fb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .changes/unreleased/Bugfix-20241022-093210.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Bugfix
body: 'BREAKING CHANGE: CheckPackageVersionUpdateInput changed to allow MissingPackageResult to be nullable'
time: 2024-10-22T09:32:10.794966-05:00
68 changes: 34 additions & 34 deletions input.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func IsID(value string) bool {

// NullableConstraint defines what types can be nullable - keep separated using the union operator (pipe)
type NullableConstraint interface {
string
~string
}

// Nullable can be used to unset a value using an OpsLevel input struct type, should always be instantiated using a constructor.
Expand All @@ -94,8 +94,13 @@ func (nullable Nullable[T]) MarshalJSON() ([]byte, error) {
return json.Marshal(nullable.Value)
}

// NewNull returns a Nullable that will always marshal into `null`, can be used to unset fields
func NewNull[T NullableConstraint]() *Nullable[T] {
// NewNull returns a Nullable string that will always marshal into `null`, can be used to unset fields
func NewNull[T string]() *Nullable[T] {
return NewNullOf[T]()
}

// NewNullOf returns a Nullable of any type that fits NullableConstraint that will always marshal into `null`, can be used to unset fields
func NewNullOf[T NullableConstraint]() *Nullable[T] {
return &Nullable[T]{
SetNull: true,
}
Expand Down

0 comments on commit 68ee5fb

Please sign in to comment.