-
-
Notifications
You must be signed in to change notification settings - Fork 802
Fix SlicingArgumentDefaultValue within ListSizeAttribute
#9369
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
Merged
glen-84
merged 10 commits into
ChilliCream:main
from
N-Olbert:SlicingArgumentDefaultValue
Mar 19, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c31ccd6
Fix `SlicingArgumentDefaultValue` within `ListSizeAttribute` and adde…
N-Olbert 65ffb8f
PR comment: Change default value in `ListSizeAttribute` to `null`
N-Olbert c236e9f
Undo (wrong) migration note
N-Olbert 36bd54a
Merge branch 'main' into SlicingArgumentDefaultValue
N-Olbert 9a1be4d
Replace Unset-sentinel with nullable backing fields
N-Olbert 2654822
Merge branch 'main' into SlicingArgumentDefaultValue
N-Olbert 507cba8
Document NotSupportedException
N-Olbert b7918c6
Remove extra spaces
glen-84 6d58618
Merge branch 'main' into SlicingArgumentDefaultValue
glen-84 e771bed
Update comment
glen-84 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
40 changes: 40 additions & 0 deletions
40
..._/SlicingArgumentsTests.SlicingArgumentDefaultValue_Inferred_From_DefaultPageSize.graphql
This file contains hidden or 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,40 @@ | ||
| schema { | ||
| query: Query2 | ||
| } | ||
|
|
||
| "A connection to a list of items." | ||
| type FoosConnection { | ||
| "Information to aid in pagination." | ||
| pageInfo: PageInfo! | ||
| "A list of edges." | ||
| edges: [FoosEdge!] | ||
| "A flattened list of the nodes." | ||
| nodes: [Int!] | ||
| } | ||
|
|
||
| "An edge in a connection." | ||
| type FoosEdge { | ||
| "A cursor for use in pagination." | ||
| cursor: String! | ||
| "The item at the end of the edge." | ||
| node: Int! | ||
| } | ||
|
|
||
| "Information about pagination in a connection." | ||
| type PageInfo { | ||
| "Indicates whether more edges exist following the set defined by the clients arguments." | ||
| hasNextPage: Boolean! | ||
| "Indicates whether more edges exist prior the set defined by the clients arguments." | ||
| hasPreviousPage: Boolean! | ||
| "When paginating backwards, the cursor to continue." | ||
| startCursor: String | ||
| "When paginating forwards, the cursor to continue." | ||
| endCursor: String | ||
| } | ||
|
|
||
| type Query2 { | ||
| foos("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FoosConnection @listSize(assumedSize: 50, slicingArguments: ["first", "last"], slicingArgumentDefaultValue: 42, sizedFields: ["edges", "nodes"], requireOneSlicingArgument: false) | ||
| } | ||
|
|
||
| "The purpose of the `@listSize` directive is to either inform the static analysis about the size of returned lists (if that information is statically available), or to point the analysis to where to find that information." | ||
| directive @listSize("The `assumedSize` argument can be used to statically define the maximum length of a list returned by a field." assumedSize: Int "The `slicingArguments` argument can be used to define which of the field's arguments with numeric type are slicing arguments, so that their value determines the size of the list returned by that field. It may specify a list of multiple slicing arguments." slicingArguments: [String!] "The `slicingArgumentDefaultValue` argument can be used to define a default value for a slicing argument, which is used if the argument is not present in a query." slicingArgumentDefaultValue: Int "The `sizedFields` argument can be used to define that the value of the `assumedSize` argument or of a slicing argument does not affect the size of a list returned by a field itself, but that of a list returned by one of its sub-fields." sizedFields: [String!] "The `requireOneSlicingArgument` argument can be used to inform the static analysis that it should expect that exactly one of the defined slicing arguments is present in a query. If that is not the case (i.e., if none or multiple slicing arguments are present), the static analysis may throw an error." requireOneSlicingArgument: Boolean = true) on FIELD_DEFINITION |
40 changes: 40 additions & 0 deletions
40
...s.SlicingArgumentDefaultValue_ListSizeAttribute_HasPrecedenceOver_DefaultPageSize.graphql
This file contains hidden or 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,40 @@ | ||
| schema { | ||
| query: Query3 | ||
| } | ||
|
|
||
| "A connection to a list of items." | ||
| type FoosConnection { | ||
| "Information to aid in pagination." | ||
| pageInfo: PageInfo! | ||
| "A list of edges." | ||
| edges: [FoosEdge!] | ||
| "A flattened list of the nodes." | ||
| nodes: [Int!] | ||
| } | ||
|
|
||
| "An edge in a connection." | ||
| type FoosEdge { | ||
| "A cursor for use in pagination." | ||
| cursor: String! | ||
| "The item at the end of the edge." | ||
| node: Int! | ||
| } | ||
|
|
||
| "Information about pagination in a connection." | ||
| type PageInfo { | ||
| "Indicates whether more edges exist following the set defined by the clients arguments." | ||
| hasNextPage: Boolean! | ||
| "Indicates whether more edges exist prior the set defined by the clients arguments." | ||
| hasPreviousPage: Boolean! | ||
| "When paginating backwards, the cursor to continue." | ||
| startCursor: String | ||
| "When paginating forwards, the cursor to continue." | ||
| endCursor: String | ||
| } | ||
|
|
||
| type Query3 { | ||
| foos("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FoosConnection @listSize(assumedSize: 10, slicingArguments: ["first", "last"], slicingArgumentDefaultValue: 999, sizedFields: ["edges", "nodes"], requireOneSlicingArgument: false) | ||
| } | ||
|
|
||
| "The purpose of the `@listSize` directive is to either inform the static analysis about the size of returned lists (if that information is statically available), or to point the analysis to where to find that information." | ||
| directive @listSize("The `assumedSize` argument can be used to statically define the maximum length of a list returned by a field." assumedSize: Int "The `slicingArguments` argument can be used to define which of the field's arguments with numeric type are slicing arguments, so that their value determines the size of the list returned by that field. It may specify a list of multiple slicing arguments." slicingArguments: [String!] "The `slicingArgumentDefaultValue` argument can be used to define a default value for a slicing argument, which is used if the argument is not present in a query." slicingArgumentDefaultValue: Int "The `sizedFields` argument can be used to define that the value of the `assumedSize` argument or of a slicing argument does not affect the size of a list returned by a field itself, but that of a list returned by one of its sub-fields." sizedFields: [String!] "The `requireOneSlicingArgument` argument can be used to inform the static analysis that it should expect that exactly one of the defined slicing arguments is present in a query. If that is not the case (i.e., if none or multiple slicing arguments are present), the static analysis may throw an error." requireOneSlicingArgument: Boolean = true) on FIELD_DEFINITION |
52 changes: 52 additions & 0 deletions
52
...apshots__/StaticQueryAnalysisTests.Execute_ListQuery_ReturnsExpectedResult_9.md
This file contains hidden or 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,52 @@ | ||
| # Execute_ListQuery_ReturnsExpectedResult | ||
|
|
||
| ## Query | ||
|
|
||
| ```graphql | ||
| { | ||
| examples { | ||
| field1 | ||
| field2 | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Result | ||
|
|
||
| ```text | ||
| { | ||
| "data": { | ||
| "examples": [ | ||
| { | ||
| "field1": true, | ||
| "field2": 1 | ||
| } | ||
| ] | ||
| }, | ||
| "extensions": { | ||
| "operationCost": { | ||
| "fieldCost": 1, | ||
| "typeCost": 43 | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Schema | ||
|
|
||
| ```text | ||
| type Query { | ||
| examples(limit: Int): [Example!]! | ||
| @listSize( | ||
| slicingArguments: ["limit"], | ||
| assumedSize: 10, | ||
| requireOneSlicingArgument: false, | ||
| slicingArgumentDefaultValue: 42 | ||
| ) | ||
| } | ||
|
|
||
| type Example { | ||
| field1: Boolean! | ||
| field2: Int! | ||
| } | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.