@jcm/nexus-plugin-datetime
Advanced tools
Comparing version
@@ -6,2 +6,6 @@ # Change Log | ||
## [0.0.7](https://github.com/JCMais/nexus-plugins/compare/@jcm/nexus-plugin-datetime@0.0.6...@jcm/nexus-plugin-datetime@0.0.7) (2020-08-05) | ||
**Note:** Version bump only for package @jcm/nexus-plugin-datetime | ||
## [0.0.6](https://github.com/JCMais/nexus-plugins/compare/@jcm/nexus-plugin-datetime@0.0.5...@jcm/nexus-plugin-datetime@0.0.6) (2020-07-31) | ||
@@ -8,0 +12,0 @@ |
{ | ||
"name": "@jcm/nexus-plugin-datetime", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Creates t.dateTime field", | ||
@@ -51,3 +51,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "34b519a9027b24a4c954356dc2a8f95021b7403e" | ||
"gitHead": "67a6c111f6ebbd496ffe5c463c3e3deb11d079a1" | ||
} |
150
README.md
@@ -1,1 +0,149 @@ | ||
# @jcm/nexus-plugin-datetime | ||
# @jcm/nexus-plugin-datetime<!-- omit in toc --> | ||
<p align="center"> | ||
<a href="https://www.patreon.com/bePatron?u=19985213" data-patreon-widget-type="become-patron-button" title="Become a Patreon"> | ||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="190" alt="Patreon Logo"> | ||
</a> | ||
<br> | ||
<a href="https://discord.io/jonathancardoso" title="Join our Discord Server"> | ||
<img src="https://i.imgur.com/DlKeNmn.png" alt="Discord Logo" width="190" /> | ||
</a> | ||
</p> | ||
This plugin adds the field method `dateTime(fieldName, fieldConfig)` to the Nexus Schema Builder, which can be used to create date-time fields with a few helpful methods. | ||
Sample usage: | ||
```typescript | ||
const User = objectType({ | ||
name: 'User', | ||
definition(t) { | ||
// ... | ||
t.dateTime('createdAt') | ||
// ... | ||
}, | ||
}) | ||
``` | ||
With the above code, the following schema will be generated: | ||
```graphql | ||
""" | ||
Represents an ISO datetime that can be formatted in other formats | ||
""" | ||
type DateTimeField implements DateTimeFieldInterface { | ||
formatted( | ||
format: String! | ||
""" | ||
Timezone to format the ISO date, defaults to UTC | ||
""" | ||
timezone: String | ||
): String! | ||
isAfter( | ||
""" | ||
Defaults to the current time if not provided | ||
""" | ||
iso: String | ||
): Boolean! | ||
isBefore( | ||
""" | ||
Defaults to the current time if not provided | ||
""" | ||
iso: String | ||
): Boolean! | ||
isBetween( | ||
""" | ||
Defaults to the end of the current day if not provided | ||
""" | ||
isoEnd: String | ||
""" | ||
Defaults to the start of the current day if not provided | ||
""" | ||
isoStart: String | ||
): Boolean! | ||
iso: String! | ||
isSame( | ||
""" | ||
Defaults to the current time if not provided | ||
""" | ||
iso: String | ||
): Boolean! | ||
isSameOrAfter( | ||
""" | ||
Defaults to the current time if not provided | ||
""" | ||
iso: String | ||
): Boolean! | ||
isSameOrBefore( | ||
""" | ||
Defaults to the current time if not provided | ||
""" | ||
iso: String | ||
): Boolean! | ||
} | ||
""" | ||
A object that represents an ISO datetime | ||
""" | ||
interface DateTimeFieldInterface { | ||
formatted( | ||
format: String! | ||
""" | ||
Timezone to format the ISO date, defaults to UTC | ||
""" | ||
timezone: String | ||
): String! | ||
isAfter( | ||
""" | ||
Defaults to the current time if not provided | ||
""" | ||
iso: String | ||
): Boolean! | ||
isBefore( | ||
""" | ||
Defaults to the current time if not provided | ||
""" | ||
iso: String | ||
): Boolean! | ||
isBetween( | ||
""" | ||
Defaults to the end of the current day if not provided | ||
""" | ||
isoEnd: String | ||
""" | ||
Defaults to the start of the current day if not provided | ||
""" | ||
isoStart: String | ||
): Boolean! | ||
iso: String! | ||
isSame( | ||
""" | ||
Defaults to the current time if not provided | ||
""" | ||
iso: String | ||
): Boolean! | ||
isSameOrAfter( | ||
""" | ||
Defaults to the current time if not provided | ||
""" | ||
iso: String | ||
): Boolean! | ||
isSameOrBefore( | ||
""" | ||
Defaults to the current time if not provided | ||
""" | ||
iso: String | ||
): Boolean! | ||
} | ||
type User { | ||
# ... | ||
createdAt: DateTimeField! | ||
} | ||
# ... | ||
``` |
38841
8.9%150
7400%