Uploaded image for project: 'Magnolia GraphQL'
  1. Magnolia GraphQL
  2. MGNLGQL-83

Support DateTime in GraphQL

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Done
    • Neutral
    • 1.0
    • None
    • Yes
    • HL & LD 26
    • 2

    Description

      Our GraphQL formats Date(Time) always into yyyy-mm-dd format. We need to support both Date and DateTime.

      Plan of action - based on conversation in comments

      • Introduce DateTime scalar which outputs values in 8601 ISO format: yyyy-mm-ddThh:mm:ss:sssZ
      • Change the system (metadata) properties defined by us to be DateTime
      • Keep the current  ContentType "Date" properties as is and have the generated GraphQL types be of scalar "Date" and output yyyy-mm-dd format. This is logical because ContentType-based app also renders a Date picker (not a Date & Time picker)

      One corner case we should document:

      If one decides to decorate CT generated app and enables time picker, then he/she should also decorate the respective GraphQL definition and set the type of the field to DateTime.

       In the future we plan to add a DateTime property type to ContentTypes system, which will then result in Date Time picker in the app and DateTime output in GraphQL.

       

       

       

      Previous Ideas

      We have a couple of options here:

      • specify another scalar type, e.g. DateTime
      • introduce a new argument for Date field called format which would take string parameter with requested format.
      • always return date in DateTime format.

      Option #2 seems most flexible - devs would not need to hassle with datetime formatting on the client and would get exactly what they want (which imo is the GraphQL way).

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                jsimak Jaroslav Simak
                jsimak Jaroslav Simak
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Task DoD

                    Time Tracking

                      Estimated:
                      Original Estimate - Not Specified
                      Not Specified
                      Remaining:
                      Remaining Estimate - Not Specified
                      Not Specified
                      Logged:
                      Time Spent - 0.75d
                      0.75d