Updated book for master ***NO_CI***
This commit is contained in:
parent
38e6750474
commit
aae0f65168
5 changed files with 30 additions and 20 deletions
|
@ -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<'static, Query, EmptyMutation<Context>>;
|
||||
type Schema = juniper::RootNode<
|
||||
'static,
|
||||
Query,
|
||||
EmptyMutation<Context>,
|
||||
EmptySubscription<Context>
|
||||
>;
|
||||
|
||||
fn main() {
|
||||
// Create a context object.
|
||||
|
@ -190,7 +195,7 @@ fn main() {
|
|||
|
||||
// Run the built-in introspection query.
|
||||
let (res, _errors) = juniper::introspect(
|
||||
&Schema::new(Query, EmptyMutation::new()),
|
||||
&Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()),
|
||||
&ctx,
|
||||
IntrospectionFormat::default(),
|
||||
).unwrap();
|
||||
|
|
|
@ -197,7 +197,7 @@ naturally map to GraphQL features, such as <code>Option<T></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<'static, Query, Mutation>;
|
||||
type Schema = juniper::RootNode<'static, Query, Mutation, EmptySubscription<Context>>;
|
||||
|
||||
# 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<'static, Query, Mutation>;
|
|||
<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<'static, Query, EmptyMutation<Ctx>>;
|
||||
type Schema = juniper::RootNode<'static, Query, EmptyMutation<Ctx>, EmptySubscription<Ctx>>;
|
||||
|
||||
fn main() {
|
||||
// Create a context object.
|
||||
|
@ -344,7 +344,7 @@ fn main() {
|
|||
let (res, _errors) = juniper::execute_sync(
|
||||
"query { favoriteEpisode }",
|
||||
None,
|
||||
&Schema::new(Query, EmptyMutation::new()),
|
||||
&Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()),
|
||||
&Variables::new(),
|
||||
&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<'static, Query, EmptyMutation<Context>>;
|
||||
type Schema = juniper::RootNode<
|
||||
'static,
|
||||
Query,
|
||||
EmptyMutation<Context>,
|
||||
EmptySubscription<Context>
|
||||
>;
|
||||
|
||||
fn main() {
|
||||
// Create a context object.
|
||||
|
@ -1782,7 +1787,7 @@ fn main() {
|
|||
|
||||
// Run the built-in introspection query.
|
||||
let (res, _errors) = juniper::introspect(
|
||||
&Schema::new(Query, EmptyMutation::new()),
|
||||
&Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()),
|
||||
&ctx,
|
||||
IntrospectionFormat::default(),
|
||||
).unwrap();
|
||||
|
|
|
@ -152,7 +152,7 @@ naturally map to GraphQL features, such as <code>Option<T></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<'static, Query, Mutation>;
|
||||
type Schema = juniper::RootNode<'static, Query, Mutation, EmptySubscription<Context>>;
|
||||
|
||||
# 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<'static, Query, Mutation>;
|
|||
<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<'static, Query, EmptyMutation<Ctx>>;
|
||||
type Schema = juniper::RootNode<'static, Query, EmptyMutation<Ctx>, EmptySubscription<Ctx>>;
|
||||
|
||||
fn main() {
|
||||
// Create a context object.
|
||||
|
@ -299,7 +299,7 @@ fn main() {
|
|||
let (res, _errors) = juniper::execute_sync(
|
||||
"query { favoriteEpisode }",
|
||||
None,
|
||||
&Schema::new(Query, EmptyMutation::new()),
|
||||
&Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()),
|
||||
&Variables::new(),
|
||||
&ctx,
|
||||
).unwrap();
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue