Open
Description
Expected Behavior
When I create a schema.graphql containing a non-null query argument that has a default value, I would expect to not have to pass that argument to the query.
Current Behavior
The type system gives me an error, asking me to add the query argument.
Possible Solution
The generation logic should treat non-null query arguments with a default value the same as if they were optional.
Relevant part of the spec: https://spec.graphql.org/October2021/#sec-Required-Arguments
Steps to Reproduce
- Create a
schema.graphql
like this:
type Row {
id: ID!
}
type Query {
rows(limit: Int! = 10): [Row!]!
}
- Run
npx graphql-zeus@5.3.1 schema.graphql --typedDocumentNode
- Inspect
zeus/index.ts
:
...
export type ValueTypes = {
['Row']: AliasType<{
id?: boolean | `@${string}`,
__typename?: boolean | `@${string}`
}>;
['Query']: AliasType<{
// Here I would expect "limit" to be optional, because the default value is "10".
rows?: [{ limit: number | Variable<any, string> }, ValueTypes['Row']],
__typename?: boolean | `@${string}`
}>
}
...
Additional information
- Node.js version
18.17.1
. - graphql-zeus version
5.3.1
. - graphql version
16.8.0
. - @apollo/client version
3.8.3
. - Typescript version
5.1.6
. - using
typedDocumentNode
for the Apollo client in Angular.
References
Metadata
Metadata
Assignees
Labels
No labels