Skip to main content

ISO Date Formatter for Tartiflette

Project description

tartiflette-plugin-isodatenow

Buddy.Works logo.

buddy pipeline

ISO Date Format Directive for Tartiflette

TOC

Overview

The tartiflette-plugin-isodatenow plugin adds an @isoDateNow directive to tartiflette. It sets the field that it is on with the current time in ISO 8601 format. It is primarly intended for use in mutations as the directive overrides any value sent though it can be used in queries where a createdAt or response timestamp is required.

Installation

To install with poetry:

$ poetry add tartiflette-plugin-isodatenow

To install with pip:

$ pip install tartiflette-plugin-isodatenow

Usage

type Example {
    createdAt: String @isoDateNow
}

Querying createdAt would return the following:

{
    "data": {
        "example": {
            "createdAt": "2019-09-04T13:49:12.585158+00:00"
        }
    }
}

Options

The @isoDateNow also takes the following optional arguments:

@isoDateNow(microseconds: false)

Returns date and time without microseconds.

type Example {
    createdAt: String @isoDateNow(microseconds: false)
}

Querying createdAt would return the following:

{
    "data": {
        "example": {
            "createdAt": "2019-09-04T13:49:12+00:00"
        }
    }
}

@isoDateNow(timezone: false)

Returns date and time without timezone.

type Example {
    createdAt: String @isoDateNow(timezone: false)
}

Querying createdAt would return the following:

{
    "data": {
        "example": {
            "createdAt": "2019-09-04T13:49:12.585158"
        }
    }
}

@isoDateNow(utc: false)

Returns date and time in the local timezone.

type Example {
    createdAt: String @isoDateNow(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:

  • @isoDateNow >> "2019-09-04T13:49:12.585158+00:00"
  • @isoDateNow(timezone: false) >> "2019-09-04T13:52:43.476260"
  • @isoDateNow(microseconds: false) >> "2019-09-04T13:50:02+00:00"
  • @isoDateNow(microseconds: false, timezone: false) >> "2019-09-04T13:53:31"

The time can also be set to the local time by setting utc to false.

@isoDateNow(utc: false) >> "2019-09-04T09:50:02+00:00"

Using the @isoDateNow directive will override any value sent.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tartiflette-plugin-isodatenow-0.2.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file tartiflette-plugin-isodatenow-0.2.2.tar.gz.

File metadata

File hashes

Hashes for tartiflette-plugin-isodatenow-0.2.2.tar.gz
Algorithm Hash digest
SHA256 83c54be71e8d04adc198bea14d46530068433c76ee2c00d815878179302e3681
MD5 21587b86843a9f0cf68a74f8f661e568
BLAKE2b-256 a0e30934affcbfc2347dca4781210f372f5cf45ef0575341ef00ef6adfef49cf

See more details on using hashes here.

File details

Details for the file tartiflette_plugin_isodatenow-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for tartiflette_plugin_isodatenow-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d778af0d82ba6e2a5a93264277dd1bbee322a497740767fe9b1fa17405dd3d1
MD5 fc3e317c1dbeea3484ecf74c3d6fc400
BLAKE2b-256 1e3ddf2a5138a877508c7141af859da79f263805573252dbed0988c9022b24ee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page