Skip to content

Be able to set null for date input #5777

@locopati

Description

@locopati

Describe the bug
I want to clear the date that was set on a field

Steps to reproduce the behavior

  1. Create a type with a date field that is not required
  2. Create an instance of the type with a value in the date field and save it
  3. Edit the instance and clear the date field
  4. It cannot be cleared
  5. Make a GraphQL request to clear the field
  6. The request errors

Expected behavior
You can clear the field in the UI
The GraphQL mutation works

Code snippets

mutation UnsetDate($id: ID!) {
  updateYourType(input:{
    where:{
      id: $id
    },
    data: {
      date_field: null
    }
  }) {
    your_type { 
      id
      date_field
    }
  }
}

This returns "message": "Expected type Date, found \"\"; Date cannot represent an invalid date-string ."

System

  • Node.js version: 13.7
  • Yarn version: 1.22
  • Strapi version: 3b19.5
  • Database: Mongo 4.2.5
  • Operating system: Arch Linux 4.19-97

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersissue: bugIssue reporting a bugseverity: mediumIf it breaks the basic use of the product but can be worked aroundsource: core:strapiSource is core/strapi packagestatus: confirmedConfirmed by a Strapi Team member or multiple community members

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions