-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
omitempty validation on input fields with/without defaults
- Loading branch information
Showing
28 changed files
with
499 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# very similar to DefaultInputsNoOmitPointerForDirective.graphql - same expected behaviour, but takes a different code path(?) | ||
# @genqlient(pointer: true) | ||
query DefaultInputs( | ||
$input: InputWithDefaults! | ||
) { | ||
default(input: $input) | ||
} |
8 changes: 8 additions & 0 deletions
8
generate/testdata/errors/DefaultInputsNoOmitPointerForDirective.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Non-nullable input field with default cannot be pointer without omitempty - as that | ||
# would send `null`, which is invalid value. | ||
# @genqlient(for: "InputWithDefaults.field", pointer: true) | ||
query DefaultInputs( | ||
$input: InputWithDefaults! | ||
) { | ||
default(input: $input) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# One of the input filed is non-nullable -> cannot omit it | ||
# @genqlient(omitempty: true) | ||
query OmitemptyDirective ( | ||
$input: OmitemptyInput | ||
) { | ||
omitempty(input: $input) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# The specific input field is non-nullable -> cannot omit it | ||
# @genqlient(for: "OmitemptyInput.field", omitempty: true) | ||
query OmitemptyDirective ( | ||
$input: OmitemptyInput | ||
) { | ||
omitempty(input: $input) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Without any extra directives or configuration, the defaults are never considered, | ||
# as the client sends at least zero-value (struct with empty string). | ||
query DefaultInputs( | ||
$input: InputWithDefaults! | ||
) { | ||
default(input: $input) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# The `InputWithDefaults.field` cannot be `pointer: true`, together with implicit `omitempty: false`, as `null` is | ||
# not a valid value there. However, nullableField should still be ok | ||
# (this will send null, overwriting the server's default) | ||
# @genqlient(for: "InputWithDefaults.nullableField", pointer: true) | ||
query DefaultInputs( | ||
$input: InputWithDefaults! | ||
) { | ||
default(input: $input) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# very similar to DefaultInputsWithForDirective.graphql - same expected behaviour, but takes a different code path(?) | ||
# @genqlient(omitempty: true) | ||
query DefaultInputs( | ||
$input: InputWithDefaults! | ||
) { | ||
default(input: $input) | ||
} |
7 changes: 7 additions & 0 deletions
7
generate/testdata/queries/DefaultInputsWithForDirective.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @genqlient(for: "InputWithDefaults.field", omitempty: true) | ||
# @genqlient(for: "InputWithDefaults.nullableField", omitempty: true) | ||
query DefaultInputs( | ||
$input: InputWithDefaults! | ||
) { | ||
default(input: $input) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @genqlient(omitempty: true) | ||
# @genqlient(for: "OmitemptyInput.field",omitempty: false) | ||
query OmitemptyFalse( | ||
$input: OmitemptyInput | ||
) { | ||
omitempty(input: $input) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
generate/testdata/snapshots/TestGenerate-DefaultInputs.graphql-DefaultInputs.graphql.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
generate/testdata/snapshots/TestGenerate-DefaultInputs.graphql-DefaultInputs.graphql.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"operations": [ | ||
{ | ||
"operationName": "DefaultInputs", | ||
"query": "\nquery DefaultInputs ($input: InputWithDefaults!) {\n\tdefault(input: $input)\n}\n", | ||
"sourceLocation": "testdata/queries/DefaultInputs.graphql" | ||
} | ||
] | ||
} |
69 changes: 69 additions & 0 deletions
69
...tdata/snapshots/TestGenerate-DefaultInputsPointer.graphql-DefaultInputsPointer.graphql.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...ata/snapshots/TestGenerate-DefaultInputsPointer.graphql-DefaultInputsPointer.graphql.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"operations": [ | ||
{ | ||
"operationName": "DefaultInputs", | ||
"query": "\nquery DefaultInputs ($input: InputWithDefaults!) {\n\tdefault(input: $input)\n}\n", | ||
"sourceLocation": "testdata/queries/DefaultInputsPointer.graphql" | ||
} | ||
] | ||
} |
Oops, something went wrong.