Merge pull request #640 from Miaxos/misc-add-documentation-for-uuid

misc: add documentations for naive_time url and uuid
This commit is contained in:
Sunli 2021-09-21 22:04:10 +08:00 committed by GitHub
commit 5d03592d98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 0 deletions

View File

@ -3,6 +3,13 @@ use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
#[Scalar(internal)]
/// ISO 8601 calendar date without timezone.
/// Format: %Y-%m-%d
///
/// # Examples
///
/// * `1994-11-13`
/// * `2000-02-24`
impl ScalarType for NaiveDate {
fn parse(value: Value) -> InputValueResult<Self> {
match value {
@ -17,6 +24,13 @@ impl ScalarType for NaiveDate {
}
#[Scalar(internal)]
/// ISO 8601 time without timezone.
/// Allows for the nanosecond precision and optional leap second representation.
/// Format: %H:%M:%S%.f
///
/// # Examples
///
/// * `08:59:60.123`
impl ScalarType for NaiveTime {
fn parse(value: Value) -> InputValueResult<Self> {
match value {
@ -31,6 +45,11 @@ impl ScalarType for NaiveTime {
}
#[Scalar(internal)]
/// ISO 8601 combined date and time without timezone.
///
/// # Examples
///
/// * `2015-07-01T08:59:60.123`,
impl ScalarType for NaiveDateTime {
fn parse(value: Value) -> InputValueResult<Self> {
match value {

View File

@ -3,6 +3,7 @@ use url::Url;
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
#[Scalar(internal)]
/// URL is a String implementing the [URL Standard](http://url.spec.whatwg.org/)
impl ScalarType for Url {
fn parse(value: Value) -> InputValueResult<Self> {
match value {

View File

@ -3,6 +3,14 @@ use uuid::Uuid;
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
#[Scalar(internal, name = "UUID")]
/// A UUID is a unique 128-bit number, stored as 16 octets. UUIDs are parsed as Strings
/// within GraphQL. UUIDs are used to assign unique identifiers to entities without requiring a central
/// allocating authority.
///
/// # References
///
/// * [Wikipedia: Universally Unique Identifier](http://en.wikipedia.org/wiki/Universally_unique_identifier)
/// * [RFC4122: A Universally Unique IDentifier (UUID) URN Namespace](http://tools.ietf.org/html/rfc4122)
impl ScalarType for Uuid {
fn parse(value: Value) -> InputValueResult<Self> {
match value {