Co-authored-by: Kai Ren <tyranron@gmail.com>
This commit is contained in:
parent
927e42201a
commit
a32140cd46
71 changed files with 286 additions and 286 deletions
|
@ -47,7 +47,7 @@ see the [actix][actix_examples], [hyper][hyper_examples], [rocket][rocket_exampl
|
|||
## Features
|
||||
|
||||
Juniper supports the full GraphQL query language according to the
|
||||
[specification][graphql_spec], including interfaces, unions, schema
|
||||
[specification (October 2021)][graphql_spec], including interfaces, unions, schema
|
||||
introspection, and validations. It can also output the schema in the [GraphQL Schema Language][schema_language].
|
||||
|
||||
As an exception to other GraphQL libraries for other languages, Juniper builds
|
||||
|
@ -97,7 +97,7 @@ Juniper has not reached 1.0 yet, thus some API instability should be expected.
|
|||
[graphiql]: https://github.com/graphql/graphiql
|
||||
[playground]: https://github.com/prisma/graphql-playground
|
||||
[iron]: https://github.com/iron/iron
|
||||
[graphql_spec]: http://facebook.github.io/graphql
|
||||
[graphql_spec]: https://spec.graphql.org/October2021
|
||||
[schema_language]: https://graphql.org/learn/schema/#type-language
|
||||
[schema_approach]: https://blog.logrocket.com/code-first-vs-schema-first-development-graphql/
|
||||
[test_schema_rs]: https://github.com/graphql-rust/juniper/blob/master/juniper/src/tests/fixtures/starwars/schema.rs
|
||||
|
|
|
@ -21,7 +21,7 @@ embedded [Graphiql][graphiql] for easy debugging.
|
|||
## Features
|
||||
|
||||
Juniper supports the full GraphQL query language according to the
|
||||
[specification][graphql_spec], including interfaces, unions, schema
|
||||
[specification (October 2021)][graphql_spec], including interfaces, unions, schema
|
||||
introspection, and validations.
|
||||
It does not, however, support the schema language.
|
||||
|
||||
|
@ -57,7 +57,7 @@ Juniper has not reached 1.0 yet, thus some API instability should be expected.
|
|||
[graphql]: http://graphql.org
|
||||
[graphiql]: https://github.com/graphql/graphiql
|
||||
[iron]: https://github.com/iron/iron
|
||||
[graphql_spec]: http://facebook.github.io/graphql
|
||||
[graphql_spec]: https://spec.graphql.org/October2021
|
||||
[test_schema_rs]: https://github.com/graphql-rust/juniper/blob/master/juniper/src/tests/schema.rs
|
||||
[tokio]: https://github.com/tokio-rs/tokio
|
||||
[hyper_examples]: https://github.com/graphql-rust/juniper/tree/master/juniper_hyper/examples
|
||||
|
|
|
@ -473,9 +473,9 @@ struct Droid {
|
|||
|
||||
|
||||
|
||||
[1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
[1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
[2]: https://doc.rust-lang.org/reference/types/trait-object.html
|
||||
[3]: https://docs.rs/juniper/latest/juniper/trait.ScalarValue.html
|
||||
[4]: https://docs.rs/juniper/latest/juniper/struct.Executor.html
|
||||
[5]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
[5]: https://spec.graphql.org/October2021#sec-Objects
|
||||
[6]: https://docs.rs/juniper/0.14.2/juniper/trait.Context.html
|
||||
|
|
|
@ -60,7 +60,7 @@ there - those errors are automatically converted into `FieldError`.
|
|||
|
||||
## Error payloads, `null`, and partial errors
|
||||
|
||||
Juniper's error behavior conforms to the [GraphQL specification](https://spec.graphql.org/June2018/#sec-Errors-and-Non-Nullability).
|
||||
Juniper's error behavior conforms to the [GraphQL specification](https://spec.graphql.org/October2021#sec-Handling-Field-Errors).
|
||||
|
||||
When a field returns an error, the field's result is replaced by `null`, an
|
||||
additional `errors` object is created at the top level of the response, and the
|
||||
|
@ -168,7 +168,7 @@ impl Example {
|
|||
# fn main() {}
|
||||
```
|
||||
|
||||
The specified structured error information is included in the [`extensions`](https://facebook.github.io/graphql/June2018/#sec-Errors) key:
|
||||
The specified structured error information is included in the [`extensions`](https://spec.graphql.org/October2021#sec-Errors) key:
|
||||
|
||||
```json
|
||||
{
|
||||
|
|
|
@ -24,10 +24,10 @@ Juniper has built-in support for:
|
|||
* `String` and `&str` as `String`
|
||||
* `bool` as `Boolean`
|
||||
* `juniper::ID` as `ID`. This type is defined [in the
|
||||
spec](http://facebook.github.io/graphql/#sec-ID) as a type that is serialized
|
||||
spec](https://spec.graphql.org/October2021#sec-ID) as a type that is serialized
|
||||
as a string but can be parsed from both a string and an integer.
|
||||
|
||||
Note that there is no built-in support for `i64`/`u64`, as the GraphQL spec [doesn't define any built-in scalars for `i64`/`u64` by default](https://spec.graphql.org/June2018/#sec-Int). You may wish to leverage a [custom GraphQL scalar](#custom-scalars) in your schema to support them.
|
||||
Note that there is no built-in support for `i64`/`u64`, as the GraphQL spec [doesn't define any built-in scalars for `i64`/`u64` by default](https://spec.graphql.org/October2021#sec-Int). You may wish to leverage a [custom GraphQL scalar](#custom-scalars) in your schema to support them.
|
||||
|
||||
**Third party types**:
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ impl Character {
|
|||
# fn main() {}
|
||||
```
|
||||
|
||||
With an external resolver function we can even declare a new [GraphQL union][1] variant where the Rust type is absent in the initial enum definition. The attribute syntax `#[graphql(on VariantType = resolver_fn)]` follows the [GraphQL syntax for dispatching union variants](https://spec.graphql.org/June2018/#example-f8163).
|
||||
With an external resolver function we can even declare a new [GraphQL union][1] variant where the Rust type is absent in the initial enum definition. The attribute syntax `#[graphql(on VariantType = resolver_fn)]` follows the [GraphQL syntax for dispatching union variants](https://spec.graphql.org/October2021#example-f8163).
|
||||
|
||||
```rust
|
||||
# #![allow(dead_code)]
|
||||
|
@ -485,7 +485,7 @@ enum Character {
|
|||
|
||||
|
||||
|
||||
[1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
[1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
[2]: https://docs.rs/juniper/latest/juniper/trait.ScalarValue.html
|
||||
[5]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
[5]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
[6]: https://docs.rs/juniper/0.14.2/juniper/trait.Context.html
|
||||
|
|
|
@ -405,7 +405,7 @@ impl<'a, S> MetaType<'a, S> {
|
|||
// "used exclusively by GraphQL’s introspection system"
|
||||
{
|
||||
name.starts_with("__") ||
|
||||
// <https://facebook.github.io/graphql/draft/#sec-Scalars>
|
||||
// https://spec.graphql.org/October2021#sec-Scalars
|
||||
name == "Boolean" || name == "String" || name == "Int" || name == "Float" || name == "ID" ||
|
||||
// Our custom empty markers
|
||||
name == "_EmptyMutation" || name == "_EmptySubscription"
|
||||
|
|
|
@ -298,9 +298,9 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
// Right now the only directive supported is `@deprecated`. `@skip` and `@include`
|
||||
// are dealt with elsewhere.
|
||||
// <https://facebook.github.io/graphql/draft/#sec-Type-System.Directives>
|
||||
// Right now the only directive supported is `@deprecated`.
|
||||
// `@skip` and `@include` are dealt with elsewhere.
|
||||
// https://spec.graphql.org/October2021#sec-Type-System.Directives.Built-in-Directives
|
||||
fn generate_directives<'a, T>(status: &DeprecationStatus) -> Vec<ExternalDirective<'a, T>>
|
||||
where
|
||||
T: Text<'a>,
|
||||
|
|
|
@ -30,7 +30,7 @@ where
|
|||
///
|
||||
/// The default implementation panics.
|
||||
///
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Objects
|
||||
fn resolve_field_async<'a>(
|
||||
&'a self,
|
||||
_info: &'a Self::TypeInfo,
|
||||
|
@ -54,9 +54,9 @@ where
|
|||
///
|
||||
/// The default implementation panics.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Unions
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Objects
|
||||
fn resolve_into_type_async<'a>(
|
||||
&'a self,
|
||||
info: &'a Self::TypeInfo,
|
||||
|
@ -91,8 +91,8 @@ where
|
|||
///
|
||||
/// The default implementation panics, if `selection_set` is [`None`].
|
||||
///
|
||||
/// [0]: https://spec.graphql.org/June2018/#sec-Errors-and-Non-Nullability
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [0]: https://spec.graphql.org/October2021#sec-Handling-Field-Errors
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Objects
|
||||
fn resolve_async<'a>(
|
||||
&'a self,
|
||||
info: &'a Self::TypeInfo,
|
||||
|
|
|
@ -150,14 +150,14 @@ impl<'a, S> Arguments<'a, S> {
|
|||
/// This trait is intended to be used in a conjunction with a [`GraphQLType`] trait. See the example
|
||||
/// in the documentation of a [`GraphQLType`] trait.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [4]: https://spec.graphql.org/June2018/#sec-Scalars
|
||||
/// [5]: https://spec.graphql.org/June2018/#sec-Enums
|
||||
/// [6]: https://spec.graphql.org/June2018/#sec-Type-System.List
|
||||
/// [7]: https://spec.graphql.org/June2018/#sec-Type-System.Non-Null
|
||||
/// [8]: https://spec.graphql.org/June2018/#sec-Input-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Unions
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Objects
|
||||
/// [4]: https://spec.graphql.org/October2021#sec-Scalars
|
||||
/// [5]: https://spec.graphql.org/October2021#sec-Enums
|
||||
/// [6]: https://spec.graphql.org/October2021#sec-List
|
||||
/// [7]: https://spec.graphql.org/October2021#sec-Non-Null
|
||||
/// [8]: https://spec.graphql.org/October2021#sec-Input-Objects
|
||||
/// [11]: https://doc.rust-lang.org/reference/items/traits.html#object-safety
|
||||
/// [12]: https://doc.rust-lang.org/reference/types/trait-object.html
|
||||
pub trait GraphQLValue<S = DefaultScalarValue>
|
||||
|
@ -196,7 +196,7 @@ where
|
|||
///
|
||||
/// The default implementation panics.
|
||||
///
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Objects
|
||||
fn resolve_field(
|
||||
&self,
|
||||
_info: &Self::TypeInfo,
|
||||
|
@ -217,9 +217,9 @@ where
|
|||
///
|
||||
/// The default implementation panics.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Unions
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Objects
|
||||
fn resolve_into_type(
|
||||
&self,
|
||||
info: &Self::TypeInfo,
|
||||
|
@ -243,9 +243,9 @@ where
|
|||
///
|
||||
/// The default implementation panics.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Unions
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[allow(unused_variables)]
|
||||
fn concrete_type_name(&self, context: &Self::Context, info: &Self::TypeInfo) -> String {
|
||||
panic!(
|
||||
|
@ -271,8 +271,8 @@ where
|
|||
///
|
||||
/// The default implementation panics, if `selection_set` is [`None`].
|
||||
///
|
||||
/// [0]: https://spec.graphql.org/June2018/#sec-Errors-and-Non-Nullability
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [0]: https://spec.graphql.org/October2021#sec-Errors-and-Non-Nullability
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Objects
|
||||
fn resolve(
|
||||
&self,
|
||||
info: &Self::TypeInfo,
|
||||
|
@ -385,7 +385,7 @@ where
|
|||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub trait GraphQLType<S = DefaultScalarValue>: GraphQLValue<S>
|
||||
where
|
||||
S: ScalarValue,
|
||||
|
|
|
@ -17,19 +17,19 @@ use crate::{GraphQLType, ScalarValue};
|
|||
/// [GraphQL objects][1]. Other types ([scalars][2], [enums][3], [interfaces][4], [input objects][5]
|
||||
/// and [unions][6]) are not allowed.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Scalars
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Enums
|
||||
/// [4]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [5]: https://spec.graphql.org/June2018/#sec-Input-Objects
|
||||
/// [6]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Scalars
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Enums
|
||||
/// [4]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
/// [5]: https://spec.graphql.org/October2021#sec-Input-Objects
|
||||
/// [6]: https://spec.graphql.org/October2021#sec-Unions
|
||||
pub trait GraphQLObject<S: ScalarValue>: GraphQLType<S> {
|
||||
/// An arbitrary function without meaning.
|
||||
///
|
||||
/// May contain compile timed check logic which ensures that types are used correctly according
|
||||
/// to the [GraphQL specification][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/
|
||||
/// [1]: https://spec.graphql.org/October2021
|
||||
fn mark() {}
|
||||
}
|
||||
|
||||
|
@ -74,19 +74,19 @@ where
|
|||
/// [GraphQL interfaces][1]. Other types ([scalars][2], [enums][3], [objects][4], [input objects][5]
|
||||
/// and [unions][6]) are not allowed.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Scalars
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Enums
|
||||
/// [4]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [5]: https://spec.graphql.org/June2018/#sec-Input-Objects
|
||||
/// [6]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Scalars
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Enums
|
||||
/// [4]: https://spec.graphql.org/October2021#sec-Objects
|
||||
/// [5]: https://spec.graphql.org/October2021#sec-Input-Objects
|
||||
/// [6]: https://spec.graphql.org/October2021#sec-Unions
|
||||
pub trait GraphQLInterface<S: ScalarValue>: GraphQLType<S> {
|
||||
/// An arbitrary function without meaning.
|
||||
///
|
||||
/// May contain compile timed check logic which ensures that types are used correctly according
|
||||
/// to the [GraphQL specification][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/
|
||||
/// [1]: https://spec.graphql.org/October2021
|
||||
fn mark() {}
|
||||
}
|
||||
|
||||
|
@ -131,19 +131,19 @@ where
|
|||
/// [GraphQL unions][1]. Other types ([scalars][2], [enums][3], [objects][4], [input objects][5] and
|
||||
/// [interfaces][6]) are not allowed.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Scalars
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Enums
|
||||
/// [4]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [5]: https://spec.graphql.org/June2018/#sec-Input-Objects
|
||||
/// [6]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Scalars
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Enums
|
||||
/// [4]: https://spec.graphql.org/October2021#sec-Objects
|
||||
/// [5]: https://spec.graphql.org/October2021#sec-Input-Objects
|
||||
/// [6]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
pub trait GraphQLUnion<S: ScalarValue>: GraphQLType<S> {
|
||||
/// An arbitrary function without meaning.
|
||||
///
|
||||
/// May contain compile timed check logic which ensures that types are used correctly according
|
||||
/// to the [GraphQL specification][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/
|
||||
/// [1]: https://spec.graphql.org/October2021
|
||||
fn mark() {}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,8 +94,8 @@ pub trait SubscriptionConnection<S>: futures::Stream<Item = ExecutionOutput<S>>
|
|||
///
|
||||
/// See trait methods for more detailed explanation on how this trait works.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Subscription
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Subscription
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub trait GraphQLSubscriptionValue<S = DefaultScalarValue>: GraphQLValue<S> + Sync
|
||||
where
|
||||
Self::TypeInfo: Sync,
|
||||
|
@ -204,7 +204,7 @@ crate::sa::assert_obj_safe!(GraphQLSubscriptionValue<Context = (), TypeInfo = ()
|
|||
/// It's automatically implemented for [`GraphQLSubscriptionValue`] and [`GraphQLType`]
|
||||
/// implementers, so doesn't require manual or code-generated implementation.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Subscription
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Subscription
|
||||
pub trait GraphQLSubscriptionType<S = DefaultScalarValue>:
|
||||
GraphQLSubscriptionValue<S> + GraphQLType<S>
|
||||
where
|
||||
|
|
|
@ -228,20 +228,20 @@ pub trait ScalarValue:
|
|||
///
|
||||
/// These types closely follow the [GraphQL specification][0].
|
||||
///
|
||||
/// [0]: https://spec.graphql.org/June2018
|
||||
/// [0]: https://spec.graphql.org/October2021
|
||||
#[derive(Clone, Debug, PartialEq, ScalarValue, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum DefaultScalarValue {
|
||||
/// [`Int` scalar][0] as a signed 32‐bit numeric non‐fractional value.
|
||||
///
|
||||
/// [0]: https://spec.graphql.org/June2018/#sec-Int
|
||||
/// [0]: https://spec.graphql.org/October2021#sec-Int
|
||||
#[value(as_float, as_int)]
|
||||
Int(i32),
|
||||
|
||||
/// [`Float` scalar][0] as a signed double‐precision fractional values as
|
||||
/// specified by [IEEE 754].
|
||||
///
|
||||
/// [0]: https://spec.graphql.org/June2018/#sec-Float
|
||||
/// [0]: https://spec.graphql.org/October2021#sec-Float
|
||||
/// [IEEE 754]: https://en.wikipedia.org/wiki/IEEE_floating_point
|
||||
#[value(as_float)]
|
||||
Float(f64),
|
||||
|
@ -249,13 +249,13 @@ pub enum DefaultScalarValue {
|
|||
/// [`String` scalar][0] as a textual data, represented as UTF‐8 character
|
||||
/// sequences.
|
||||
///
|
||||
/// [0]: https://spec.graphql.org/June2018/#sec-String
|
||||
/// [0]: https://spec.graphql.org/October2021#sec-String
|
||||
#[value(as_str, as_string, into_string)]
|
||||
String(String),
|
||||
|
||||
/// [`Boolean` scalar][0] as a `true` or `false` value.
|
||||
///
|
||||
/// [0]: https://spec.graphql.org/June2018/#sec-Boolean
|
||||
/// [0]: https://spec.graphql.org/October2021#sec-Boolean
|
||||
#[value(as_bool)]
|
||||
Boolean(bool),
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Common functions, definitions and extensions for parsing and code generation
|
||||
//! of [GraphQL arguments][1]
|
||||
//!
|
||||
//! [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments.
|
||||
//! [1]: https://spec.graphql.org/October2021#sec-Language.Arguments.
|
||||
|
||||
use std::mem;
|
||||
|
||||
|
@ -29,7 +29,7 @@ use crate::{
|
|||
/// Available metadata (arguments) behind `#[graphql]` attribute placed on a
|
||||
/// method argument, when generating code for [GraphQL argument][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
#[derive(Debug, Default)]
|
||||
pub(crate) struct Attr {
|
||||
/// Explicitly specified name of a [GraphQL argument][1] represented by this
|
||||
|
@ -37,13 +37,13 @@ pub(crate) struct Attr {
|
|||
///
|
||||
/// If [`None`], then `camelCased` Rust argument name is used by default.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
pub(crate) name: Option<SpanContainer<syn::LitStr>>,
|
||||
|
||||
/// Explicitly specified [description][2] of this [GraphQL argument][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Descriptions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Descriptions
|
||||
pub(crate) description: Option<SpanContainer<syn::LitStr>>,
|
||||
|
||||
/// Explicitly specified [default value][2] of this [GraphQL argument][1].
|
||||
|
@ -54,8 +54,8 @@ pub(crate) struct Attr {
|
|||
/// If [`None`], then this [GraphQL argument][1] is considered as
|
||||
/// [required][2].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Required-Arguments
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Required-Arguments
|
||||
pub(crate) default: Option<SpanContainer<Option<syn::Expr>>>,
|
||||
|
||||
/// Explicitly specified marker indicating that this method argument doesn't
|
||||
|
@ -66,8 +66,8 @@ pub(crate) struct Attr {
|
|||
/// if it's named `context` or `ctx`.
|
||||
///
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) context: Option<SpanContainer<syn::Ident>>,
|
||||
|
||||
/// Explicitly specified marker indicating that this method argument doesn't
|
||||
|
@ -78,8 +78,8 @@ pub(crate) struct Attr {
|
|||
/// if it's named `executor`.
|
||||
///
|
||||
/// [`Executor`]: juniper::Executor
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) executor: Option<SpanContainer<syn::Ident>>,
|
||||
}
|
||||
|
||||
|
@ -223,24 +223,24 @@ impl Attr {
|
|||
|
||||
/// Representation of a [GraphQL field argument][1] for code generation.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct OnField {
|
||||
/// Rust type that this [GraphQL field argument][1] is represented by.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
pub(crate) ty: syn::Type,
|
||||
|
||||
/// Name of this [GraphQL field argument][2] in GraphQL schema.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
pub(crate) name: String,
|
||||
|
||||
/// [Description][2] of this [GraphQL field argument][1] to put into GraphQL
|
||||
/// schema.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Descriptions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Descriptions
|
||||
pub(crate) description: Option<String>,
|
||||
|
||||
/// Default value of this [GraphQL field argument][1] in GraphQL schema.
|
||||
|
@ -250,8 +250,8 @@ pub(crate) struct OnField {
|
|||
///
|
||||
/// If inner [`Option`] is [`None`], then the [`Default`] value is used.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Required-Arguments
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Required-Arguments
|
||||
pub(crate) default: Option<Option<syn::Expr>>,
|
||||
}
|
||||
|
||||
|
@ -260,19 +260,19 @@ pub(crate) struct OnField {
|
|||
pub(crate) enum OnMethod {
|
||||
/// Regular [GraphQL field argument][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Arguments
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Arguments
|
||||
Regular(Box<OnField>),
|
||||
|
||||
/// [`Context`] passed into a [GraphQL field][2] resolving method.
|
||||
///
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
Context(Box<syn::Type>),
|
||||
|
||||
/// [`Executor`] passed into a [GraphQL field][2] resolving method.
|
||||
///
|
||||
/// [`Executor`]: juniper::Executor
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
Executor,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Common functions, definitions and extensions for parsing and code generation
|
||||
//! of [GraphQL fields][1]
|
||||
//!
|
||||
//! [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
//! [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
|
||||
pub(crate) mod arg;
|
||||
|
||||
|
@ -30,14 +30,14 @@ pub(crate) use self::arg::OnMethod as MethodArgument;
|
|||
/// Available metadata (arguments) behind `#[graphql]` attribute placed on a
|
||||
/// [GraphQL field][1] definition.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
#[derive(Debug, Default)]
|
||||
pub(crate) struct Attr {
|
||||
/// Explicitly specified name of this [GraphQL field][1].
|
||||
///
|
||||
/// If [`None`], then `camelCased` Rust method name is used by default.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) name: Option<SpanContainer<syn::LitStr>>,
|
||||
|
||||
/// Explicitly specified [description][2] of this [GraphQL field][1].
|
||||
|
@ -45,8 +45,8 @@ pub(crate) struct Attr {
|
|||
/// If [`None`], then Rust doc comment will be used as the [description][2],
|
||||
/// if any.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Descriptions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Descriptions
|
||||
pub(crate) description: Option<SpanContainer<syn::LitStr>>,
|
||||
|
||||
/// Explicitly specified [deprecation][2] of this [GraphQL field][1].
|
||||
|
@ -54,15 +54,15 @@ pub(crate) struct Attr {
|
|||
/// If [`None`], then Rust `#[deprecated]` attribute will be used as the
|
||||
/// [deprecation][2], if any.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Deprecation
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Deprecation
|
||||
pub(crate) deprecated: Option<SpanContainer<Option<syn::LitStr>>>,
|
||||
|
||||
/// Explicitly specified marker indicating that this method (or struct
|
||||
/// field) should be omitted by code generation and not considered as the
|
||||
/// [GraphQL field][1] definition.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) ignore: Option<SpanContainer<syn::Ident>>,
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ impl Attr {
|
|||
/// Parses [`Attr`] from the given multiple `name`d [`syn::Attribute`]s
|
||||
/// placed on a [GraphQL field][1] definition.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) fn from_attrs(name: &str, attrs: &[syn::Attribute]) -> syn::Result<Self> {
|
||||
let mut attr = filter_attrs(name, attrs)
|
||||
.map(|attr| attr.parse_args())
|
||||
|
@ -164,24 +164,24 @@ impl Attr {
|
|||
|
||||
/// Representation of a [GraphQL field][1] for code generation.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Definition {
|
||||
/// Rust type that this [GraphQL field][1] is represented by (method return
|
||||
/// type or struct field type).
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) ty: syn::Type,
|
||||
|
||||
/// Name of this [GraphQL field][1] in GraphQL schema.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) name: String,
|
||||
|
||||
/// [Description][2] of this [GraphQL field][1] to put into GraphQL schema.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Descriptions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Descriptions
|
||||
pub(crate) description: Option<String>,
|
||||
|
||||
/// [Deprecation][2] of this [GraphQL field][1] to put into GraphQL schema.
|
||||
|
@ -189,14 +189,14 @@ pub(crate) struct Definition {
|
|||
/// If inner [`Option`] is [`None`], then deprecation has no message
|
||||
/// attached.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Deprecation
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Deprecation
|
||||
pub(crate) deprecated: Option<Option<String>>,
|
||||
|
||||
/// Ident of the Rust method (or struct field) representing this
|
||||
/// [GraphQL field][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) ident: syn::Ident,
|
||||
|
||||
/// Rust [`MethodArgument`]s required to call the method representing this
|
||||
|
@ -205,19 +205,19 @@ pub(crate) struct Definition {
|
|||
/// If [`None`] then this [GraphQL field][1] is represented by a struct
|
||||
/// field.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) arguments: Option<Vec<MethodArgument>>,
|
||||
|
||||
/// Indicator whether the Rust method representing this [GraphQL field][1]
|
||||
/// has a [`syn::Receiver`].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) has_receiver: bool,
|
||||
|
||||
/// Indicator whether this [GraphQL field][1] should be resolved
|
||||
/// asynchronously.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) is_async: bool,
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ impl Definition {
|
|||
/// Indicates whether this [GraphQL field][1] is represented by a method,
|
||||
/// not a struct field.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
#[must_use]
|
||||
pub(crate) fn is_method(&self) -> bool {
|
||||
self.arguments.is_some()
|
||||
|
@ -235,7 +235,7 @@ impl Definition {
|
|||
/// tried to be resolved in the [`GraphQLValue::resolve_field`] method.
|
||||
///
|
||||
/// [`GraphQLValue::resolve_field`]: juniper::GraphQLValue::resolve_field
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
#[must_use]
|
||||
pub(crate) fn method_resolve_field_err_no_field_tokens(
|
||||
scalar: &scalar::Type,
|
||||
|
@ -255,7 +255,7 @@ impl Definition {
|
|||
/// which performs static checks for this [GraphQL field][1].
|
||||
///
|
||||
/// [`marker::IsOutputType::mark`]: juniper::marker::IsOutputType::mark
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
#[must_use]
|
||||
pub(crate) fn method_mark_tokens(
|
||||
&self,
|
||||
|
@ -291,7 +291,7 @@ impl Definition {
|
|||
///
|
||||
/// [`GraphQLType::meta`]: juniper::GraphQLType::meta
|
||||
/// [`Registry`]: juniper::Registry
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
#[must_use]
|
||||
pub(crate) fn method_meta_tokens(
|
||||
&self,
|
||||
|
@ -336,8 +336,8 @@ impl Definition {
|
|||
/// resolves this [GraphQL field][1] as [subscription][2].
|
||||
///
|
||||
/// [0]: juniper::GraphQLSubscriptionValue::resolve_field_into_stream
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Subscription
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Subscription
|
||||
#[must_use]
|
||||
pub(crate) fn method_resolve_field_into_stream_tokens(
|
||||
&self,
|
||||
|
@ -401,7 +401,7 @@ impl Definition {
|
|||
|
||||
/// Checks whether all [GraphQL fields][1] fields have different names.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
#[must_use]
|
||||
pub(crate) fn all_different(fields: &[Definition]) -> bool {
|
||||
let mut names: Vec<_> = fields.iter().map(|f| &f.name).collect();
|
||||
|
|
|
@ -8,7 +8,7 @@ use quote::quote;
|
|||
/// Value of a [GraphQL type][1] should be stored in a `res` binding in the generated code, before
|
||||
/// including this piece of code.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Types
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Types
|
||||
pub(crate) fn sync_resolving_code() -> TokenStream {
|
||||
quote! {
|
||||
::juniper::IntoResolvable::into(res, executor.context())
|
||||
|
@ -29,7 +29,7 @@ pub(crate) fn sync_resolving_code() -> TokenStream {
|
|||
///
|
||||
/// [`Future`]: std::future::Future
|
||||
/// [`Future::Output`]: std::future::Future::Output
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Types
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Types
|
||||
pub(crate) fn async_resolving_code(ty: Option<&syn::Type>) -> TokenStream {
|
||||
let ty = ty.map(|t| quote! { : #t });
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//! Common functions, definitions and extensions for parsing downcasting functions, used by GraphQL
|
||||
//! [interfaces][1] and [unions][2] definitions to downcast its type to a concrete implementer type.
|
||||
//!
|
||||
//! [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
//! [2]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
//! [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
//! [2]: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
||||
use proc_macro2::Span;
|
||||
use syn::{ext::IdentExt as _, spanned::Spanned as _};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Code generation for [GraphQL interface][1].
|
||||
//!
|
||||
//! [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
//! [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
|
||||
pub mod attr;
|
||||
pub mod derive;
|
||||
|
@ -35,7 +35,7 @@ use crate::{
|
|||
/// on it and enum alias which generic arguments are filled with
|
||||
/// [GraphQL interface][1] implementers.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
fn enum_idents(
|
||||
trait_ident: &syn::Ident,
|
||||
alias_ident: Option<&syn::Ident>,
|
||||
|
@ -54,14 +54,14 @@ fn enum_idents(
|
|||
/// trait or struct definition, when generating code for [GraphQL interface][1]
|
||||
/// type.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
#[derive(Debug, Default)]
|
||||
struct Attr {
|
||||
/// Explicitly specified name of [GraphQL interface][1] type.
|
||||
///
|
||||
/// If [`None`], then Rust trait name is used by default.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
name: Option<SpanContainer<String>>,
|
||||
|
||||
/// Explicitly specified [description][2] of [GraphQL interface][1] type.
|
||||
|
@ -69,8 +69,8 @@ struct Attr {
|
|||
/// If [`None`], then Rust doc comment will be used as the [description][2],
|
||||
/// if any.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Descriptions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Descriptions
|
||||
description: Option<SpanContainer<String>>,
|
||||
|
||||
/// Explicitly specified identifier of the type alias of Rust enum type
|
||||
|
@ -79,14 +79,14 @@ struct Attr {
|
|||
///
|
||||
/// If [`None`], then `{trait_name}Value` identifier will be used.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
r#enum: Option<SpanContainer<syn::Ident>>,
|
||||
|
||||
/// Explicitly specified Rust types of [GraphQL objects][2] or
|
||||
/// [interfaces][1] implementing this [GraphQL interface][1] type.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Objects
|
||||
implemented_for: HashSet<SpanContainer<syn::TypePath>>,
|
||||
|
||||
/// Explicitly specified [GraphQL interfaces, implemented][1] by this
|
||||
|
@ -102,7 +102,7 @@ struct Attr {
|
|||
/// If [`None`], then unit type `()` is assumed as a type of [`Context`].
|
||||
///
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
context: Option<SpanContainer<syn::Type>>,
|
||||
|
||||
/// Explicitly specified type (or type parameter with its bounds) of
|
||||
|
@ -116,7 +116,7 @@ struct Attr {
|
|||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
scalar: Option<SpanContainer<scalar::AttrValue>>,
|
||||
|
||||
/// Explicitly specified marker indicating that the Rust trait should be
|
||||
|
@ -131,7 +131,7 @@ struct Attr {
|
|||
///
|
||||
/// If [`None`] then the default rule will be [`RenameRule::CamelCase`].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
rename_fields: Option<SpanContainer<RenameRule>>,
|
||||
|
||||
/// Indicator whether the generated code is intended to be used only inside
|
||||
|
@ -277,18 +277,18 @@ impl Attr {
|
|||
|
||||
/// Definition of [GraphQL interface][1] for code generation.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
struct Definition {
|
||||
/// [`syn::Generics`] of the trait or struct describing the
|
||||
/// [GraphQL interface][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
generics: syn::Generics,
|
||||
|
||||
/// [`syn::Visibility`] of the trait or struct describing the
|
||||
/// [GraphQL interface][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
vis: syn::Visibility,
|
||||
|
||||
/// Name of the generic enum describing all [`implementers`]. It's generic
|
||||
|
@ -319,7 +319,7 @@ struct Definition {
|
|||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
context: syn::Type,
|
||||
|
||||
/// [`ScalarValue`] parametrization to generate [`GraphQLType`]
|
||||
|
@ -327,18 +327,18 @@ struct Definition {
|
|||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
scalar: scalar::Type,
|
||||
|
||||
/// Defined [GraphQL fields][2] of this [GraphQL interface][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
fields: Vec<field::Definition>,
|
||||
|
||||
/// Defined [`Implementer`]s of this [GraphQL interface][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
implemented_for: Vec<syn::TypePath>,
|
||||
|
||||
/// [GraphQL interfaces implemented][1] by this [GraphQL interface][0].
|
||||
|
@ -352,7 +352,7 @@ struct Definition {
|
|||
/// [GraphQL interface][1]. We generate hacky `const` which doesn't actually
|
||||
/// use it, but suppresses this warning.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
suppress_dead_code: Option<(syn::Ident, syn::Fields)>,
|
||||
|
||||
/// Intra-doc link to the [`syn::Item`] defining this
|
||||
|
@ -440,13 +440,13 @@ impl Definition {
|
|||
"Enum building an opaque value represented by [`{}`]({}) \
|
||||
[GraphQL interface][0].\
|
||||
\n\n\
|
||||
[0]: https://spec.graphql.org/June2018/#sec-Interfaces",
|
||||
[0]: https://spec.graphql.org/October2021#sec-Interfaces",
|
||||
self.name, self.src_intra_doc_link,
|
||||
);
|
||||
let enum_alias_doc = format!(
|
||||
"Opaque value represented by [`{}`]({}) [GraphQL interface][0].\
|
||||
\n\n\
|
||||
[0]: https://spec.graphql.org/June2018/#sec-Interfaces",
|
||||
[0]: https://spec.graphql.org/October2021#sec-Interfaces",
|
||||
self.name, self.src_intra_doc_link,
|
||||
);
|
||||
|
||||
|
@ -513,7 +513,7 @@ impl Definition {
|
|||
/// [GraphQL interface][1].
|
||||
///
|
||||
/// [`GraphQLInterface`]: juniper::GraphQLInterface
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
#[must_use]
|
||||
fn impl_graphql_interface_tokens(&self) -> TokenStream {
|
||||
let ty = &self.enum_alias_ident;
|
||||
|
@ -603,7 +603,7 @@ impl Definition {
|
|||
/// this [GraphQL interface][1].
|
||||
///
|
||||
/// [`marker::IsOutputType`]: juniper::marker::IsOutputType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
#[must_use]
|
||||
fn impl_output_type_tokens(&self) -> TokenStream {
|
||||
let ty = &self.enum_alias_ident;
|
||||
|
@ -679,7 +679,7 @@ impl Definition {
|
|||
/// [GraphQL interface][1].
|
||||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
#[must_use]
|
||||
fn impl_graphql_type_tokens(&self) -> TokenStream {
|
||||
let ty = &self.enum_alias_ident;
|
||||
|
@ -753,7 +753,7 @@ impl Definition {
|
|||
/// [GraphQL interface][1].
|
||||
///
|
||||
/// [`GraphQLValue`]: juniper::GraphQLValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
#[must_use]
|
||||
fn impl_graphql_value_tokens(&self) -> TokenStream {
|
||||
let ty = &self.enum_alias_ident;
|
||||
|
@ -835,7 +835,7 @@ impl Definition {
|
|||
/// [GraphQL interface][1].
|
||||
///
|
||||
/// [`GraphQLValueAsync`]: juniper::GraphQLValueAsync
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
#[must_use]
|
||||
fn impl_graphql_value_async_tokens(&self) -> TokenStream {
|
||||
let ty = &self.enum_alias_ident;
|
||||
|
@ -901,7 +901,7 @@ impl Definition {
|
|||
/// [`BaseType`]: juniper::macros::reflect::BaseType
|
||||
/// [`Fields`]: juniper::macros::reflect::Fields
|
||||
/// [`WrappedType`]: juniper::macros::reflect::WrappedType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
#[must_use]
|
||||
fn impl_reflection_traits_tokens(&self) -> TokenStream {
|
||||
let ty = &self.enum_alias_ident;
|
||||
|
@ -966,7 +966,7 @@ impl Definition {
|
|||
/// [GraphQL interface][1].
|
||||
///
|
||||
/// [`FieldMeta`]: juniper::macros::reflect::FieldMeta
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
fn impl_field_meta_tokens(&self) -> TokenStream {
|
||||
let ty = &self.enum_alias_ident;
|
||||
let context = &self.context;
|
||||
|
@ -1027,7 +1027,7 @@ impl Definition {
|
|||
/// this [GraphQL interface][1].
|
||||
///
|
||||
/// [`Field`]: juniper::macros::reflect::Field
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
fn impl_field_tokens(&self) -> TokenStream {
|
||||
let ty = &self.enum_alias_ident;
|
||||
let scalar = &self.scalar;
|
||||
|
@ -1107,7 +1107,7 @@ impl Definition {
|
|||
/// of this [GraphQL interface][1].
|
||||
///
|
||||
/// [`AsyncField`]: juniper::macros::reflect::AsyncField
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
fn impl_async_field_tokens(&self) -> TokenStream {
|
||||
let ty = &self.enum_alias_ident;
|
||||
let scalar = &self.scalar;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Code generation for [GraphQL object][1].
|
||||
//!
|
||||
//! [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
//! [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
|
||||
pub mod attr;
|
||||
pub mod derive;
|
||||
|
@ -32,14 +32,14 @@ use syn::ext::IdentExt;
|
|||
/// Available arguments behind `#[graphql]` (or `#[graphql_object]`) attribute
|
||||
/// when generating code for [GraphQL object][1] type.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[derive(Debug, Default)]
|
||||
pub(crate) struct Attr {
|
||||
/// Explicitly specified name of this [GraphQL object][1] type.
|
||||
///
|
||||
/// If [`None`], then Rust type name is used by default.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub(crate) name: Option<SpanContainer<String>>,
|
||||
|
||||
/// Explicitly specified [description][2] of this [GraphQL object][1] type.
|
||||
|
@ -47,8 +47,8 @@ pub(crate) struct Attr {
|
|||
/// If [`None`], then Rust doc comment will be used as the [description][2],
|
||||
/// if any.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Descriptions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Descriptions
|
||||
pub(crate) description: Option<SpanContainer<String>>,
|
||||
|
||||
/// Explicitly specified type of [`Context`] to use for resolving this
|
||||
|
@ -57,7 +57,7 @@ pub(crate) struct Attr {
|
|||
/// If [`None`], then unit type `()` is assumed as a type of [`Context`].
|
||||
///
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub(crate) context: Option<SpanContainer<syn::Type>>,
|
||||
|
||||
/// Explicitly specified type (or type parameter with its bounds) of
|
||||
|
@ -71,14 +71,14 @@ pub(crate) struct Attr {
|
|||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub(crate) scalar: Option<SpanContainer<scalar::AttrValue>>,
|
||||
|
||||
/// Explicitly specified [GraphQL interfaces][2] this [GraphQL object][1]
|
||||
/// type implements.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
pub(crate) interfaces: HashSet<SpanContainer<syn::Type>>,
|
||||
|
||||
/// Explicitly specified [`RenameRule`] for all fields of this
|
||||
|
@ -86,7 +86,7 @@ pub(crate) struct Attr {
|
|||
///
|
||||
/// If [`None`] then the default rule will be [`RenameRule::CamelCase`].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub(crate) rename_fields: Option<SpanContainer<RenameRule>>,
|
||||
|
||||
/// Indicator whether the generated code is intended to be used only inside
|
||||
|
@ -204,30 +204,30 @@ impl Attr {
|
|||
|
||||
/// Definition of [GraphQL object][1] for code generation.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Definition<Operation: ?Sized> {
|
||||
/// Name of this [GraphQL object][1] in GraphQL schema.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub(crate) name: String,
|
||||
|
||||
/// Rust type that this [GraphQL object][1] is represented with.
|
||||
///
|
||||
/// It should contain all its generics, if any.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub(crate) ty: syn::Type,
|
||||
|
||||
/// Generics of the Rust type that this [GraphQL object][1] is implemented
|
||||
/// for.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub(crate) generics: syn::Generics,
|
||||
|
||||
/// Description of this [GraphQL object][1] to put into GraphQL schema.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub(crate) description: Option<String>,
|
||||
|
||||
/// Rust type of [`Context`] to generate [`GraphQLType`] implementation with
|
||||
|
@ -235,7 +235,7 @@ pub(crate) struct Definition<Operation: ?Sized> {
|
|||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub(crate) context: syn::Type,
|
||||
|
||||
/// [`ScalarValue`] parametrization to generate [`GraphQLType`]
|
||||
|
@ -243,28 +243,28 @@ pub(crate) struct Definition<Operation: ?Sized> {
|
|||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
pub(crate) scalar: scalar::Type,
|
||||
|
||||
/// Defined [GraphQL fields][2] of this [GraphQL object][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Language.Fields
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Language.Fields
|
||||
pub(crate) fields: Vec<field::Definition>,
|
||||
|
||||
/// [GraphQL interfaces][2] implemented by this [GraphQL object][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
pub(crate) interfaces: HashSet<syn::Type>,
|
||||
|
||||
/// [GraphQL operation][1] this [`Definition`] should generate code for.
|
||||
///
|
||||
/// Either [GraphQL query][2] or [GraphQL subscription][3].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Language.Operations
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Query
|
||||
/// [3]: https://spec.graphql.org/June2018/#sec-Subscription
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Language.Operations
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Query
|
||||
/// [3]: https://spec.graphql.org/October2021#sec-Subscription
|
||||
pub(crate) _operation: PhantomData<Box<Operation>>,
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ impl<Operation: ?Sized + 'static> Definition<Operation> {
|
|||
///
|
||||
/// [`GraphQLAsyncValue`]: juniper::GraphQLAsyncValue
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[must_use]
|
||||
pub(crate) fn impl_generics(&self, for_async: bool) -> (TokenStream, Option<syn::WhereClause>) {
|
||||
let mut generics = self.generics.clone();
|
||||
|
@ -334,7 +334,7 @@ impl<Operation: ?Sized + 'static> Definition<Operation> {
|
|||
/// this [GraphQL object][1].
|
||||
///
|
||||
/// [`marker::IsOutputType`]: juniper::marker::IsOutputType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[must_use]
|
||||
pub(crate) fn impl_output_type_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -369,7 +369,7 @@ impl<Operation: ?Sized + 'static> Definition<Operation> {
|
|||
/// [`BaseType`]: juniper::macros::reflect::BaseType
|
||||
/// [`Fields`]: juniper::macros::reflect::Fields
|
||||
/// [`WrappedType`]: juniper::macros::reflect::WrappedType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[must_use]
|
||||
pub(crate) fn impl_reflection_traits_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -428,7 +428,7 @@ impl<Operation: ?Sized + 'static> Definition<Operation> {
|
|||
/// [GraphQL object][1].
|
||||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[must_use]
|
||||
pub(crate) fn impl_graphql_type_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -491,7 +491,7 @@ impl<Operation: ?Sized + 'static> Definition<Operation> {
|
|||
|
||||
/// [GraphQL query operation][2] of the [`Definition`] to generate code for.
|
||||
///
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Query
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Query
|
||||
struct Query;
|
||||
|
||||
impl ToTokens for Definition<Query> {
|
||||
|
@ -513,7 +513,7 @@ impl Definition<Query> {
|
|||
/// [GraphQL object][1].
|
||||
///
|
||||
/// [`GraphQLObject`]: juniper::GraphQLObject
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[must_use]
|
||||
fn impl_graphql_object_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -561,7 +561,7 @@ impl Definition<Query> {
|
|||
/// of this [GraphQL object][1].
|
||||
///
|
||||
/// [`FieldMeta`]: juniper::FieldMeta
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[must_use]
|
||||
fn impl_field_meta_tokens(&self) -> TokenStream {
|
||||
let impl_ty = &self.ty;
|
||||
|
@ -622,7 +622,7 @@ impl Definition<Query> {
|
|||
/// this [GraphQL object][1].
|
||||
///
|
||||
/// [`Field`]: juniper::Field
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[must_use]
|
||||
fn impl_field_tokens(&self) -> TokenStream {
|
||||
let (impl_ty, scalar) = (&self.ty, &self.scalar);
|
||||
|
@ -695,7 +695,7 @@ impl Definition<Query> {
|
|||
/// of this [GraphQL object][1].
|
||||
///
|
||||
/// [`AsyncField`]: juniper::AsyncField
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[must_use]
|
||||
fn impl_async_field_tokens(&self) -> TokenStream {
|
||||
let (impl_ty, scalar) = (&self.ty, &self.scalar);
|
||||
|
@ -757,7 +757,7 @@ impl Definition<Query> {
|
|||
/// [GraphQL object][1].
|
||||
///
|
||||
/// [`GraphQLValue`]: juniper::GraphQLValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[must_use]
|
||||
fn impl_graphql_value_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -824,7 +824,7 @@ impl Definition<Query> {
|
|||
/// [GraphQL object][1].
|
||||
///
|
||||
/// [`GraphQLValueAsync`]: juniper::GraphQLValueAsync
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[must_use]
|
||||
fn impl_graphql_value_async_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Code generation for [GraphQL subscription][1].
|
||||
//!
|
||||
//! [1]: https://spec.graphql.org/June2018/#sec-Subscription
|
||||
//! [1]: https://spec.graphql.org/October2021#sec-Subscription
|
||||
|
||||
pub mod attr;
|
||||
|
||||
|
@ -13,7 +13,7 @@ use crate::{common::field, graphql_object::Definition};
|
|||
/// [GraphQL subscription operation][2] of the [`Definition`] to generate code
|
||||
/// for.
|
||||
///
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Subscription
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Subscription
|
||||
struct Subscription;
|
||||
|
||||
impl ToTokens for Definition<Subscription> {
|
||||
|
@ -31,7 +31,7 @@ impl Definition<Subscription> {
|
|||
/// [GraphQL subscription][1].
|
||||
///
|
||||
/// [`GraphQLValue`]: juniper::GraphQLValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Subscription
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Subscription
|
||||
#[must_use]
|
||||
fn impl_graphql_value_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -80,7 +80,7 @@ impl Definition<Subscription> {
|
|||
/// for this [GraphQL subscription][1].
|
||||
///
|
||||
/// [`GraphQLSubscriptionValue`]: juniper::GraphQLSubscriptionValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Subscription
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Subscription
|
||||
#[must_use]
|
||||
fn impl_graphql_subscription_value_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
|
|
@ -112,7 +112,7 @@ fn expand_on_trait(
|
|||
/// On failure returns [`None`] and internally fills up [`proc_macro_error`]
|
||||
/// with the corresponding errors.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
fn parse_variant_from_trait_method(
|
||||
method: &mut syn::TraitItemMethod,
|
||||
trait_ident: &syn::Ident,
|
||||
|
|
|
@ -98,7 +98,7 @@ fn expand_enum(ast: syn::DeriveInput) -> syn::Result<Definition> {
|
|||
/// On failure returns [`None`] and internally fills up [`proc_macro_error`]
|
||||
/// with the corresponding errors.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
fn parse_variant_from_enum_variant(
|
||||
var: syn::Variant,
|
||||
enum_ident: &syn::Ident,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Code generation for [GraphQL union][1].
|
||||
//!
|
||||
//! [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
//! [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
||||
pub mod attr;
|
||||
pub mod derive;
|
||||
|
@ -35,14 +35,14 @@ type AttrResolvers = HashMap<syn::Type, SpanContainer<syn::ExprPath>>;
|
|||
/// Available arguments behind `#[graphql]` (or `#[graphql_union]`) attribute
|
||||
/// when generating code for [GraphQL union][1] type.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
#[derive(Debug, Default)]
|
||||
struct Attr {
|
||||
/// Explicitly specified name of [GraphQL union][1] type.
|
||||
///
|
||||
/// If [`None`], then Rust type name is used by default.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
name: Option<SpanContainer<String>>,
|
||||
|
||||
/// Explicitly specified [description][2] of [GraphQL union][1] type.
|
||||
|
@ -50,8 +50,8 @@ struct Attr {
|
|||
/// If [`None`], then Rust doc comment will be used as the [description][2],
|
||||
/// if any.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [2]: https://spec.graphql.org/June2018/#sec-Descriptions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
/// [2]: https://spec.graphql.org/October2021#sec-Descriptions
|
||||
description: Option<SpanContainer<String>>,
|
||||
|
||||
/// Explicitly specified type of [`Context`] to use for resolving this
|
||||
|
@ -60,7 +60,7 @@ struct Attr {
|
|||
/// If [`None`], then unit type `()` is assumed as a type of [`Context`].
|
||||
///
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
context: Option<SpanContainer<syn::Type>>,
|
||||
|
||||
/// Explicitly specified type of [`ScalarValue`] to use for resolving this
|
||||
|
@ -74,7 +74,7 @@ struct Attr {
|
|||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
scalar: Option<SpanContainer<scalar::AttrValue>>,
|
||||
|
||||
/// Explicitly specified external resolver functions for [GraphQL union][1]
|
||||
|
@ -85,7 +85,7 @@ struct Attr {
|
|||
/// external resolver function has sense, when some custom [union][1]
|
||||
/// variant resolving logic is involved, or variants cannot be inferred.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
external_resolvers: AttrResolvers,
|
||||
|
||||
/// Indicator whether the generated code is intended to be used only inside
|
||||
|
@ -192,13 +192,13 @@ impl Attr {
|
|||
/// Available arguments behind `#[graphql]` attribute when generating code for
|
||||
/// [GraphQL union][1]'s variant.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
#[derive(Debug, Default)]
|
||||
struct VariantAttr {
|
||||
/// Explicitly specified marker for the variant/field being ignored and not
|
||||
/// included into [GraphQL union][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
ignore: Option<SpanContainer<syn::Ident>>,
|
||||
|
||||
/// Explicitly specified external resolver function for this [GraphQL union][1] variant.
|
||||
|
@ -207,7 +207,7 @@ struct VariantAttr {
|
|||
/// Usually, specifying an external resolver function has sense, when some custom resolving
|
||||
/// logic is involved.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
external_resolver: Option<SpanContainer<syn::ExprPath>>,
|
||||
}
|
||||
|
||||
|
@ -259,22 +259,22 @@ impl VariantAttr {
|
|||
|
||||
/// Definition of [GraphQL union][1] for code generation.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
struct Definition {
|
||||
/// Name of this [GraphQL union][1] in GraphQL schema.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
name: String,
|
||||
|
||||
/// Rust type that this [GraphQL union][1] is represented with.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
ty: syn::Type,
|
||||
|
||||
/// Generics of the Rust type that this [GraphQL union][1] is implemented
|
||||
/// for.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
generics: syn::Generics,
|
||||
|
||||
/// Indicator whether code should be generated for a trait object, rather
|
||||
|
@ -283,7 +283,7 @@ struct Definition {
|
|||
|
||||
/// Description of this [GraphQL union][1] to put into GraphQL schema.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
description: Option<String>,
|
||||
|
||||
/// Rust type of [`Context`] to generate [`GraphQLType`] implementation with
|
||||
|
@ -291,7 +291,7 @@ struct Definition {
|
|||
///
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
context: syn::Type,
|
||||
|
||||
/// Rust type of [`ScalarValue`] to generate [`GraphQLType`] implementation
|
||||
|
@ -305,12 +305,12 @@ struct Definition {
|
|||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
scalar: scalar::Type,
|
||||
|
||||
/// Variants definitions of this [GraphQL union][1].
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
variants: Vec<VariantDefinition>,
|
||||
}
|
||||
|
||||
|
@ -334,7 +334,7 @@ impl Definition {
|
|||
///
|
||||
/// [`GraphQLAsyncValue`]: juniper::GraphQLAsyncValue
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
#[must_use]
|
||||
fn impl_generics(
|
||||
&self,
|
||||
|
@ -411,7 +411,7 @@ impl Definition {
|
|||
/// [GraphQL union][1].
|
||||
///
|
||||
/// [`GraphQLUnion`]: juniper::GraphQLUnion
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
#[must_use]
|
||||
fn impl_graphql_union_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -439,7 +439,7 @@ impl Definition {
|
|||
/// this [GraphQL union][1].
|
||||
///
|
||||
/// [`marker::IsOutputType`]: juniper::marker::IsOutputType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
#[must_use]
|
||||
fn impl_output_type_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -463,7 +463,7 @@ impl Definition {
|
|||
/// [GraphQL union][1].
|
||||
///
|
||||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
#[must_use]
|
||||
fn impl_graphql_type_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -507,7 +507,7 @@ impl Definition {
|
|||
/// [GraphQL union][1].
|
||||
///
|
||||
/// [`GraphQLValue`]: juniper::GraphQLValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
#[must_use]
|
||||
fn impl_graphql_value_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -574,7 +574,7 @@ impl Definition {
|
|||
/// [GraphQL union][1].
|
||||
///
|
||||
/// [`GraphQLValueAsync`]: juniper::GraphQLValueAsync
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
#[must_use]
|
||||
fn impl_graphql_value_async_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -618,7 +618,7 @@ impl Definition {
|
|||
/// [`BaseSubTypes`]: juniper::macros::reflect::BaseSubTypes
|
||||
/// [`BaseType`]: juniper::macros::reflect::BaseType
|
||||
/// [`WrappedType`]: juniper::macros::reflect::WrappedType
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
#[must_use]
|
||||
pub(crate) fn impl_reflection_traits_tokens(&self) -> TokenStream {
|
||||
let scalar = &self.scalar;
|
||||
|
@ -659,22 +659,22 @@ impl Definition {
|
|||
|
||||
/// Definition of [GraphQL union][1] variant for code generation.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
struct VariantDefinition {
|
||||
/// Rust type that this [GraphQL union][1] variant resolves into.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
ty: syn::Type,
|
||||
|
||||
/// Rust code for value resolution of this [GraphQL union][1] variant.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
resolver_code: syn::Expr,
|
||||
|
||||
/// Rust code for checking whether [GraphQL union][1] should be resolved
|
||||
/// into this variant.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
resolver_check: syn::Expr,
|
||||
|
||||
/// Rust type of [`Context`] that this [GraphQL union][1] variant requires
|
||||
|
@ -684,7 +684,7 @@ struct VariantDefinition {
|
|||
/// trait method contains context argument.
|
||||
///
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
context: Option<syn::Type>,
|
||||
}
|
||||
|
||||
|
@ -763,7 +763,7 @@ impl VariantDefinition {
|
|||
/// If duplication happens, then resolving code is overwritten with the one from
|
||||
/// `external_resolvers`.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
fn emerge_union_variants_from_attr(
|
||||
variants: &mut Vec<VariantDefinition>,
|
||||
external_resolvers: AttrResolvers,
|
||||
|
@ -810,7 +810,7 @@ fn emerge_union_variants_from_attr(
|
|||
/// used to enforce this requirement in the generated code. However, due to the
|
||||
/// bad error message this implementation should stay and provide guidance.
|
||||
///
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
/// [2]: juniper::sa::assert_type_ne_all
|
||||
fn all_variants_different(variants: &[VariantDefinition]) -> bool {
|
||||
let mut types: Vec<_> = variants.iter().map(|var| &var.ty).collect();
|
||||
|
|
|
@ -1287,8 +1287,8 @@ pub fn derive_scalar_value(input: TokenStream) -> TokenStream {
|
|||
/// [`Context`]: juniper::Context
|
||||
/// [`Executor`]: juniper::Executor
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [0]: https://spec.graphql.org/June2018
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [0]: https://spec.graphql.org/October2021
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
/// [2]: https://doc.rust-lang.org/stable/reference/items/traits.html#object-safety
|
||||
/// [3]: https://doc.rust-lang.org/stable/reference/types/trait-object.html
|
||||
/// [4]: https://doc.rust-lang.org/stable/std/primitive.unit.html
|
||||
|
@ -1328,7 +1328,7 @@ pub fn graphql_interface(attr: TokenStream, body: TokenStream) -> TokenStream {
|
|||
/// For more info and possibilities see [`#[graphql_interface]`] macro.
|
||||
///
|
||||
/// [`#[graphql_interface]`]: crate::graphql_interface
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
#[proc_macro_error]
|
||||
#[proc_macro_derive(GraphQLInterface, attributes(graphql))]
|
||||
pub fn derive_interface(body: TokenStream) -> TokenStream {
|
||||
|
@ -1465,7 +1465,7 @@ pub fn derive_interface(body: TokenStream) -> TokenStream {
|
|||
/// ```
|
||||
///
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[proc_macro_error]
|
||||
#[proc_macro_derive(GraphQLObject, attributes(graphql))]
|
||||
pub fn derive_object(body: TokenStream) -> TokenStream {
|
||||
|
@ -1789,8 +1789,8 @@ pub fn derive_object(body: TokenStream) -> TokenStream {
|
|||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [`GraphQLValue`]: juniper::GraphQLValue
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [0]: https://spec.graphql.org/June2018
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Objects
|
||||
/// [0]: https://spec.graphql.org/October2021
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Objects
|
||||
#[proc_macro_error]
|
||||
#[proc_macro_attribute]
|
||||
pub fn graphql_object(attr: TokenStream, body: TokenStream) -> TokenStream {
|
||||
|
@ -1843,7 +1843,7 @@ pub fn graphql_object(attr: TokenStream, body: TokenStream) -> TokenStream {
|
|||
/// [`GraphQLType`]: juniper::GraphQLType
|
||||
/// [`GraphQLSubscriptionValue`]: juniper::GraphQLSubscriptionValue
|
||||
/// [`Stream`]: futures::Stream
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Subscription
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Subscription
|
||||
#[proc_macro_error]
|
||||
#[proc_macro_attribute]
|
||||
pub fn graphql_subscription(attr: TokenStream, body: TokenStream) -> TokenStream {
|
||||
|
@ -2150,7 +2150,7 @@ pub fn graphql_subscription(attr: TokenStream, body: TokenStream) -> TokenStream
|
|||
///
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
/// [4]: https://doc.rust-lang.org/stable/std/primitive.unit.html
|
||||
#[proc_macro_error]
|
||||
#[proc_macro_derive(GraphQLUnion, attributes(graphql))]
|
||||
|
@ -2440,7 +2440,7 @@ pub fn derive_union(body: TokenStream) -> TokenStream {
|
|||
///
|
||||
/// [`Context`]: juniper::Context
|
||||
/// [`ScalarValue`]: juniper::ScalarValue
|
||||
/// [1]: https://spec.graphql.org/June2018/#sec-Unions
|
||||
/// [1]: https://spec.graphql.org/October2021#sec-Unions
|
||||
/// [2]: https://doc.rust-lang.org/stable/reference/items/traits.html#object-safety
|
||||
/// [3]: https://doc.rust-lang.org/stable/reference/types/trait-object.html
|
||||
/// [4]: https://doc.rust-lang.org/stable/std/primitive.unit.html
|
||||
|
|
|
@ -5,8 +5,8 @@ use std::fmt;
|
|||
use proc_macro2::Span;
|
||||
use proc_macro_error::{Diagnostic, Level};
|
||||
|
||||
/// URL of the GraphQL specification (June 2018 Edition).
|
||||
pub const SPEC_URL: &str = "https://spec.graphql.org/June2018/";
|
||||
/// URL of the GraphQL specification (October 2021 Edition).
|
||||
pub const SPEC_URL: &str = "https://spec.graphql.org/October2021";
|
||||
|
||||
pub enum GraphQLScope {
|
||||
EnumDerive,
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
4 | enum __Test {
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL enum no fields allowed for non-ignored variants
|
|||
5 | Variant(i32),
|
||||
| ^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Enums
|
||||
= note: https://spec.graphql.org/October2021#sec-Enums
|
||||
|
|
|
@ -5,4 +5,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
6 | | test: String,
|
||||
| |________________^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
5 | __id: String,
|
||||
| ^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -9,4 +9,4 @@ error: GraphQL interface must have a different name for each field
|
|||
9 | | }
|
||||
| |_^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
= note: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
4 | struct __Character {
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL interface must have at least one field
|
|||
4 | struct Character {}
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
= note: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL interface expected named struct field
|
|||
4 | struct Character(i32);
|
||||
| ^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
= note: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
5 | __id: String,
|
||||
| ^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -9,4 +9,4 @@ error: GraphQL interface must have a different name for each field
|
|||
9 | | }
|
||||
| |_^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
= note: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
4 | struct __Character {
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL interface must have at least one field
|
|||
4 | struct Character {}
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
= note: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL interface expected named struct field
|
|||
4 | struct Character(i32);
|
||||
| ^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
= note: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
5 | fn id(&self, __num: i32) -> &str;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
5 | fn __id(&self) -> &str;
|
||||
| ^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -9,4 +9,4 @@ error: GraphQL interface must have a different name for each field
|
|||
9 | | }
|
||||
| |_^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
= note: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
|
|
|
@ -7,4 +7,4 @@ error: GraphQL interface trait method can't have default implementation
|
|||
7 | | }
|
||||
| |_____^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
= note: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
4 | trait __Character {
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL interface must have at least one field
|
|||
4 | trait Character {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Interfaces
|
||||
= note: https://spec.graphql.org/October2021#sec-Interfaces
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
7 | fn id(&self, __num: i32) -> &str {
|
||||
| ^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL object must have a different name for each field
|
|||
6 | impl ObjA {
|
||||
| ^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Objects
|
||||
= note: https://spec.graphql.org/October2021#sec-Objects
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
6 | impl __Obj {
|
||||
| ^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL object must have at least one field
|
|||
6 | impl Obj {}
|
||||
| ^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Objects
|
||||
= note: https://spec.graphql.org/October2021#sec-Objects
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
5 | __test: String,
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -8,4 +8,4 @@ error: GraphQL object must have a different name for each field
|
|||
8 | | }
|
||||
| |_^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Objects
|
||||
= note: https://spec.graphql.org/October2021#sec-Objects
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
4 | struct __Obj {
|
||||
| ^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL object must have at least one field
|
|||
4 | struct Obj {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Objects
|
||||
= note: https://spec.graphql.org/October2021#sec-Objects
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
11 | async fn id(&self, __num: i32) -> Stream<'static, &'static str> {
|
||||
| ^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,5 +4,5 @@ error: GraphQL object synchronous resolvers are not supported
|
|||
11 | fn id(&self) -> Stream<'static, bool> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Objects
|
||||
= note: https://spec.graphql.org/October2021#sec-Objects
|
||||
= note: Specify that this function is async: `async fn foo()`
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL object must have a different name for each field
|
|||
10 | impl ObjA {
|
||||
| ^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Objects
|
||||
= note: https://spec.graphql.org/October2021#sec-Objects
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
10 | impl __Obj {
|
||||
| ^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL object must have at least one field
|
|||
6 | impl Obj {}
|
||||
| ^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Objects
|
||||
= note: https://spec.graphql.org/October2021#sec-Objects
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL union variant `Human` already has external resolver function `res
|
|||
6 | #[graphql(with = resolve_fn2)]
|
||||
| ^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
4 | enum __Character {
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL union expects at least one union variant
|
|||
4 | enum Character {}
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
|
|
@ -7,4 +7,4 @@ error: GraphQL union must have a different type for each union variant
|
|||
7 | | }
|
||||
| |_^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
|
|
@ -4,7 +4,7 @@ error: GraphQL union enum allows only unnamed variants with a single field, e.g.
|
|||
5 | A { human: Human },
|
||||
| ^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
||||
error: GraphQL union enum allows only unnamed variants with a single field, e.g. `Some(T)`
|
||||
--> fail/union/enum_wrong_variant_field.rs:10:6
|
||||
|
@ -12,4 +12,4 @@ error: GraphQL union enum allows only unnamed variants with a single field, e.g.
|
|||
10 | A(Human, u8),
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
5 | struct __Character;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL union expects at least one union variant
|
|||
4 | struct Character;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
|
|
@ -4,5 +4,5 @@ error: GraphQL union trait method `a` conflicts with the external resolver funct
|
|||
5 | fn a(&self) -> Option<&Human>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
= note: use `#[graphql(ignore)]` attribute to ignore this trait method for union variants resolution
|
||||
|
|
|
@ -4,4 +4,4 @@ error: All types and directives defined within a schema must not have a name whi
|
|||
4 | trait __Character {
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Schema
|
||||
= note: https://spec.graphql.org/October2021#sec-Schema
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL union expects at least one union variant
|
|||
4 | trait Character {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
|
|
@ -7,4 +7,4 @@ error: GraphQL union must have a different type for each union variant
|
|||
7 | | }
|
||||
| |_^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
|
|
@ -4,5 +4,5 @@ error: GraphQL union cannot use #[graphql(with = ...)] attribute on a trait meth
|
|||
5 | #[graphql(with = something)]
|
||||
| ^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
= note: instead use #[graphql(ignore)] on the method with #[graphql_union(on ... = ...)] on the trait itself
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL union expects trait method to accept `&self` only and, optionally
|
|||
5 | fn a(&self, ctx: &(), rand: u8) -> Option<&Human>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
|
|
@ -4,4 +4,4 @@ error: GraphQL union expects trait method return type to be `Option<&VariantType
|
|||
5 | fn a(&self) -> &Human;
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: https://spec.graphql.org/June2018/#sec-Unions
|
||||
= note: https://spec.graphql.org/October2021#sec-Unions
|
||||
|
|
Loading…
Reference in a new issue