tartiflette-plugin-isodate
ISO Date Format Directive for Tartiflette
TOC
Overview
The tartiflette-plugin-isodate
plugin adds an @isoDate
directive to tartiflette.
Installation
To install with poetry:
$ poetry add tartiflette-plugin-isodate
To install with pip:
$ pip install tartiflette-plugin-isodate
Usage
type Example {
createdAt: String @isoDate
}
Querying createdAt
would return the following:
{
"data": {
"example": {
"createdAt": "2019-09-04T13:49:12.585158+00:00"
}
}
}
Options
The @isoDate
also takes the following optional arguments:
@isoDate(microseconds: false)
Returns date and time without microseconds.
type Example {
createdAt: String @isoDate(microseconds: false)
}
Querying createdAt
would return the following:
{
"data": {
"example": {
"createdAt": "2019-09-04T13:49:12+00:00"
}
}
}
@isoDate(timezone: false)
Returns date and time without timezone.
type Example {
createdAt: String @isoDate(timezone: false)
}
Querying createdAt
would return the following:
{
"data": {
"example": {
"createdAt": "2019-09-04T13:49:12.585158"
}
}
}
@isoDate(utc: false)
Returns date and time in the local timezone.
type Example {
createdAt: String @isoDate(utc: false)
}
Querying createdAt
would return the following:
{
"data": {
"example": {
"createdAt": "2019-09-04T09:49:12.585158-04:00"
}
}
}
The arguments can be used in any combination and will return an ISO8601 compliant date.
For example settings microseconds
to false
and timezone
to true
would yield: 2019-09-04T13:49:12+00:00.
Possible combinations:
-
@isoDate
>> "2019-09-04T13:49:12.585158+00:00" -
@isoDate(timezone: false)
>> "2019-09-04T13:52:43.476260" -
@isoDate(microseconds: false)
>> "2019-09-04T13:50:02+00:00" -
@isoDate(microseconds: false, timezone: false)
>> "2019-09-04T13:53:31"
The time can also be set to the local
time by setting utc
to false
.
@isoDate(utc: false)
>> "2019-09-04T09:50:02+00:00"
Using the @isoDate
directive will override any value sent.