-
Notifications
You must be signed in to change notification settings - Fork 105
Description
According to the docs (https://graphqlite.thecodingmachine.io/docs/input-types) when you use an update=true input type, it removes default parameters:
Note that update: true argument for UpdateUserInput. It should be used when input type is used for a partial update, It makes all fields optional and removes all default values
Inspecting the GraphQL schema proves that this is the case - default parameters exist for the "create" input type, and do not exist for the "update" input type.
However, the actual PHP "update" input object still has the default parameter.
Full example:
/**
* @GraphQL\Input(name="CreateBlogPostInput", default=true, update=false)
* @GraphQL\Input(name="UpdateBlogPostInput", update=true)
*/
class BlogPostInput {
/**
* @GraphQL\Field
*/
public string $title;
/**
* @GraphQL\Field
*/
public string $content;
/**
* @GraphQL\Field(inputType="Boolean")
*/
public bool $published = true;
}The GraphQL schema for CreatePostInput is generated as:
title: String!
content: String!
published: Boolean = true
The PHP object will default $input->published to true if it's not passed in.
The GraphQL schema for UpdatePostInput is generated as:
title: String
content: String
published: Boolean
However, the PHP object will still default $input->published to true if it's not passed in.
I believe that for the Update input, we should unset($input->published) in this case, which would make it null/not initialised depending on the PHP version.