Updated book for master ***NO_CI***

This commit is contained in:
Juniper Bot 2019-05-17 17:34:11 +00:00
parent ecbe1a730a
commit b998cea2b9
4 changed files with 20 additions and 8 deletions

View file

@ -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

View file

@ -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 = &lt;S&gt; {
description: &quot;An opaque identifier, represented as a string&quot;
resolve(&amp;self) -&gt; Value {
@ -163,11 +163,17 @@ juniper::graphql_scalar!(UserID {
v.as_scalar_value::&lt;String&gt;().map(|s| UserID(s.to_owned()))
}
from_str&lt;'a&gt;(value: ScalarToken&lt;'a&gt;) -&gt; juniper::ParseScalarResult&lt;'a, juniper::DefaultScalarValue&gt; {
&lt;String as juniper::ParseScalarValue&gt;::from_str(value)
from_str&lt;'a&gt;(value: ScalarToken&lt;'a&gt;) -&gt; juniper::ParseScalarResult&lt;'a, S&gt; {
&lt;String as juniper::ParseScalarValue&lt;S&gt;&gt;::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>