Updated book for master ***NO_CI***

This commit is contained in:
Juniper Bot 2020-03-19 03:40:03 +00:00
parent 38e6750474
commit aae0f65168
5 changed files with 30 additions and 20 deletions

View file

@ -159,7 +159,7 @@ produced by issuing a specially crafted introspection query.</p>
<p>Juniper provides a convenience function to introspect the entire schema. The
result can then be converted to JSON for use with tools and libraries such as
<a href="https://github.com/graphql-rust/graphql-client">graphql-client</a>:</p>
<pre><pre class="playpen"><code class="language-rust">use juniper::{EmptyMutation, FieldResult, IntrospectionFormat};
<pre><pre class="playpen"><code class="language-rust">use juniper::{EmptyMutation, EmptySubscription, FieldResult, IntrospectionFormat};
// Define our schema.
@ -182,7 +182,12 @@ impl Query {
}
}
type Schema = juniper::RootNode&lt;'static, Query, EmptyMutation&lt;Context&gt;&gt;;
type Schema = juniper::RootNode&lt;
'static,
Query,
EmptyMutation&lt;Context&gt;,
EmptySubscription&lt;Context&gt;
&gt;;
fn main() {
// Create a context object.
@ -190,7 +195,7 @@ fn main() {
// Run the built-in introspection query.
let (res, _errors) = juniper::introspect(
&amp;Schema::new(Query, EmptyMutation::new()),
&amp;Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()),
&amp;ctx,
IntrospectionFormat::default(),
).unwrap();

View file

@ -197,7 +197,7 @@ naturally map to GraphQL features, such as <code>Option&lt;T&gt;</code>, <code>V
types to a GraphQL schema. The most important one is the
[object][jp_object] procedural macro that is used for declaring an object with
resolvers, which you will use for the <code>Query</code> and <code>Mutation</code> roots.</p>
<pre><pre class="playpen"><code class="language-rust">use juniper::{FieldResult};
<pre><pre class="playpen"><code class="language-rust">use juniper::{FieldResult, EmptySubscription};
# struct DatabasePool;
# impl DatabasePool {
@ -292,10 +292,10 @@ impl Mutation {
// A root schema consists of a query and a mutation.
// Request queries can be executed against a RootNode.
type Schema = juniper::RootNode&lt;'static, Query, Mutation&gt;;
type Schema = juniper::RootNode&lt;'static, Query, Mutation, EmptySubscription&lt;Context&gt;&gt;;
# fn main() {
# let _ = Schema::new(Query, Mutation{});
# let _ = Schema::new(Query, Mutation{}, EmptySubscription::new());
# }
</code></pre></pre>
<p>We now have a very simple but functional schema for a GraphQL server!</p>
@ -305,7 +305,7 @@ type Schema = juniper::RootNode&lt;'static, Query, Mutation&gt;;
<p>You can invoke <code>juniper::execute</code> directly to run a GraphQL query:</p>
<pre><pre class="playpen"><code class="language-rust"># // Only needed due to 2018 edition because the macro is not accessible.
# #[macro_use] extern crate juniper;
use juniper::{FieldResult, Variables, EmptyMutation};
use juniper::{FieldResult, Variables, EmptyMutation, EmptySubscription};
#[derive(juniper::GraphQLEnum, Clone, Copy)]
@ -334,7 +334,7 @@ impl Query {
// A root schema consists of a query and a mutation.
// Request queries can be executed against a RootNode.
type Schema = juniper::RootNode&lt;'static, Query, EmptyMutation&lt;Ctx&gt;&gt;;
type Schema = juniper::RootNode&lt;'static, Query, EmptyMutation&lt;Ctx&gt;, EmptySubscription&lt;Ctx&gt;&gt;;
fn main() {
// Create a context object.
@ -344,7 +344,7 @@ fn main() {
let (res, _errors) = juniper::execute_sync(
&quot;query { favoriteEpisode }&quot;,
None,
&amp;Schema::new(Query, EmptyMutation::new()),
&amp;Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()),
&amp;Variables::new(),
&amp;ctx,
).unwrap();
@ -1751,7 +1751,7 @@ produced by issuing a specially crafted introspection query.</p>
<p>Juniper provides a convenience function to introspect the entire schema. The
result can then be converted to JSON for use with tools and libraries such as
<a href="https://github.com/graphql-rust/graphql-client">graphql-client</a>:</p>
<pre><pre class="playpen"><code class="language-rust">use juniper::{EmptyMutation, FieldResult, IntrospectionFormat};
<pre><pre class="playpen"><code class="language-rust">use juniper::{EmptyMutation, EmptySubscription, FieldResult, IntrospectionFormat};
// Define our schema.
@ -1774,7 +1774,12 @@ impl Query {
}
}
type Schema = juniper::RootNode&lt;'static, Query, EmptyMutation&lt;Context&gt;&gt;;
type Schema = juniper::RootNode&lt;
'static,
Query,
EmptyMutation&lt;Context&gt;,
EmptySubscription&lt;Context&gt;
&gt;;
fn main() {
// Create a context object.
@ -1782,7 +1787,7 @@ fn main() {
// Run the built-in introspection query.
let (res, _errors) = juniper::introspect(
&amp;Schema::new(Query, EmptyMutation::new()),
&amp;Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()),
&amp;ctx,
IntrospectionFormat::default(),
).unwrap();

View file

@ -152,7 +152,7 @@ naturally map to GraphQL features, such as <code>Option&lt;T&gt;</code>, <code>V
types to a GraphQL schema. The most important one is the
[object][jp_object] procedural macro that is used for declaring an object with
resolvers, which you will use for the <code>Query</code> and <code>Mutation</code> roots.</p>
<pre><pre class="playpen"><code class="language-rust">use juniper::{FieldResult};
<pre><pre class="playpen"><code class="language-rust">use juniper::{FieldResult, EmptySubscription};
# struct DatabasePool;
# impl DatabasePool {
@ -247,10 +247,10 @@ impl Mutation {
// A root schema consists of a query and a mutation.
// Request queries can be executed against a RootNode.
type Schema = juniper::RootNode&lt;'static, Query, Mutation&gt;;
type Schema = juniper::RootNode&lt;'static, Query, Mutation, EmptySubscription&lt;Context&gt;&gt;;
# fn main() {
# let _ = Schema::new(Query, Mutation{});
# let _ = Schema::new(Query, Mutation{}, EmptySubscription::new());
# }
</code></pre></pre>
<p>We now have a very simple but functional schema for a GraphQL server!</p>
@ -260,7 +260,7 @@ type Schema = juniper::RootNode&lt;'static, Query, Mutation&gt;;
<p>You can invoke <code>juniper::execute</code> directly to run a GraphQL query:</p>
<pre><pre class="playpen"><code class="language-rust"># // Only needed due to 2018 edition because the macro is not accessible.
# #[macro_use] extern crate juniper;
use juniper::{FieldResult, Variables, EmptyMutation};
use juniper::{FieldResult, Variables, EmptyMutation, EmptySubscription};
#[derive(juniper::GraphQLEnum, Clone, Copy)]
@ -289,7 +289,7 @@ impl Query {
// A root schema consists of a query and a mutation.
// Request queries can be executed against a RootNode.
type Schema = juniper::RootNode&lt;'static, Query, EmptyMutation&lt;Ctx&gt;&gt;;
type Schema = juniper::RootNode&lt;'static, Query, EmptyMutation&lt;Ctx&gt;, EmptySubscription&lt;Ctx&gt;&gt;;
fn main() {
// Create a context object.
@ -299,7 +299,7 @@ fn main() {
let (res, _errors) = juniper::execute_sync(
&quot;query { favoriteEpisode }&quot;,
None,
&amp;Schema::new(Query, EmptyMutation::new()),
&amp;Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()),
&amp;Variables::new(),
&amp;ctx,
).unwrap();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long