Add specified_by_url for Tz & DateTime<Tz> & Url & Uuid scalars

This commit is contained in:
Sunli 2021-10-29 14:06:46 +08:00
parent 057d6aebfd
commit fa6b7964c4
4 changed files with 26 additions and 6 deletions

View File

@ -2,7 +2,11 @@ use chrono_tz::Tz;
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
#[Scalar(internal, name = "TimeZone")]
#[Scalar(
internal,
name = "TimeZone",
specified_by_url = "http://www.iana.org/time-zones"
)]
impl ScalarType for Tz {
fn parse(value: Value) -> InputValueResult<Self> {
match value {

View File

@ -5,7 +5,11 @@ use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
/// Implement the DateTime<FixedOffset> scalar
///
/// The input/output is a string in RFC3339 format.
#[Scalar(internal, name = "DateTime")]
#[Scalar(
internal,
name = "DateTime",
specified_by_url = "https://datatracker.ietf.org/doc/html/rfc3339"
)]
impl ScalarType for DateTime<FixedOffset> {
fn parse(value: Value) -> InputValueResult<Self> {
match &value {
@ -22,7 +26,11 @@ impl ScalarType for DateTime<FixedOffset> {
/// Implement the DateTime<Local> scalar
///
/// The input/output is a string in RFC3339 format.
#[Scalar(internal, name = "DateTime")]
#[Scalar(
internal,
name = "DateTime",
specified_by_url = "https://datatracker.ietf.org/doc/html/rfc3339"
)]
impl ScalarType for DateTime<Local> {
fn parse(value: Value) -> InputValueResult<Self> {
match &value {
@ -39,7 +47,11 @@ impl ScalarType for DateTime<Local> {
/// Implement the DateTime<Utc> scalar
///
/// The input/output is a string in RFC3339 format.
#[Scalar(internal, name = "DateTime")]
#[Scalar(
internal,
name = "DateTime",
specified_by_url = "https://datatracker.ietf.org/doc/html/rfc3339"
)]
impl ScalarType for DateTime<Utc> {
fn parse(value: Value) -> InputValueResult<Self> {
match &value {

View File

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

View File

@ -2,7 +2,11 @@ use uuid::Uuid;
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
#[Scalar(internal, name = "UUID")]
#[Scalar(
internal,
name = "UUID",
specified_by_url = "http://tools.ietf.org/html/rfc4122"
)]
/// 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.