Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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.

Files for tartiflette-plugin-isodatenow, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size tartiflette_plugin_isodatenow-0.2.2-py3-none-any.whl (4.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size tartiflette-plugin-isodatenow-0.2.2.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page