Open
Description
Expected Behavior
When generating the SDL for an InputObject with defined defaults, the defaultable field should not be marked as required (no '!' type).
The following InputObject:
#[derive(InputObject)]
struct SampleInput {
required_input: i32,
#[graphql(default = 1)]
optional_input: i32
}
Should generate the following SDL input definition:
input SampleInput {
optionalInput: Int = 1
requiredInput: Int!
}
Actual Behavior
The following SDL is generated with the optionalInput
field marked as required:
input SampleInput {
optionalInput: Int! = 1
requiredInput: Int!
}
Steps to Reproduce the Problem
Use the following code to reproduce:
use async_graphql::{Schema, EmptyMutation, EmptySubscription, SDLExportOptions};
use async_graphql_derive::{InputObject, Object};
struct Query;
#[Object]
impl Query {
async fn sample(&self, _input: SampleInput) -> i32 {
1
}
}
#[derive(InputObject)]
struct SampleInput {
required_input: i32,
#[graphql(default = 1)]
optional_input: i32
}
fn main() {
let schema = Schema::build(Query, EmptyMutation, EmptySubscription).finish();
let sdl_opts = SDLExportOptions::new().sorted_arguments().sorted_fields();
println!("{}", schema.sdl_with_options(sdl_opts));
}
Specifications
- Version: 5.x, source
- Platform: MacOS/Ubuntu
- Subsystem: N/A