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 hashes)

Uploaded Source

Built Distribution

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