From be210c0bfe32a7ca0701d708c762fe318f80f96a Mon Sep 17 00:00:00 2001 From: Seyyed Morteza Moosavi Date: Sun, 7 Apr 2024 18:49:46 +0330 Subject: [PATCH] update snapshots --- derive/tests/app.rs | 89 ++++++++- derive/tests/expand_object/args_tests.rs | 68 ++++++- .../expand_object/expand_object_tests.rs | 103 +++++++++- derive/tests/expand_object/generic_tests.rs | 60 +++++- derive/tests/expand_object/reuse_tests.rs | 18 +- derive/tests/gql_enum/tests.rs | 101 +++++++++- derive/tests/input_object/list_tests.rs | 98 +++++++++- derive/tests/input_object/tests.rs | 129 ++++++++++++- derive/tests/input_object/type_tests.rs | 60 +++++- derive/tests/interface/as_value_tests.rs | 76 +++++++- derive/tests/interface/async_test.rs | 20 +- .../tests/interface/implementation_tests.rs | 74 ++++++- derive/tests/interface/interface_tests.rs | 180 +++++++++++++++++- derive/tests/interface/list_tests.rs | 43 ++++- derive/tests/interface/output_types_tests.rs | 54 +++++- derive/tests/mutation/mutation_tests.rs | 94 ++++++++- derive/tests/registry.rs | 42 +++- .../resolved_object_args_tests.rs | 73 ++++++- .../resolved_object_list_args_tests.rs | 44 ++++- .../resolved_object_list_tests.rs | 64 ++++++- .../resolved_object_result_tests.rs | 11 +- .../resolved_object/resolved_object_tests.rs | 133 +++++++++++-- .../resolved_object_type_tests.rs | 65 ++++++- .../resolved_object_with_generics_tests.rs | 34 +++- derive/tests/resolved_object/reuse_tests.rs | 18 +- derive/tests/scalar/json_tests.rs | 36 +++- derive/tests/scalar/scalar_tests.rs | 63 +++++- derive/tests/schema_data/node_data.rs | 19 +- derive/tests/schema_data/node_data_auto.rs | 19 +- derive/tests/schema_data/prepare_data.rs | 15 +- derive/tests/schema_utils.rs | 25 ++- derive/tests/simple_object/list_tests.rs | 40 +++- derive/tests/simple_object/object_tests.rs | 119 +++++++++++- derive/tests/simple_object/type_tests.rs | 64 ++++++- .../simple_object/with_generics_tests.rs | 41 +++- derive/tests/subscription.rs | 15 +- derive/tests/union/union_tests.rs | 140 +++++++++++++- derive/tests/union/with_generic_tests.rs | 28 ++- derive/tests/union/with_interface.rs | 30 ++- derive/tests/upload/upload_tests.rs | 76 +++++++- 40 files changed, 2314 insertions(+), 167 deletions(-) diff --git a/derive/tests/app.rs b/derive/tests/app.rs index f7b26a6..ce52558 100644 --- a/derive/tests/app.rs +++ b/derive/tests/app.rs @@ -25,7 +25,19 @@ fn test_app() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + other: Foo! + } + + schema { + query: Query + } + "###); } #[test] @@ -65,7 +77,19 @@ fn test_app_with_generic() { let schema = App::<()>::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + other: Foo! + } + + schema { + query: Query + } + "###); } #[test] @@ -94,7 +118,19 @@ fn test_app_with_lifetime() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + other: Foo! + } + + schema { + query: Query + } + "###); } #[test] @@ -138,7 +174,19 @@ fn test_app_with_generic_and_lifetime() { let schema = App::<()>::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + other: Foo! + } + + schema { + query: Query + } + "###); } #[test] fn test_nested_app() { @@ -167,7 +215,24 @@ fn test_nested_app() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar { + value: String! + } + + type Foo { + value: String! + } + + type Query { + foo: Foo! + bar: Bar! + } + + schema { + query: Query + } + "###); } mod test_in_mod { @@ -198,6 +263,18 @@ mod test_in_mod { async fn test() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + foo: Foo! + } + + schema { + query: Query + } + "###); } } diff --git a/derive/tests/expand_object/args_tests.rs b/derive/tests/expand_object/args_tests.rs index a43bb08..023d769 100644 --- a/derive/tests/expand_object/args_tests.rs +++ b/derive/tests/expand_object/args_tests.rs @@ -46,7 +46,20 @@ fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + foo: String! + withoutSelf: String! + withSelf: String! + withArg(name: String!): String! + withoutSelfWithArgs(name: String!): String! + unusedArg(name: String!): String! + } + + schema { + query: Query + } + "###); } #[test] @@ -91,7 +104,21 @@ fn test_schema_with_ctx() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + foo: String! + withoutUnderline: String! + withoutSelf: String! + withSelf: String! + renamed: String! + withArg(name: String!): String! + withCtxArg(ctx: String!): String! + } + + schema { + query: Query + } + "###); } #[test] @@ -125,7 +152,17 @@ fn test_schema_rename_args() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + foo: String! + withArg(THE_NAME: String!, foo: String!): String! + withFieldRename(the_name: String!, foo: String!): String! + } + + schema { + query: Query + } + "###); } #[test] @@ -157,7 +194,17 @@ fn test_schema_with_arg_ref() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + foo: String! + withoutStringRef(name: String!): String! + withStr(name: String!): String! + } + + schema { + query: Query + } + "###); } #[test] @@ -192,7 +239,18 @@ fn test_schema_with_arg_option() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + foo: String! + withoutOption(name: String!): String! + withOption(name: String): String! + withOptionRef(name: String): String! + } + + schema { + query: Query + } + "###); } #[tokio::test] diff --git a/derive/tests/expand_object/expand_object_tests.rs b/derive/tests/expand_object/expand_object_tests.rs index 0d529ef..7ea2bab 100644 --- a/derive/tests/expand_object/expand_object_tests.rs +++ b/derive/tests/expand_object/expand_object_tests.rs @@ -72,7 +72,20 @@ fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Example { + field: String! + } + + type Query { + foo: String! + theExample: Example! + } + + schema { + query: Query + } + "###); } #[test] @@ -115,7 +128,21 @@ fn test_schema_with_rename() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Example { + field: String! + } + + type Query { + foo: String! + the_example: Example! + other: Example! + } + + schema { + query: Query + } + "###); } #[test] @@ -158,7 +185,20 @@ fn test_schema_with_skip() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Example { + field: String! + } + + type Query { + foo: String! + theExample: Example! + } + + schema { + query: Query + } + "###); } #[test] @@ -201,7 +241,21 @@ fn test_schema_with_deprecation() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Example { + field: String! + } + + type Query { + foo: String! + example: Example! @deprecated + old: Example! @deprecated(reason: "this is the old one") + } + + schema { + query: Query + } + "###); } #[test] @@ -238,7 +292,23 @@ fn test_schema_with_description() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Example { + field: String! + } + + type Query { + foo: String! + """ + this is the example + """ + theExample: Example! + } + + schema { + query: Query + } + "###); } #[tokio::test] @@ -411,7 +481,28 @@ async fn test_auto_register() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Example { + field: String! + } + + input ExampleInput { + field: String! + } + + type Foo { + field: String! + } + + type Query { + foo: String! + example(input: ExampleInput): Example! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/expand_object/generic_tests.rs b/derive/tests/expand_object/generic_tests.rs index 91cdf37..12810ac 100644 --- a/derive/tests/expand_object/generic_tests.rs +++ b/derive/tests/expand_object/generic_tests.rs @@ -143,7 +143,24 @@ fn test_schema_with_generic() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar { + field: String! + } + + type Foo { + field: String! + } + + type Query { + foo: Foo! + bar: Bar! + } + + schema { + query: Query + } + "###); #[derive(App)] struct AppWithName(Query, Bar, Foo, WithName<'static, Foo>); @@ -151,7 +168,25 @@ fn test_schema_with_generic() { let schema = AppWithName::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar { + field: String! + } + + type Foo { + field: String! + name: String! + } + + type Query { + foo: Foo! + bar: Bar! + } + + schema { + query: Query + } + "###); #[derive(App)] struct AppBothWithName( @@ -165,7 +200,26 @@ fn test_schema_with_generic() { let schema = AppBothWithName::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar { + field: String! + name: String! + } + + type Foo { + field: String! + name: String! + } + + type Query { + foo: Foo! + bar: Bar! + } + + schema { + query: Query + } + "###); } #[tokio::test] diff --git a/derive/tests/expand_object/reuse_tests.rs b/derive/tests/expand_object/reuse_tests.rs index b82366a..1f79732 100644 --- a/derive/tests/expand_object/reuse_tests.rs +++ b/derive/tests/expand_object/reuse_tests.rs @@ -88,7 +88,23 @@ async fn test_base_list() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type FooList { + items(page: Int): [Foo!]! + } + + type Query { + fooList: FooList! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/gql_enum/tests.rs b/derive/tests/gql_enum/tests.rs index 747211b..a0563d8 100644 --- a/derive/tests/gql_enum/tests.rs +++ b/derive/tests/gql_enum/tests.rs @@ -76,7 +76,21 @@ async fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + enum Example { + FOO + BAR + } + + type Query { + example: Example! + byExample(example: Example!): Example! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -151,7 +165,21 @@ async fn test_rename() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + enum Other { + foo + Other + } + + type Query { + example: Other! + byExample(example: Other!): Other! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -230,7 +258,21 @@ async fn test_type_name() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + enum Other { + FOO + BAR + } + + type Query { + example: Other! + byExample(example: Other!): Other! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -304,7 +346,21 @@ async fn test_deprecation() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + enum Example { + FOO @deprecated + BAR @deprecated(reason: "This is old") + } + + type Query { + example: Example! + byExample(example: Example!): Example! + } + + schema { + query: Query + } + "###); } #[tokio::test] @@ -339,7 +395,26 @@ async fn test_doc() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + """ + the example enum + """ + enum Example { + """ + the foo item + """ FOO + BAR + } + + type Query { + example: Example! + byExample(example: Example!): Example! + } + + schema { + query: Query + } + "###); } mod in_mod { @@ -397,7 +472,21 @@ mod in_mod { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + enum Example { + FOO + BAR + } + + type Query { + example: Example! + byExample(example: Example!): Example! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/input_object/list_tests.rs b/derive/tests/input_object/list_tests.rs index 393ff18..260d85e 100644 --- a/derive/tests/input_object/list_tests.rs +++ b/derive/tests/input_object/list_tests.rs @@ -37,7 +37,19 @@ async fn test_maybe_undefined() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + theString: String + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query($input: ExampleInput) { @@ -109,7 +121,19 @@ async fn test_option() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + theString: String + } + + type Query { + example(input: ExampleInput): String! + } + + schema { + query: Query + } + "###); let query = r#" query($input: ExampleInput) { @@ -175,7 +199,19 @@ async fn test_unset() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + theString: String + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query($input: ExampleInput) { @@ -245,7 +281,19 @@ async fn test_list() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + names: [String!]! + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query($input: ExampleInput) { @@ -309,7 +357,19 @@ async fn test_optional_list() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + names: [String!] + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query($input: ExampleInput!) { @@ -384,7 +444,19 @@ async fn test_optional_items() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + names: [String]! + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query($input: ExampleInput!) { @@ -452,7 +524,19 @@ async fn test_optional_items_and_value() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + names: [String] + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query($input: ExampleInput!) { diff --git a/derive/tests/input_object/tests.rs b/derive/tests/input_object/tests.rs index 6878f3c..22bf20a 100644 --- a/derive/tests/input_object/tests.rs +++ b/derive/tests/input_object/tests.rs @@ -63,7 +63,19 @@ async fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + theString: String! + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -106,7 +118,19 @@ async fn test_schema_with_rename() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input OtherInput { + other: String! + } + + type Query { + example(input: OtherInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { example(input: { other: "hello" }) @@ -153,7 +177,19 @@ async fn test_schema_with_type_name() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input OtherInput { + theString: String! + } + + type Query { + example(input: OtherInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -197,7 +233,19 @@ async fn test_schema_with_skip() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + string: String! + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -240,7 +288,24 @@ fn test_schema_with_doc() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + """ + the example input object + """ + input ExampleInput { + """ + the string input field + """ string: String! + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); } #[tokio::test] @@ -268,7 +333,19 @@ async fn test_rename_fields() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + the_string: String! + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -320,7 +397,27 @@ async fn test_auto_register() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + foo: FooInput! + } + + type Foo { + string: String! + } + + input FooInput { + string: String! + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -382,7 +479,23 @@ mod in_mod { let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + foo: FooInput! + } + + input FooInput { + string: String! + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/input_object/type_tests.rs b/derive/tests/input_object/type_tests.rs index 6491210..446856b 100644 --- a/derive/tests/input_object/type_tests.rs +++ b/derive/tests/input_object/type_tests.rs @@ -47,7 +47,33 @@ async fn test_types() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + byString: String! + byId: ID! + byI8: Int! + byI16: Int! + byI32: Int! + byI64: Int! + byIsize: Int! + byU8: Int! + byU16: Int! + byU32: Int! + byU64: Int! + byUsize: Int! + byF32: Float! + byF64: Float! + byBool: Boolean! + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query($input: ExampleInput!) { @@ -134,7 +160,23 @@ async fn test_object_type() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + foo: FooInput! + } + + input FooInput { + value: String! + } + + type Query { + example(input: ExampleInput!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -175,7 +217,19 @@ async fn test_number() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + input ExampleInput { + value: Int! + } + + type Query { + example(input: ExampleInput!): Int! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/interface/as_value_tests.rs b/derive/tests/interface/as_value_tests.rs index 312d1c7..a0f538b 100644 --- a/derive/tests/interface/as_value_tests.rs +++ b/derive/tests/interface/as_value_tests.rs @@ -46,7 +46,24 @@ async fn interface_as_output_value_for_simple_object_with_implement() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + otherField: String! + theId: String! + } + + interface Node { + theId: String! + } + + type Query { + node: Node! + } + + schema { + query: Query + } + "###); let query = r#" @@ -108,7 +125,24 @@ async fn interface_as_output_value_for_simple_object_with_mark_with() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + theId: String! + otherField: String! + } + + interface Node { + theId: String! + } + + type Query { + node: Node! + } + + schema { + query: Query + } + "###); let query = r#" @@ -177,7 +211,24 @@ async fn interface_as_output_value_for_resolved_object_with_implement() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + otherField: String! + theId: String! + } + + interface Node { + theId: String! + } + + type Query { + node: Node! + } + + schema { + query: Query + } + "###); let query = r#" @@ -243,7 +294,24 @@ async fn interface_as_output_value_for_resolved_object_with_mark_with() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + theId: String! + otherField: String! + } + + interface Node { + theId: String! + } + + type Query { + node: Node! + } + + schema { + query: Query + } + "###); let query = r#" diff --git a/derive/tests/interface/async_test.rs b/derive/tests/interface/async_test.rs index 6f881cb..56dd722 100644 --- a/derive/tests/interface/async_test.rs +++ b/derive/tests/interface/async_test.rs @@ -51,7 +51,25 @@ async fn test_async_trait() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + interface Foo { + syncValue: String! + asyncValue: String! + } + + type FooValue implements Foo { + syncValue: String! + asyncValue: String! + } + + type Query { + foo: Foo! + } + + schema { + query: Query + } + "###); let query = r#" diff --git a/derive/tests/interface/implementation_tests.rs b/derive/tests/interface/implementation_tests.rs index 20bab60..18d1e99 100644 --- a/derive/tests/interface/implementation_tests.rs +++ b/derive/tests/interface/implementation_tests.rs @@ -31,7 +31,23 @@ fn test_schema_simple_object_mark_with() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + theId: String! + } + + interface Node { + theId: String! + } + + type Query { + foo: FooNode! + } + + schema { + query: Query + } + "###); } #[test] @@ -67,7 +83,24 @@ fn test_schema_simple_object_with_implement() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + someField: String! + theId: String! + } + + interface Node { + theId: String! + } + + type Query { + foo: FooNode! + } + + schema { + query: Query + } + "###); } #[test] @@ -130,7 +163,23 @@ fn test_schema_resolved_object_mark_with() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + theId: String! + } + + interface Node { + theId: String! + } + + type Query { + foo: FooNode! + } + + schema { + query: Query + } + "###); } #[test] @@ -169,7 +218,24 @@ fn test_schema_resolved_object_with_implement() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + otherFields: String! + theId: String! + } + + interface Node { + theId: String! + } + + type Query { + foo: FooNode! + } + + schema { + query: Query + } + "###); } #[test] diff --git a/derive/tests/interface/interface_tests.rs b/derive/tests/interface/interface_tests.rs index 3c30abd..065ab1d 100644 --- a/derive/tests/interface/interface_tests.rs +++ b/derive/tests/interface/interface_tests.rs @@ -51,7 +51,19 @@ fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + interface Node { + theId: String! + } + + type Query { + foo: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -75,7 +87,19 @@ fn test_schema_with_name() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + interface Other { + id: String! + } + + type Query { + foo: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -123,7 +147,27 @@ fn test_schema_with_type_name() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type BarNode implements Other { + theId: String! + } + + type FooNode implements Other { + theId: String! + } + + interface Other { + theId: String! + } + + type Query { + foo: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -149,7 +193,20 @@ fn test_schema_with_rename() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + interface Node { + id: String! + the_id: String! + } + + type Query { + foo: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -173,7 +230,25 @@ fn test_schema_description() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + """ + the interface + """ + interface Node { + """ + the id + """ + theId: String! + } + + type Query { + foo: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -199,7 +274,20 @@ fn test_schema_with_deprecation() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + interface Node { + theId: String! @deprecated + old: String! @deprecated(reason: "deprecated") + } + + type Query { + foo: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -223,7 +311,19 @@ fn test_schema_with_skip() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + interface Node { + theId: String! + } + + type Query { + foo: String! + } + + schema { + query: Query + } + "###); } #[tokio::test] @@ -261,7 +361,27 @@ async fn test_auto_register() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar { + id: String! + } + + type Foo { + id: String! + } + + interface GetFoo { + getFoo: Foo! + } + + type Query implements GetFoo { + getFoo: Foo! + } + + schema { + query: Query + } + "###); } #[tokio::test] @@ -318,7 +438,24 @@ async fn test_auto_register_instance() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + id: String! + } + + interface GetFoo { + getFoo: Foo! + } + + type Query implements GetFoo { + name: String! + getFoo: Foo! + } + + schema { + query: Query + } + "###); } mod in_mod { @@ -387,7 +524,30 @@ mod in_mod { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar implements Node { + id: String! + other: String! + } + + type Foo implements Node { + other: String! + id: String! + } + + interface Node { + id: String! + } + + type Query { + foo: Node! + bar: Node! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/interface/list_tests.rs b/derive/tests/interface/list_tests.rs index 7591673..1c66569 100644 --- a/derive/tests/interface/list_tests.rs +++ b/derive/tests/interface/list_tests.rs @@ -47,7 +47,24 @@ async fn test_interface_as_optional_value() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + otherField: String! + theId: String! + } + + interface Node { + theId: String! + } + + type Query { + node: Node + } + + schema { + query: Query + } + "###); let query = r#" @@ -131,7 +148,29 @@ async fn test_interface_as_list_value() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type BarNode implements Node { + anotherField: String! + theId: String! + } + + type FooNode implements Node { + otherField: String! + theId: String! + } + + interface Node { + theId: String! + } + + type Query { + nodes: [Node!]! + } + + schema { + query: Query + } + "###); let query = r#" diff --git a/derive/tests/interface/output_types_tests.rs b/derive/tests/interface/output_types_tests.rs index cfa1937..2bd3c70 100644 --- a/derive/tests/interface/output_types_tests.rs +++ b/derive/tests/interface/output_types_tests.rs @@ -62,7 +62,30 @@ async fn interface_string_ref_types() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + otherField: String! + idRef: String! + idOwned: String! + idCowBorrowed: String! + idCowOwned: String! + } + + interface Node { + idRef: String! + idOwned: String! + idCowBorrowed: String! + idCowOwned: String! + } + + type Query { + node: Node! + } + + schema { + query: Query + } + "###); let query = r#" @@ -157,7 +180,34 @@ async fn interface_object_ref_types() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar { + value: String! + } + + interface Baz { + barRef: Bar! + barOwned: Bar! + barCowBorrowed: Bar! + barCowOwned: Bar! + } + + type FooNode implements Baz { + otherField: String! + barRef: Bar! + barOwned: Bar! + barCowBorrowed: Bar! + barCowOwned: Bar! + } + + type Query { + baz: Baz! + } + + schema { + query: Query + } + "###); let query = r#" diff --git a/derive/tests/mutation/mutation_tests.rs b/derive/tests/mutation/mutation_tests.rs index f173dfe..8aada9d 100644 --- a/derive/tests/mutation/mutation_tests.rs +++ b/derive/tests/mutation/mutation_tests.rs @@ -80,7 +80,20 @@ fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type MutationRoot { + theExample: String! + } + + type Query { + foo: String! + } + + schema { + query: Query + mutation: MutationRoot + } + "###); } #[test] @@ -111,7 +124,20 @@ fn test_schema_with_rename() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Mutation { + theExample: String! + } + + type Query { + foo: String! + } + + schema { + query: Query + mutation: Mutation + } + "###); } #[test] @@ -148,7 +174,20 @@ fn test_schema_with_type_name() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Mutation { + theExample: String! + } + + type Query { + foo: String! + } + + schema { + query: Query + mutation: Mutation + } + "###); } #[test] @@ -179,7 +218,23 @@ fn test_schema_with_doc() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + """ + The Root of all Mutations + """ + type MutationRoot { + theExample: String! + } + + type Query { + foo: String! + } + + schema { + query: Query + mutation: MutationRoot + } + "###); } #[tokio::test] @@ -280,7 +335,36 @@ async fn test_auto_register() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar { + bar: String! + } + + input ExampleInput { + foo: String! + } + + type ExamplePayload { + bar: String! + } + + type Foo { + foo: String! + } + + type MutationRoot { + theExample(input: ExampleInput!): ExamplePayload! + } + + type Query { + foo: String! + } + + schema { + query: Query + mutation: MutationRoot + } + "###); let query = r#" mutation { diff --git a/derive/tests/registry.rs b/derive/tests/registry.rs index 80e35a4..742702b 100644 --- a/derive/tests/registry.rs +++ b/derive/tests/registry.rs @@ -49,7 +49,19 @@ async fn test_app() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + foo: Foo + } + + schema { + query: Query + } + "###); let result = schema .execute("{ foo { value } }") @@ -87,7 +99,19 @@ async fn test_apply() { let schema = schema.finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + foo: Foo + } + + schema { + query: Query + } + "###); let result = schema .execute("{ foo { value } }") @@ -160,7 +184,19 @@ async fn define_custom_type() { // use schema let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + foo: Foo! + } + + schema { + query: Query + } + "###); let root = Query { foo: Foo { diff --git a/derive/tests/resolved_object/resolved_object_args_tests.rs b/derive/tests/resolved_object/resolved_object_args_tests.rs index 2cc34f7..3b2444c 100644 --- a/derive/tests/resolved_object/resolved_object_args_tests.rs +++ b/derive/tests/resolved_object/resolved_object_args_tests.rs @@ -41,7 +41,19 @@ fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + withoutSelf: String! + withSelf: String! + withArg(name: String!): String! + withoutSelfWithArgs(name: String!): String! + unusedArg(name: String!): String! + } + + schema { + query: Query + } + "###); } #[test] @@ -79,7 +91,20 @@ fn test_schema_with_ctx() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + withoutUnderline: String! + withoutSelf: String! + withSelf: String! + renamed: String! + withArg(name: String!): String! + withCtxArg(ctx: String!): String! + } + + schema { + query: Query + } + "###); } #[test] @@ -106,7 +131,16 @@ fn test_schema_rename_args() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + withArg(THE_NAME: String!, foo: String!): String! + withFieldRename(the_name: String!, foo: String!): String! + } + + schema { + query: Query + } + "###); } #[test] @@ -131,7 +165,16 @@ fn test_schema_with_arg_ref() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + withoutStringRef(name: String!): String! + withStr(name: String!): String! + } + + schema { + query: Query + } + "###); } #[test] @@ -159,7 +202,17 @@ fn test_schema_with_arg_option() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + withoutOption(name: String!): String! + withOption(name: String): String! + withOptionRef(name: String): String! + } + + schema { + query: Query + } + "###); } #[tokio::test] @@ -577,7 +630,15 @@ async fn test_query_numbers() { let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + byU8(name: Int!): String! + } + + schema { + query: Query + } + "###); let query = r#"{ byU8(name: 1) diff --git a/derive/tests/resolved_object/resolved_object_list_args_tests.rs b/derive/tests/resolved_object/resolved_object_list_args_tests.rs index 6897c94..d47fd8b 100644 --- a/derive/tests/resolved_object/resolved_object_list_args_tests.rs +++ b/derive/tests/resolved_object/resolved_object_list_args_tests.rs @@ -28,7 +28,16 @@ async fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + hello(names: [String!]!): String! + helloWithRef(names: [String!]!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -83,7 +92,16 @@ async fn test_schema_optional_arg() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + helloWithOptionalArg(names: [String!]): String! + helloWithOptionalArgRef(names: [String!]): String! + } + + schema { + query: Query + } + "###); let query = r#" query($names: [String!]) { helloWithOptionalArg(names: $names) @@ -155,7 +173,16 @@ async fn test_schema_optional_item() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + helloWithOptionalItem(names: [String]!): String! + helloWithOptionalItemRef(names: [String]!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { helloWithOptionalItem(names: ["world", null, "rust"]) @@ -217,7 +244,16 @@ async fn test_schema_optional_item_and_arg() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + helloWithOptionalItemAndArg(names: [String]): String! + helloWithOptionalItemAndArgRef(names: [String]): String! + } + + schema { + query: Query + } + "###); let query = r#" query($names: [String]) { helloWithOptionalItemAndArg(names: $names) diff --git a/derive/tests/resolved_object/resolved_object_list_tests.rs b/derive/tests/resolved_object/resolved_object_list_tests.rs index f720c3a..167eb5b 100644 --- a/derive/tests/resolved_object/resolved_object_list_tests.rs +++ b/derive/tests/resolved_object/resolved_object_list_tests.rs @@ -36,7 +36,18 @@ async fn test_list() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + strings: [String!]! + newStrings: [String!]! + stringsRef: [String!]! + refItems: [String!]! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -110,7 +121,22 @@ async fn test_list_object() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Item { + name: String! + } + + type Query { + items: [Item!]! + newItems: [Item!]! + itemsRef: [Item!]! + refItems: [Item!]! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -176,7 +202,16 @@ async fn test_optional_list() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + maybeListOfStrings: [String!] + newMaybeListOfStrings: [String!] + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -238,7 +273,17 @@ async fn test_list_of_optional() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + listOfMaybeStrings: [String]! + newListOfMaybeStrings: [String]! + listOfMaybeStringsRef: [String]! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -290,7 +335,16 @@ async fn test_optional_list_of_optional() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + maybeListOfMaybeStrings: [String] + newMaybeListOfMaybeStrings: [String] + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/resolved_object/resolved_object_result_tests.rs b/derive/tests/resolved_object/resolved_object_result_tests.rs index aac45d3..ad91fd7 100644 --- a/derive/tests/resolved_object/resolved_object_result_tests.rs +++ b/derive/tests/resolved_object/resolved_object_result_tests.rs @@ -35,7 +35,16 @@ fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + string: String! + maybeString: String + } + + schema { + query: Query + } + "###); } #[tokio::test] diff --git a/derive/tests/resolved_object/resolved_object_tests.rs b/derive/tests/resolved_object/resolved_object_tests.rs index 02b6fa0..af012e3 100644 --- a/derive/tests/resolved_object/resolved_object_tests.rs +++ b/derive/tests/resolved_object/resolved_object_tests.rs @@ -52,7 +52,15 @@ fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + theString: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -76,7 +84,15 @@ fn test_schema_with_rename() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Other { + other: String! + } + + schema { + query: Other + } + "###); } #[test] @@ -104,7 +120,15 @@ fn test_schema_with_type_name() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Other { + theString: String! + } + + schema { + query: Other + } + "###); } #[test] @@ -131,7 +155,15 @@ fn test_schema_with_skip() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + string: String! + } + + schema { + query: Query + } + "###); } #[tokio::test] @@ -161,7 +193,17 @@ async fn test_query() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + string: String! + value: String! + other: String! + } + + schema { + query: Query + } + "###); let query = r#" query { string @@ -211,7 +253,21 @@ fn test_schema_with_doc() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + """ + this is the query object + """ + type Query { + """ + this is the string field + """ + string: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -238,7 +294,16 @@ fn test_schema_with_deprecation() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + deprecated: String! @deprecated + withReason: String! @deprecated(reason: "this is the old one") + } + + schema { + query: Query + } + "###); } #[test] @@ -262,7 +327,15 @@ fn test_rename_fields() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type TheQuery { + the_string: String! + } + + schema { + query: TheQuery + } + "###); } #[tokio::test] @@ -292,7 +365,17 @@ async fn test_async_query() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + string: String! + value: String! + other: String! + } + + schema { + query: Query + } + "###); let query = r#" query { string @@ -355,7 +438,27 @@ async fn test_auto_register() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Example { + value: String! + } + + input ExampleInput { + value: String! + } + + type Foo { + value: String! + } + + type Query { + example(input: ExampleInput!): Example! + } + + schema { + query: Query + } + "###); let query = r#" query { example(input: {value: "Hello"}) { @@ -411,6 +514,14 @@ mod in_mod { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + theString: String! + } + + schema { + query: Query + } + "###); } } diff --git a/derive/tests/resolved_object/resolved_object_type_tests.rs b/derive/tests/resolved_object/resolved_object_type_tests.rs index 4498eb4..1fcf600 100644 --- a/derive/tests/resolved_object/resolved_object_type_tests.rs +++ b/derive/tests/resolved_object/resolved_object_type_tests.rs @@ -89,7 +89,30 @@ async fn test_types() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + string: String! + str: String! + id: ID! + i8: Int! + i16: Int! + i32: Int! + i64: Int! + isize: Int! + u8: Int! + u16: Int! + u32: Int! + u64: Int! + usize: Int! + f32: Float! + f64: Float! + bool: Boolean! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -222,7 +245,30 @@ async fn test_optional_types() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + string: String + str: String + id: ID + i8: Int + i16: Int + i32: Int + i64: Int + isize: Int + u8: Int + u16: Int + u32: Int + u64: Int + usize: Int + f32: Float + f64: Float + bool: Boolean + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -348,7 +394,20 @@ async fn test_object_output() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + foo: Foo! + newFoo: Foo! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/resolved_object/resolved_object_with_generics_tests.rs b/derive/tests/resolved_object/resolved_object_with_generics_tests.rs index f423c6c..04bc4da 100644 --- a/derive/tests/resolved_object/resolved_object_with_generics_tests.rs +++ b/derive/tests/resolved_object/resolved_object_with_generics_tests.rs @@ -41,7 +41,15 @@ async fn test_query_static_generic() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + greet(name: String!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -88,7 +96,15 @@ async fn test_query_generic_with_self() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + greet(name: String!): String! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -138,7 +154,19 @@ async fn test_query_graphql_generic() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + theG: Foo! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/resolved_object/reuse_tests.rs b/derive/tests/resolved_object/reuse_tests.rs index ee87493..a4917e1 100644 --- a/derive/tests/resolved_object/reuse_tests.rs +++ b/derive/tests/resolved_object/reuse_tests.rs @@ -97,7 +97,23 @@ async fn test_base_list() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type FooList { + items(page: Int): [Foo!]! + } + + type Query { + fooList: FooList! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/scalar/json_tests.rs b/derive/tests/scalar/json_tests.rs index d0c0973..663de73 100644 --- a/derive/tests/scalar/json_tests.rs +++ b/derive/tests/scalar/json_tests.rs @@ -21,7 +21,17 @@ async fn json_input_output() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + scalar JsonValue + + type Query { + value(value: JsonValue!): JsonValue! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -71,7 +81,17 @@ async fn json_object_test() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + scalar JsonObject + + type Query { + value(value: JsonObject!): JsonObject! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -128,7 +148,17 @@ async fn json_key_value() { let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + scalar KeyValue + + type Query { + value(value: KeyValue!): KeyValue! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/scalar/scalar_tests.rs b/derive/tests/scalar/scalar_tests.rs index 0080101..888a93f 100644 --- a/derive/tests/scalar/scalar_tests.rs +++ b/derive/tests/scalar/scalar_tests.rs @@ -81,7 +81,17 @@ fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + scalar MyString + + type Query { + value: MyString! + } + + schema { + query: Query + } + "###); } #[test] @@ -118,7 +128,17 @@ fn test_schema_scalar_as_input() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + scalar MyString + + type Query { + value(value: MyString!): String! + } + + schema { + query: Query + } + "###); } #[test] @@ -151,7 +171,17 @@ fn test_schema_with_rename() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + scalar OtherString + + type Query { + value: OtherString! + } + + schema { + query: Query + } + "###); } #[test] @@ -190,7 +220,17 @@ fn test_schema_with_type_name() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + scalar OtherString + + type Query { + value: OtherString! + } + + schema { + query: Query + } + "###); } #[test] @@ -223,7 +263,20 @@ fn test_schema_with_doc() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + """ + this is my special string + """ + scalar MyString + + type Query { + value: MyString! + } + + schema { + query: Query + } + "###); } #[test] diff --git a/derive/tests/schema_data/node_data.rs b/derive/tests/schema_data/node_data.rs index 990512a..cef3209 100644 --- a/derive/tests/schema_data/node_data.rs +++ b/derive/tests/schema_data/node_data.rs @@ -135,7 +135,24 @@ struct App(Query, NodeQuery<'static>, foo::FooNode); async fn test() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + name: String! + id: String! + } + + interface Node { + id: String! + } + + type Query { + node(id: String!): Node + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/schema_data/node_data_auto.rs b/derive/tests/schema_data/node_data_auto.rs index eec4642..d4a74dc 100644 --- a/derive/tests/schema_data/node_data_auto.rs +++ b/derive/tests/schema_data/node_data_auto.rs @@ -139,7 +139,24 @@ struct App(Query, NodeQuery<'static>, foo::FooNode); async fn test() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type FooNode implements Node { + name: String! + id: String! + } + + interface Node { + id: String! + } + + type Query { + node(id: String!): Node + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/schema_data/prepare_data.rs b/derive/tests/schema_data/prepare_data.rs index 0757c4c..13105bb 100644 --- a/derive/tests/schema_data/prepare_data.rs +++ b/derive/tests/schema_data/prepare_data.rs @@ -135,7 +135,20 @@ mod expand_example { async fn test() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Example { + value: Int! + anotherValue: Int! + } + + type Query { + example: Example! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/schema_utils.rs b/derive/tests/schema_utils.rs index f788df2..e902b5e 100644 --- a/derive/tests/schema_utils.rs +++ b/derive/tests/schema_utils.rs @@ -1,6 +1,6 @@ pub fn normalize_schema(sdl: &str) -> String { format!( - "\n{}", + "{}", graphql_parser::schema::parse_schema::(sdl) .unwrap() .to_owned() @@ -24,19 +24,16 @@ mod tests { schema { query: Query } "; - assert_eq!( - normalize_schema(sdl), - " -type Query { - hello: String! - nice: String! - bye: String! -} + insta::assert_snapshot!(normalize_schema(sdl), @r###" + type Query { + hello: String! + nice: String! + bye: String! + } -schema { - query: Query -} -" - ); + schema { + query: Query + } + "###); } } diff --git a/derive/tests/simple_object/list_tests.rs b/derive/tests/simple_object/list_tests.rs index a488269..2f2c875 100644 --- a/derive/tests/simple_object/list_tests.rs +++ b/derive/tests/simple_object/list_tests.rs @@ -20,7 +20,15 @@ async fn test_list() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + strings: [String!]! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -59,7 +67,15 @@ async fn test_optional_list() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + maybeListOfStrings: [String!] + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -103,7 +119,15 @@ async fn test_list_of_optional() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + listOfMaybeStrings: [String]! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -138,7 +162,15 @@ async fn test_optional_list_of_optional() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + maybeListOfMaybeStrings: [String] + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/simple_object/object_tests.rs b/derive/tests/simple_object/object_tests.rs index 41fceb4..53b05a4 100644 --- a/derive/tests/simple_object/object_tests.rs +++ b/derive/tests/simple_object/object_tests.rs @@ -57,7 +57,15 @@ fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + string: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -74,7 +82,15 @@ fn test_schema_with_rename() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Other { + string: String! + } + + schema { + query: Other + } + "###); } #[test] @@ -98,7 +114,15 @@ fn test_schema_with_type_name() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Other { + string: String! + } + + schema { + query: Other + } + "###); } #[test] @@ -117,7 +141,15 @@ fn test_schema_with_skip() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + string: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -135,7 +167,15 @@ fn test_schema_with_rename_field() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + other: String! + } + + schema { + query: Query + } + "###); } #[tokio::test] @@ -179,7 +219,15 @@ async fn test_optional() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + maybeString: String + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -219,7 +267,21 @@ fn test_schema_with_doc() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + """ + this is the query object + """ + type Query { + """ + this is the string field + """ + string: String! + } + + schema { + query: Query + } + "###); } #[test] @@ -239,7 +301,16 @@ fn test_schema_with_deprecation() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + deprecated: String! @deprecated + withReason: String! @deprecated(reason: "this is the old one") + } + + schema { + query: Query + } + "###); } #[test] @@ -257,7 +328,15 @@ fn test_rename_fields() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type TheQuery { + the_string: String! + } + + schema { + query: TheQuery + } + "###); } #[tokio::test] @@ -290,7 +369,27 @@ async fn test_auto_register() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar { + foo: Foo! + } + + type Example { + string: String! + } + + type Foo { + string: String! + } + + type Query { + example: Example! + } + + schema { + query: Query + } + "###); } mod in_mod { diff --git a/derive/tests/simple_object/type_tests.rs b/derive/tests/simple_object/type_tests.rs index 325b7f3..f501798 100644 --- a/derive/tests/simple_object/type_tests.rs +++ b/derive/tests/simple_object/type_tests.rs @@ -35,7 +35,30 @@ async fn test_types() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + string: String! + str: String! + id: ID! + i8: Int! + i16: Int! + i32: Int! + i64: Int! + isize: Int! + u8: Int! + u16: Int! + u32: Int! + u64: Int! + usize: Int! + f32: Float! + f64: Float! + bool: Boolean! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -116,7 +139,30 @@ async fn test_optional_types() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + string: String + str: String + id: ID + i8: Int + i16: Int + i32: Int + i64: Int + isize: Int + u8: Int + u16: Int + u32: Int + u64: Int + usize: Int + f32: Float + f64: Float + bool: Boolean + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -230,7 +276,19 @@ async fn test_object_output() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + foo: Foo! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/simple_object/with_generics_tests.rs b/derive/tests/simple_object/with_generics_tests.rs index f650ed1..c17aa50 100644 --- a/derive/tests/simple_object/with_generics_tests.rs +++ b/derive/tests/simple_object/with_generics_tests.rs @@ -35,7 +35,19 @@ async fn test_query_simple_generic() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Foo { + value: String! + } + + type Query { + field: Foo! + } + + schema { + query: Query + } + "###); let query = r#" query { @@ -102,7 +114,32 @@ async fn test_query_generic_with_type_name() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar { + bar: String! + } + + type BoxBar { + inner: Bar! + } + + type BoxFoo { + inner: Foo! + } + + type Foo { + foo: String! + } + + type Query { + foo: BoxFoo! + bar: BoxBar! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/subscription.rs b/derive/tests/subscription.rs index c617a46..455dd63 100644 --- a/derive/tests/subscription.rs +++ b/derive/tests/subscription.rs @@ -44,7 +44,20 @@ async fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Query { + foo: String! + } + + type Subscription { + foo: String! + } + + schema { + query: Query + subscription: Subscription + } + "###); let mut stream = schema.execute_stream("subscription { foo }"); for i in 0..10 { diff --git a/derive/tests/union/union_tests.rs b/derive/tests/union/union_tests.rs index 0c30699..e34c5a0 100644 --- a/derive/tests/union/union_tests.rs +++ b/derive/tests/union/union_tests.rs @@ -94,7 +94,27 @@ fn test_schema() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + union Animal = Dog | Cat + + type Cat { + name: String! + life: Int! + } + + type Dog { + name: String! + power: Int! + } + + type Query { + pet: Animal! + } + + schema { + query: Query + } + "###); } #[test] @@ -131,7 +151,27 @@ fn test_schema_with_rename() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Cat { + name: String! + life: Int! + } + + type Dog { + name: String! + power: Int! + } + + union Other = Dog | Cat + + type Query { + pet: Other! + } + + schema { + query: Query + } + "###); } #[test] @@ -174,7 +214,27 @@ fn test_schema_with_type_name() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Cat { + name: String! + life: Int! + } + + type Dog { + name: String! + power: Int! + } + + union Other = Dog | Cat + + type Query { + pet: Other! + } + + schema { + query: Query + } + "###); } #[test] @@ -212,7 +272,30 @@ fn test_schema_with_doc() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Cat { + name: String! + life: Int! + } + + type Dog { + name: String! + power: Int! + } + + """ + Some animal + """ + union Other = Dog | Cat + + type Query { + pet: Other! + } + + schema { + query: Query + } + "###); } #[tokio::test] @@ -388,7 +471,32 @@ async fn test_auto_register() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + union Animal = Dog | Cat + + type Bird { + name: String! + fly: Boolean! + } + + type Cat { + name: String! + life: Int! + } + + type Dog { + name: String! + power: Int! + } + + type Query { + pet: Animal! + } + + schema { + query: Query + } + "###); } mod in_mod { @@ -442,7 +550,27 @@ mod in_mod { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + union Animal = Dog | Cat + + type Cat { + name: String! + life: Int! + } + + type Dog { + name: String! + power: Int! + } + + type Query { + pet: Animal! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/union/with_generic_tests.rs b/derive/tests/union/with_generic_tests.rs index 3d5b603..7edc9b8 100644 --- a/derive/tests/union/with_generic_tests.rs +++ b/derive/tests/union/with_generic_tests.rs @@ -92,7 +92,33 @@ async fn test_query_simple_generic() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type Bar { + bar: String! + } + + type BoxBar { + inner: Bar! + } + + type BoxFoo { + inner: Foo! + } + + type Foo { + foo: String! + } + + union FooBar = Foo | Bar | BoxFoo | BoxBar + + type Query { + box: FooBar! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/union/with_interface.rs b/derive/tests/union/with_interface.rs index 0d48a8d..51e2b9d 100644 --- a/derive/tests/union/with_interface.rs +++ b/derive/tests/union/with_interface.rs @@ -53,7 +53,35 @@ async fn test_query() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + union Animal = Dog | Cat | Snake + + type Cat implements Named { + name: String! + life: Int! + } + + type Dog implements Named { + name: String! + power: Int! + } + + interface Named { + name: String! + } + + type Query { + pet: Animal! + } + + type Snake { + length: Int! + } + + schema { + query: Query + } + "###); let query = r#" query { diff --git a/derive/tests/upload/upload_tests.rs b/derive/tests/upload/upload_tests.rs index ea3d243..127cd99 100644 --- a/derive/tests/upload/upload_tests.rs +++ b/derive/tests/upload/upload_tests.rs @@ -64,7 +64,22 @@ async fn test_arg() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type MutationRoot { + test(file: Upload!): String! + } + + type Query { + foo: String! + } + + scalar Upload + + schema { + query: Query + mutation: MutationRoot + } + "###); let query = r##" mutation($file: Upload!) { @@ -126,7 +141,26 @@ async fn test_input_object() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type MutationRoot { + test(input: UploadInput!): String! + } + + type Query { + foo: String! + } + + scalar Upload + + input UploadInput { + file: Upload! + } + + schema { + query: Query + mutation: MutationRoot + } + "###); let query = r##" mutation($input: UploadInput!) { @@ -186,7 +220,22 @@ async fn test_arg_optional() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type MutationRoot { + test(file: Upload): String! + } + + type Query { + foo: String! + } + + scalar Upload + + schema { + query: Query + mutation: MutationRoot + } + "###); let query = r##" mutation($file: Upload!) { @@ -260,7 +309,26 @@ async fn test_input_object_optional() { let schema = App::create_schema().finish().unwrap(); let sdl = schema.sdl(); - insta::assert_snapshot!(normalize_schema(&sdl), @""); + insta::assert_snapshot!(normalize_schema(&sdl), @r###" + type MutationRoot { + test(input: UploadInput!): String! + } + + type Query { + foo: String! + } + + scalar Upload + + input UploadInput { + file: Upload + } + + schema { + query: Query + mutation: MutationRoot + } + "###); let query = r##" mutation($input: UploadInput!) {