Updated book for master ***NO_CI***
This commit is contained in:
parent
ecbe1a730a
commit
b998cea2b9
4 changed files with 20 additions and 8 deletions
|
@ -1209,7 +1209,7 @@ this example, we're representing a user ID as a string wrapped in a custom type:
|
|||
|
||||
struct UserID(String);
|
||||
|
||||
juniper::graphql_scalar!(UserID {
|
||||
juniper::graphql_scalar!(UserID where Scalar = <S> {
|
||||
description: "An opaque identifier, represented as a string"
|
||||
|
||||
resolve(&self) -> Value {
|
||||
|
@ -1222,11 +1222,17 @@ juniper::graphql_scalar!(UserID {
|
|||
v.as_scalar_value::<String>().map(|s| UserID(s.to_owned()))
|
||||
}
|
||||
|
||||
from_str<'a>(value: ScalarToken<'a>) -> juniper::ParseScalarResult<'a, juniper::DefaultScalarValue> {
|
||||
<String as juniper::ParseScalarValue>::from_str(value)
|
||||
from_str<'a>(value: ScalarToken<'a>) -> juniper::ParseScalarResult<'a, S> {
|
||||
<String as juniper::ParseScalarValue<S>>::from_str(value)
|
||||
}
|
||||
});
|
||||
|
||||
#[derive(juniper::GraphQLObject)]
|
||||
struct User {
|
||||
id: UserID,
|
||||
username: String,
|
||||
}
|
||||
|
||||
# fn main() {}
|
||||
</code></pre></pre>
|
||||
<a class="header" href="#built-in-scalars" id="built-in-scalars"><h2>Built-in scalars</h2></a>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -150,7 +150,7 @@ this example, we're representing a user ID as a string wrapped in a custom type:
|
|||
|
||||
struct UserID(String);
|
||||
|
||||
juniper::graphql_scalar!(UserID {
|
||||
juniper::graphql_scalar!(UserID where Scalar = <S> {
|
||||
description: "An opaque identifier, represented as a string"
|
||||
|
||||
resolve(&self) -> Value {
|
||||
|
@ -163,11 +163,17 @@ juniper::graphql_scalar!(UserID {
|
|||
v.as_scalar_value::<String>().map(|s| UserID(s.to_owned()))
|
||||
}
|
||||
|
||||
from_str<'a>(value: ScalarToken<'a>) -> juniper::ParseScalarResult<'a, juniper::DefaultScalarValue> {
|
||||
<String as juniper::ParseScalarValue>::from_str(value)
|
||||
from_str<'a>(value: ScalarToken<'a>) -> juniper::ParseScalarResult<'a, S> {
|
||||
<String as juniper::ParseScalarValue<S>>::from_str(value)
|
||||
}
|
||||
});
|
||||
|
||||
#[derive(juniper::GraphQLObject)]
|
||||
struct User {
|
||||
id: UserID,
|
||||
username: String,
|
||||
}
|
||||
|
||||
# fn main() {}
|
||||
</code></pre></pre>
|
||||
<a class="header" href="#built-in-scalars" id="built-in-scalars"><h2>Built-in scalars</h2></a>
|
||||
|
|
Loading…
Reference in a new issue