├── .codespellrc ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── support-request.md ├── dependabot.yml └── workflows │ └── ci.yml ├── .gitignore ├── .rustfmt.toml ├── CONTRIBUTING.md ├── Cargo.toml ├── LICENSE ├── Makefile ├── README.md ├── RELEASING.md ├── assets └── logo │ ├── README.md │ ├── juniper-dark-word.png │ ├── juniper-dark-word.svg │ ├── juniper-dark.png │ ├── juniper-dark.svg │ ├── juniper-light-word.png │ ├── juniper-light-word.svg │ ├── juniper-light.png │ ├── juniper-light.svg │ ├── juniper-mono-word.png │ ├── juniper-mono-word.svg │ ├── juniper-mono.png │ └── juniper-mono.svg ├── benches ├── Cargo.toml ├── benches │ └── benchmark.rs └── src │ └── lib.rs ├── book ├── .gitignore ├── Cargo.toml ├── README.md ├── book.toml └── src │ ├── SUMMARY.md │ ├── advanced │ ├── dataloader.md │ ├── eager_loading.md │ ├── implicit_and_explicit_null.md │ ├── index.md │ ├── lookahead.md │ └── n_plus_1.md │ ├── introduction.md │ ├── lib.rs │ ├── quickstart.md │ ├── schema │ ├── index.md │ ├── introspection.md │ └── subscriptions.md │ ├── serve │ ├── batching.md │ └── index.md │ ├── styles │ └── website.css │ └── types │ ├── enums.md │ ├── index.md │ ├── input_objects.md │ ├── interfaces.md │ ├── objects │ ├── complex_fields.md │ ├── context.md │ ├── error │ │ ├── field.md │ │ ├── index.md │ │ └── schema.md │ ├── generics.md │ └── index.md │ ├── scalars.md │ └── unions.md ├── juniper ├── .gitignore ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── Makefile ├── README.md ├── benches │ └── bench.rs ├── package.json ├── release.toml └── src │ ├── ast.rs │ ├── executor │ ├── look_ahead.rs │ ├── mod.rs │ └── owned_executor.rs │ ├── executor_tests │ ├── async_await │ │ └── mod.rs │ ├── directives.rs │ ├── enums.rs │ ├── executor.rs │ ├── interfaces_unions.rs │ ├── introspection │ │ ├── enums.rs │ │ ├── input_object.rs │ │ └── mod.rs │ ├── mod.rs │ └── variables.rs │ ├── http │ ├── graphiql.html │ ├── graphiql.js │ ├── graphiql.rs │ ├── mod.rs │ ├── playground.html │ └── playground.rs │ ├── integrations │ ├── anyhow.rs │ ├── bigdecimal.rs │ ├── bson.rs │ ├── chrono.rs │ ├── chrono_tz.rs │ ├── jiff.rs │ ├── mod.rs │ ├── rust_decimal.rs │ ├── serde.rs │ ├── time.rs │ ├── url.rs │ └── uuid.rs │ ├── introspection │ ├── mod.rs │ ├── query.graphql │ └── query_without_descriptions.graphql │ ├── lib.rs │ ├── macros │ ├── graphql_input_value.rs │ ├── graphql_value.rs │ ├── graphql_vars.rs │ ├── helper │ │ ├── mod.rs │ │ └── subscription.rs │ ├── mod.rs │ └── reflect.rs │ ├── parser │ ├── document.rs │ ├── lexer.rs │ ├── mod.rs │ ├── parser.rs │ ├── tests │ │ ├── document.rs │ │ ├── lexer.rs │ │ ├── mod.rs │ │ └── value.rs │ ├── utils.rs │ └── value.rs │ ├── schema │ ├── meta.rs │ ├── mod.rs │ ├── model.rs │ ├── schema.rs │ └── translate │ │ ├── graphql_parser.rs │ │ └── mod.rs │ ├── tests │ ├── fixtures │ │ ├── mod.rs │ │ └── starwars │ │ │ ├── mod.rs │ │ │ ├── schema.rs │ │ │ ├── schema_language.rs │ │ │ └── starwars.graphql │ ├── introspection_tests.rs │ ├── mod.rs │ ├── query_tests.rs │ ├── schema_introspection.rs │ ├── subscriptions.rs │ └── type_info_tests.rs │ ├── types │ ├── async_await.rs │ ├── base.rs │ ├── containers.rs │ ├── marker.rs │ ├── mod.rs │ ├── name.rs │ ├── nullable.rs │ ├── pointers.rs │ ├── scalars.rs │ ├── subscriptions.rs │ └── utilities.rs │ ├── util.rs │ ├── validation │ ├── context.rs │ ├── input_value.rs │ ├── mod.rs │ ├── multi_visitor.rs │ ├── rules │ │ ├── arguments_of_correct_type.rs │ │ ├── default_values_of_correct_type.rs │ │ ├── disable_introspection.rs │ │ ├── fields_on_correct_type.rs │ │ ├── fragments_on_composite_types.rs │ │ ├── known_argument_names.rs │ │ ├── known_directives.rs │ │ ├── known_fragment_names.rs │ │ ├── known_type_names.rs │ │ ├── lone_anonymous_operation.rs │ │ ├── mod.rs │ │ ├── no_fragment_cycles.rs │ │ ├── no_undefined_variables.rs │ │ ├── no_unused_fragments.rs │ │ ├── no_unused_variables.rs │ │ ├── overlapping_fields_can_be_merged.rs │ │ ├── possible_fragment_spreads.rs │ │ ├── provided_non_null_arguments.rs │ │ ├── scalar_leafs.rs │ │ ├── unique_argument_names.rs │ │ ├── unique_fragment_names.rs │ │ ├── unique_input_field_names.rs │ │ ├── unique_operation_names.rs │ │ ├── unique_variable_names.rs │ │ ├── variables_are_input_types.rs │ │ └── variables_in_allowed_position.rs │ ├── test_harness.rs │ ├── traits.rs │ └── visitor.rs │ └── value │ ├── mod.rs │ ├── object.rs │ └── scalar.rs ├── juniper_actix ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── examples │ └── subscription.rs ├── release.toml └── src │ └── lib.rs ├── juniper_axum ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── examples │ ├── custom.rs │ └── simple.rs ├── release.toml ├── src │ ├── extract.rs │ ├── lib.rs │ ├── response.rs │ └── subscriptions.rs └── tests │ ├── http_test_suite.rs │ └── ws_test_suite.rs ├── juniper_codegen ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── release.toml └── src │ ├── common │ ├── default.rs │ ├── deprecation.rs │ ├── description.rs │ ├── diagnostic.rs │ ├── field │ │ ├── arg.rs │ │ └── mod.rs │ ├── generate.rs │ ├── mod.rs │ ├── parse │ │ ├── attr.rs │ │ ├── downcaster.rs │ │ └── mod.rs │ ├── rename.rs │ ├── scalar.rs │ └── span_container.rs │ ├── graphql_enum │ ├── derive.rs │ └── mod.rs │ ├── graphql_input_object │ ├── derive.rs │ └── mod.rs │ ├── graphql_interface │ ├── attr.rs │ ├── derive.rs │ └── mod.rs │ ├── graphql_object │ ├── attr.rs │ ├── derive.rs │ └── mod.rs │ ├── graphql_scalar │ ├── attr.rs │ ├── derive.rs │ └── mod.rs │ ├── graphql_subscription │ ├── attr.rs │ └── mod.rs │ ├── graphql_union │ ├── attr.rs │ ├── derive.rs │ └── mod.rs │ ├── lib.rs │ └── scalar_value │ └── mod.rs ├── juniper_graphql_ws ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── release.toml └── src │ ├── graphql_transport_ws │ ├── client_message.rs │ ├── mod.rs │ └── server_message.rs │ ├── graphql_ws │ ├── client_message.rs │ ├── mod.rs │ └── server_message.rs │ ├── lib.rs │ ├── schema.rs │ ├── server_message.rs │ └── util.rs ├── juniper_hyper ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── examples │ └── hyper_server.rs ├── release.toml └── src │ └── lib.rs ├── juniper_rocket ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── examples │ └── simple.rs ├── release.toml ├── src │ └── lib.rs └── tests │ ├── custom_response_tests.rs │ └── http_test_suite.rs ├── juniper_subscriptions ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── examples │ └── basic.rs ├── release.toml └── src │ └── lib.rs ├── juniper_warp ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── examples │ └── subscription.rs ├── release.toml ├── src │ ├── lib.rs │ ├── response.rs │ └── subscriptions.rs └── tests │ └── http_test_suite.rs ├── release.toml └── tests ├── codegen ├── Cargo.toml ├── fail │ ├── enum │ │ ├── derive_duplicated_value_names.rs │ │ ├── derive_duplicated_value_names.stderr │ │ ├── derive_name_double_underscored.rs │ │ ├── derive_name_double_underscored.stderr │ │ ├── derive_no_values.rs │ │ ├── derive_no_values.stderr │ │ ├── derive_variant_with_field.rs │ │ ├── derive_variant_with_field.stderr │ │ ├── derive_wrong_item.rs │ │ └── derive_wrong_item.stderr │ ├── input-object │ │ ├── derive_incompatible_field_type.rs │ │ ├── derive_incompatible_field_type.stderr │ │ ├── derive_no_fields.rs │ │ ├── derive_no_fields.stderr │ │ ├── derive_no_underscore.rs │ │ ├── derive_no_underscore.stderr │ │ ├── derive_unique_name.rs │ │ └── derive_unique_name.stderr │ ├── interface │ │ ├── attr_wrong_item.rs │ │ ├── attr_wrong_item.stderr │ │ ├── derive_wrong_item.rs │ │ ├── derive_wrong_item.stderr │ │ ├── struct │ │ │ ├── attr_additional_non_nullable_argument.rs │ │ │ ├── attr_additional_non_nullable_argument.stderr │ │ │ ├── attr_cyclic_impl.rs │ │ │ ├── attr_cyclic_impl.stderr │ │ │ ├── attr_field_double_underscored.rs │ │ │ ├── attr_field_double_underscored.stderr │ │ │ ├── attr_field_non_output_return_type.rs │ │ │ ├── attr_field_non_output_return_type.stderr │ │ │ ├── attr_fields_duplicate.rs │ │ │ ├── attr_fields_duplicate.stderr │ │ │ ├── attr_implementers_duplicate_pretty.rs │ │ │ ├── attr_implementers_duplicate_pretty.stderr │ │ │ ├── attr_implementers_duplicate_ugly.rs │ │ │ ├── attr_implementers_duplicate_ugly.stderr │ │ │ ├── attr_missing_field.rs │ │ │ ├── attr_missing_field.stderr │ │ │ ├── attr_missing_for_attr.rs │ │ │ ├── attr_missing_for_attr.stderr │ │ │ ├── attr_missing_impl_attr.rs │ │ │ ├── attr_missing_impl_attr.stderr │ │ │ ├── attr_missing_transitive_impl.rs │ │ │ ├── attr_missing_transitive_impl.stderr │ │ │ ├── attr_name_double_underscored.rs │ │ │ ├── attr_name_double_underscored.stderr │ │ │ ├── attr_no_fields.rs │ │ │ ├── attr_no_fields.stderr │ │ │ ├── attr_non_subtype_return.rs │ │ │ ├── attr_non_subtype_return.stderr │ │ │ ├── attr_unnamed_field.rs │ │ │ ├── attr_unnamed_field.stderr │ │ │ ├── derive_additional_non_nullable_argument.rs │ │ │ ├── derive_additional_non_nullable_argument.stderr │ │ │ ├── derive_cyclic_impl.rs │ │ │ ├── derive_cyclic_impl.stderr │ │ │ ├── derive_field_double_underscored.rs │ │ │ ├── derive_field_double_underscored.stderr │ │ │ ├── derive_field_non_output_return_type.rs │ │ │ ├── derive_field_non_output_return_type.stderr │ │ │ ├── derive_fields_duplicate.rs │ │ │ ├── derive_fields_duplicate.stderr │ │ │ ├── derive_implementers_duplicate_pretty.rs │ │ │ ├── derive_implementers_duplicate_pretty.stderr │ │ │ ├── derive_implementers_duplicate_ugly.rs │ │ │ ├── derive_implementers_duplicate_ugly.stderr │ │ │ ├── derive_missing_field.rs │ │ │ ├── derive_missing_field.stderr │ │ │ ├── derive_missing_for_attr.rs │ │ │ ├── derive_missing_for_attr.stderr │ │ │ ├── derive_missing_impl_attr.rs │ │ │ ├── derive_missing_impl_attr.stderr │ │ │ ├── derive_missing_transitive_impl.rs │ │ │ ├── derive_missing_transitive_impl.stderr │ │ │ ├── derive_name_double_underscored.rs │ │ │ ├── derive_name_double_underscored.stderr │ │ │ ├── derive_no_fields.rs │ │ │ ├── derive_no_fields.stderr │ │ │ ├── derive_non_subtype_return.rs │ │ │ ├── derive_non_subtype_return.stderr │ │ │ ├── derive_unnamed_field.rs │ │ │ └── derive_unnamed_field.stderr │ │ └── trait │ │ │ ├── additional_non_nullable_argument.rs │ │ │ ├── additional_non_nullable_argument.stderr │ │ │ ├── argument_double_underscored.rs │ │ │ ├── argument_double_underscored.stderr │ │ │ ├── argument_non_input_type.rs │ │ │ ├── argument_non_input_type.stderr │ │ │ ├── argument_wrong_default_array.rs │ │ │ ├── argument_wrong_default_array.stderr │ │ │ ├── cyclic_impl.rs │ │ │ ├── cyclic_impl.stderr │ │ │ ├── field_double_underscored.rs │ │ │ ├── field_double_underscored.stderr │ │ │ ├── field_non_output_return_type.rs │ │ │ ├── field_non_output_return_type.stderr │ │ │ ├── fields_duplicate.rs │ │ │ ├── fields_duplicate.stderr │ │ │ ├── implementers_duplicate_pretty.rs │ │ │ ├── implementers_duplicate_pretty.stderr │ │ │ ├── implementers_duplicate_ugly.rs │ │ │ ├── implementers_duplicate_ugly.stderr │ │ │ ├── method_default_impl.rs │ │ │ ├── method_default_impl.stderr │ │ │ ├── missing_field.rs │ │ │ ├── missing_field.stderr │ │ │ ├── missing_field_argument.rs │ │ │ ├── missing_field_argument.stderr │ │ │ ├── missing_for_attr.rs │ │ │ ├── missing_for_attr.stderr │ │ │ ├── missing_impl_attr.rs │ │ │ ├── missing_impl_attr.stderr │ │ │ ├── missing_transitive_impl.rs │ │ │ ├── missing_transitive_impl.stderr │ │ │ ├── name_double_underscored.rs │ │ │ ├── name_double_underscored.stderr │ │ │ ├── no_fields.rs │ │ │ ├── no_fields.stderr │ │ │ ├── non_subtype_return.rs │ │ │ ├── non_subtype_return.stderr │ │ │ ├── wrong_argument_type.rs │ │ │ ├── wrong_argument_type.stderr │ │ │ ├── wrong_syntax.rs │ │ │ └── wrong_syntax.stderr │ ├── object │ │ ├── argument_double_underscored.rs │ │ ├── argument_double_underscored.stderr │ │ ├── argument_non_input_type.rs │ │ ├── argument_non_input_type.stderr │ │ ├── argument_wrong_default_array.rs │ │ ├── argument_wrong_default_array.stderr │ │ ├── attr_field_double_underscored.rs │ │ ├── attr_field_double_underscored.stderr │ │ ├── attr_field_non_output_return_type.rs │ │ ├── attr_field_non_output_return_type.stderr │ │ ├── attr_fields_duplicate.rs │ │ ├── attr_fields_duplicate.stderr │ │ ├── attr_name_double_underscored.rs │ │ ├── attr_name_double_underscored.stderr │ │ ├── attr_no_fields.rs │ │ ├── attr_no_fields.stderr │ │ ├── attr_wrong_item.rs │ │ ├── attr_wrong_item.stderr │ │ ├── attr_wrong_syntax.rs │ │ ├── attr_wrong_syntax.stderr │ │ ├── derive_field_double_underscored.rs │ │ ├── derive_field_double_underscored.stderr │ │ ├── derive_field_non_output_return_type.rs │ │ ├── derive_field_non_output_return_type.stderr │ │ ├── derive_fields_duplicate.rs │ │ ├── derive_fields_duplicate.stderr │ │ ├── derive_name_double_underscored.rs │ │ ├── derive_name_double_underscored.stderr │ │ ├── derive_no_fields.rs │ │ ├── derive_no_fields.stderr │ │ ├── derive_wrong_item.rs │ │ └── derive_wrong_item.stderr │ ├── scalar │ │ ├── derive_input │ │ │ ├── attr_invalid_url.rs │ │ │ ├── attr_invalid_url.stderr │ │ │ ├── attr_transparent_and_with.rs │ │ │ ├── attr_transparent_and_with.stderr │ │ │ ├── attr_transparent_multiple_named_fields.rs │ │ │ ├── attr_transparent_multiple_named_fields.stderr │ │ │ ├── attr_transparent_multiple_unnamed_fields.rs │ │ │ ├── attr_transparent_multiple_unnamed_fields.stderr │ │ │ ├── attr_transparent_unit_struct.rs │ │ │ ├── attr_transparent_unit_struct.stderr │ │ │ ├── derive_invalid_url.rs │ │ │ ├── derive_invalid_url.stderr │ │ │ ├── derive_transparent_and_with.rs │ │ │ ├── derive_transparent_and_with.stderr │ │ │ ├── derive_transparent_multiple_named_fields.rs │ │ │ ├── derive_transparent_multiple_named_fields.stderr │ │ │ ├── derive_transparent_multiple_unnamed_fields.rs │ │ │ ├── derive_transparent_multiple_unnamed_fields.stderr │ │ │ ├── derive_transparent_unit_struct.rs │ │ │ └── derive_transparent_unit_struct.stderr │ │ └── type_alias │ │ │ ├── attr_invalid_url.rs │ │ │ ├── attr_invalid_url.stderr │ │ │ ├── attr_with_not_all_resolvers.rs │ │ │ ├── attr_with_not_all_resolvers.stderr │ │ │ ├── attr_without_resolvers.rs │ │ │ └── attr_without_resolvers.stderr │ ├── scalar_value │ │ ├── missing_attributes.rs │ │ ├── missing_attributes.stderr │ │ ├── multiple_named_fields.rs │ │ ├── multiple_named_fields.stderr │ │ ├── multiple_unnamed_fields.rs │ │ ├── multiple_unnamed_fields.stderr │ │ ├── not_enum.rs │ │ └── not_enum.stderr │ ├── subscription │ │ ├── argument_double_underscored.rs │ │ ├── argument_double_underscored.stderr │ │ ├── argument_non_input_type.rs │ │ ├── argument_non_input_type.stderr │ │ ├── argument_wrong_default_array.rs │ │ ├── argument_wrong_default_array.stderr │ │ ├── field_double_underscored.rs │ │ ├── field_double_underscored.stderr │ │ ├── field_non_output_return_type.rs │ │ ├── field_non_output_return_type.stderr │ │ ├── field_not_async.rs │ │ ├── field_not_async.stderr │ │ ├── fields_duplicate.rs │ │ ├── fields_duplicate.stderr │ │ ├── name_double_underscored.rs │ │ ├── name_double_underscored.stderr │ │ ├── no_fields.rs │ │ ├── no_fields.stderr │ │ ├── wrong_item.rs │ │ ├── wrong_item.stderr │ │ ├── wrong_syntax.rs │ │ └── wrong_syntax.stderr │ └── union │ │ ├── attr_wrong_item.rs │ │ ├── attr_wrong_item.stderr │ │ ├── derive_wrong_item.rs │ │ ├── derive_wrong_item.stderr │ │ ├── enum_external_resolver_fn_conflicts_with_variant_external_resolver_fn.rs │ │ ├── enum_external_resolver_fn_conflicts_with_variant_external_resolver_fn.stderr │ │ ├── enum_name_double_underscored.rs │ │ ├── enum_name_double_underscored.stderr │ │ ├── enum_no_fields.rs │ │ ├── enum_no_fields.stderr │ │ ├── enum_non_object_variant.rs │ │ ├── enum_non_object_variant.stderr │ │ ├── enum_same_type_pretty.rs │ │ ├── enum_same_type_pretty.stderr │ │ ├── enum_same_type_ugly.rs │ │ ├── enum_same_type_ugly.stderr │ │ ├── enum_wrong_variant_field.rs │ │ ├── enum_wrong_variant_field.stderr │ │ ├── struct_name_double_underscored.rs │ │ ├── struct_name_double_underscored.stderr │ │ ├── struct_no_fields.rs │ │ ├── struct_no_fields.stderr │ │ ├── struct_non_object_variant.rs │ │ ├── struct_non_object_variant.stderr │ │ ├── struct_same_type_pretty.rs │ │ ├── struct_same_type_pretty.stderr │ │ ├── struct_same_type_ugly.rs │ │ ├── struct_same_type_ugly.stderr │ │ ├── trait_fail_infer_context.rs │ │ ├── trait_fail_infer_context.stderr │ │ ├── trait_method_conflicts_with_external_resolver_fn.rs │ │ ├── trait_method_conflicts_with_external_resolver_fn.stderr │ │ ├── trait_name_double_underscored.rs │ │ ├── trait_name_double_underscored.stderr │ │ ├── trait_no_fields.rs │ │ ├── trait_no_fields.stderr │ │ ├── trait_non_object_variant.rs │ │ ├── trait_non_object_variant.stderr │ │ ├── trait_same_type_pretty.rs │ │ ├── trait_same_type_pretty.stderr │ │ ├── trait_same_type_ugly.rs │ │ ├── trait_same_type_ugly.stderr │ │ ├── trait_with_attr_on_method.rs │ │ ├── trait_with_attr_on_method.stderr │ │ ├── trait_wrong_method_input_args.rs │ │ ├── trait_wrong_method_input_args.stderr │ │ ├── trait_wrong_method_return_type.rs │ │ └── trait_wrong_method_return_type.stderr └── src │ └── lib.rs └── integration ├── Cargo.toml └── tests ├── arc_fields.rs ├── array.rs ├── codegen_derive_object_with_raw_idents.rs ├── codegen_enum_derive.rs ├── codegen_input_object_derive.rs ├── codegen_interface_attr_struct.rs ├── codegen_interface_attr_trait.rs ├── codegen_interface_derive.rs ├── codegen_object_attr.rs ├── codegen_object_derive.rs ├── codegen_scalar_attr_derive_input.rs ├── codegen_scalar_attr_type_alias.rs ├── codegen_scalar_derive.rs ├── codegen_scalar_value_derive.rs ├── codegen_subscription_attr.rs ├── codegen_union_attr.rs ├── codegen_union_derive.rs ├── common └── mod.rs ├── custom_scalar.rs ├── cve_2022_31173.rs ├── disabled_introspection.rs ├── explicit_null.rs ├── infallible_as_field_error.rs ├── inside_macro.rs ├── issue_1287.rs ├── issue_371.rs ├── issue_372.rs ├── issue_398.rs ├── issue_407.rs ├── issue_500.rs ├── issue_798.rs ├── issue_914.rs ├── issue_922.rs ├── issue_925.rs ├── issue_945.rs └── pre_parse.rs /.codespellrc: -------------------------------------------------------------------------------- 1 | [codespell] 2 | ignore-words-list = crate 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug, needs-triage 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | (code example preferred) 16 | 17 | 18 | **Expected behavior** 19 | A clear and concise description of what you expected to happen. 20 | 21 | 22 | **Additional context** 23 | Add any other context about the problem here. 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support Request 3 | about: Create a support request if you have a problem with using Juniper. 4 | title: '' 5 | labels: question 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: cargo 4 | directory: / 5 | labels: ["enhancement", "rust", "k::dependencies"] 6 | schedule: 7 | interval: daily 8 | 9 | - package-ecosystem: github-actions 10 | directory: / 11 | labels: ["enhancement", "github_actions", "k::dependencies"] 12 | schedule: 13 | interval: daily 14 | 15 | - package-ecosystem: npm 16 | directory: /juniper/ 17 | labels: ["enhancement", "javascript", "k::dependencies", "k::integration"] 18 | schedule: 19 | interval: daily 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /.vscode/ 3 | /*.iml 4 | .DS_Store 5 | 6 | /Cargo.lock 7 | /target/ 8 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | imports_granularity = "Crate" 2 | use_field_init_shorthand = true 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Juniper Contribution Guide 2 | 3 | Juniper is always looking for new contributors, so don't be afraid to jump in and help! 4 | The maintainers are happy to provide guidance if required. 5 | 6 | To get started, you can look for [issues with the "help wanted" label](https://github.com/graphql-rust/juniper/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22). 7 | 8 | ## PR Checklist 9 | 10 | Before submitting a PR, you should follow these steps to prevent redundant churn or CI failures: 11 | 12 | - [ ] Ensure proper formatting 13 | - [ ] Run all tests 14 | - [ ] Update the CHANGELOG 15 | 16 | ### Ensure proper formatting 17 | 18 | Consistent formatting is enforced on the CI. 19 | 20 | Before you submit your PR, you should run `cargo +nightly fmt --all` in the root directory (or use the `make fmt` shortcut). 21 | 22 | Formatting should be run on the **nightly** compiler. 23 | 24 | ### Run all tests 25 | 26 | To run all available tests, including verifying the code examples in the book: 27 | 28 | 1. Run `cargo test` in the root directory. 29 | 2. Run `make test.book` in the root directory. 30 | 31 | ### Update the CHANGELOG 32 | 33 | Add your changes to the relevant changelog if they affect users in any way. 34 | Each sub-crate has it's own CHANGELOG.md. 35 | 36 | Your changes should be added to a `[master]` section on top of the file. 37 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "1" # unifying Cargo features asap for Book tests 3 | members = [ 4 | "benches", 5 | "book", 6 | "juniper_codegen", 7 | "juniper", 8 | "juniper_hyper", 9 | "juniper_rocket", 10 | "juniper_subscriptions", 11 | "juniper_graphql_ws", 12 | "juniper_warp", 13 | "juniper_actix", 14 | "juniper_axum", 15 | "tests/codegen", 16 | "tests/integration", 17 | ] 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2016-2025 Magnus Hallin , 4 | Christoph Herzog , 5 | Christian Legnitto , 6 | Ilya Solovyiov , 7 | Kai Ren 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | * Redistributions of source code must retain the above copyright notice, this 14 | list of conditions and the following disclaimer. 15 | 16 | * Redistributions in binary form must reproduce the above copyright notice, 17 | this list of conditions and the following disclaimer in the documentation 18 | and/or other materials provided with the distribution. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /assets/logo/README.md: -------------------------------------------------------------------------------- 1 | The rust-graphql logo is a derivative work based on 2 | 3 | * The GraphQL Logo licensed under the terms of the BSD license 4 | * The Rust Logo licensed under the terms of the CC-BY license 5 | -------------------------------------------------------------------------------- /assets/logo/juniper-dark-word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-rust/juniper/b9e94a60dbe702afbfaa3418f4094149c720be04/assets/logo/juniper-dark-word.png -------------------------------------------------------------------------------- /assets/logo/juniper-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-rust/juniper/b9e94a60dbe702afbfaa3418f4094149c720be04/assets/logo/juniper-dark.png -------------------------------------------------------------------------------- /assets/logo/juniper-light-word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-rust/juniper/b9e94a60dbe702afbfaa3418f4094149c720be04/assets/logo/juniper-light-word.png -------------------------------------------------------------------------------- /assets/logo/juniper-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-rust/juniper/b9e94a60dbe702afbfaa3418f4094149c720be04/assets/logo/juniper-light.png -------------------------------------------------------------------------------- /assets/logo/juniper-mono-word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-rust/juniper/b9e94a60dbe702afbfaa3418f4094149c720be04/assets/logo/juniper-mono-word.png -------------------------------------------------------------------------------- /assets/logo/juniper-mono.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphql-rust/juniper/b9e94a60dbe702afbfaa3418f4094149c720be04/assets/logo/juniper-mono.png -------------------------------------------------------------------------------- /benches/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "juniper_benchmarks" 3 | version = "0.0.0" 4 | edition = "2024" 5 | authors = ["Christoph Herzog "] 6 | publish = false 7 | 8 | [dependencies] 9 | juniper = { path = "../juniper" } 10 | 11 | [dev-dependencies] 12 | criterion = "0.6" 13 | tokio = { version = "1.0", features = ["rt-multi-thread"] } 14 | 15 | [lints.clippy] 16 | allow_attributes = "warn" 17 | allow_attributes_without_reason = "warn" 18 | [lints.rust] 19 | closure_returning_async_block = "warn" 20 | future_incompatible = { level = "warn", priority = -1 } 21 | impl_trait_redundant_captures = "warn" 22 | non_ascii_idents = "forbid" 23 | unsafe_code = "forbid" 24 | unused_crate_dependencies = "warn" 25 | 26 | [[bench]] 27 | name = "benchmark" 28 | harness = false 29 | -------------------------------------------------------------------------------- /book/.gitignore: -------------------------------------------------------------------------------- 1 | /_rendered/ 2 | /gh-pages/ 3 | -------------------------------------------------------------------------------- /book/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "juniper_book" 3 | version = "0.0.0" 4 | edition = "2024" 5 | authors = ["Kai Ren "] 6 | publish = false 7 | 8 | [dependencies] 9 | dataloader = "0.18" # for Book only 10 | 11 | [lints.clippy] 12 | allow_attributes = "warn" 13 | allow_attributes_without_reason = "warn" 14 | [lints.rust] 15 | closure_returning_async_block = "warn" 16 | future_incompatible = { level = "warn", priority = -1 } 17 | impl_trait_redundant_captures = "warn" 18 | non_ascii_idents = "forbid" 19 | unsafe_code = "forbid" 20 | unused_crate_dependencies = "warn" 21 | -------------------------------------------------------------------------------- /book/README.md: -------------------------------------------------------------------------------- 1 | Juniper Book 2 | ============ 3 | 4 | Book containing the [`juniper`](https://docs.rs/juniper) user guide. 5 | 6 | 7 | 8 | 9 | ## Contributing 10 | 11 | 12 | ### Requirements 13 | 14 | The Book is built with [mdBook](https://github.com/rust-lang/mdBook). 15 | 16 | You may install it with: 17 | ```bash 18 | cargo install mdbook 19 | ``` 20 | 21 | 22 | ### Local test server 23 | 24 | To launch a local test server that continually re-builds the Book and auto-reloads the page, run: 25 | ```bash 26 | mdbook serve 27 | 28 | # or from project root dir: 29 | make book.serve 30 | ``` 31 | 32 | 33 | ### Building 34 | 35 | You may build the Book to rendered HTML with this command: 36 | ```bash 37 | mdbook build 38 | 39 | # or from project root dir: 40 | make book 41 | ``` 42 | 43 | The output will be in the `_rendered/` directory. 44 | 45 | 46 | ### Testing 47 | 48 | To run the tests validating all code examples in the book, run (from project root dir): 49 | ```bash 50 | cargo build 51 | mdbook test -L target/debug/deps 52 | 53 | # or via shortcut: 54 | make test.book 55 | ``` 56 | -------------------------------------------------------------------------------- /book/book.toml: -------------------------------------------------------------------------------- 1 | [book] 2 | title = "Juniper Book" 3 | description = "User guide for Juniper (GraphQL server library for Rust)." 4 | language = "en" 5 | multilingual = false 6 | authors = [ 7 | "Kai Ren (@tyranron)", 8 | ] 9 | src = "src" 10 | 11 | [build] 12 | build-dir = "_rendered" 13 | create-missing = false 14 | 15 | [output.html] 16 | git_repository_url = "https://github.com/graphql-rust/juniper" 17 | 18 | [rust] 19 | edition = "2024" 20 | -------------------------------------------------------------------------------- /book/src/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Summary 2 | 3 | - [Introduction](introduction.md) 4 | - [Quickstart](quickstart.md) 5 | - [Type system](types/index.md) 6 | - [Objects](types/objects/index.md) 7 | - [Complex fields](types/objects/complex_fields.md) 8 | - [Context](types/objects/context.md) 9 | - [Error handling](types/objects/error/index.md) 10 | - [Field errors](types/objects/error/field.md) 11 | - [Schema errors](types/objects/error/schema.md) 12 | - [Generics](types/objects/generics.md) 13 | - [Interfaces](types/interfaces.md) 14 | - [Unions](types/unions.md) 15 | - [Enums](types/enums.md) 16 | - [Input objects](types/input_objects.md) 17 | - [Scalars](types/scalars.md) 18 | - [Schema](schema/index.md) 19 | - [Subscriptions](schema/subscriptions.md) 20 | - [Introspection](schema/introspection.md) 21 | - [Serving](serve/index.md) 22 | - [Batching](serve/batching.md) 23 | - [Advanced Topics](advanced/index.md) 24 | - [Implicit and explicit `null`](advanced/implicit_and_explicit_null.md) 25 | - [N+1 problem](advanced/n_plus_1.md) 26 | - [DataLoader](advanced/dataloader.md) 27 | - [Look-ahead](advanced/lookahead.md) 28 | - [Eager loading](advanced/eager_loading.md) 29 | -------------------------------------------------------------------------------- /book/src/advanced/index.md: -------------------------------------------------------------------------------- 1 | Advanced topics 2 | =============== 3 | 4 | The chapters below cover some more advanced topics. 5 | 6 | - [Implicit and explicit `null`](implicit_and_explicit_null.md) 7 | - [N+1 problem](n_plus_1.md) 8 | - [DataLoader](dataloader.md) 9 | - [Look-ahead](lookahead.md) 10 | - [Eager loading](eager_loading.md) 11 | -------------------------------------------------------------------------------- /book/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Crate keeping dependencies for running Book tests. 2 | 3 | use dataloader as _; 4 | -------------------------------------------------------------------------------- /book/src/styles/website.css: -------------------------------------------------------------------------------- 1 | .markdown-section pre { 2 | line-height: 1.3; 3 | } -------------------------------------------------------------------------------- /book/src/types/index.md: -------------------------------------------------------------------------------- 1 | Type system 2 | =========== 3 | 4 | Most of the work in working with [Juniper] consists of mapping the [GraphQL type system][0] to the [Rust] types our application uses. 5 | 6 | [Juniper] provides some convenient abstractions making this process as painless as possible. 7 | 8 | Find out more in the individual chapters below: 9 | - [Objects](objects/index.md) 10 | - [Complex fields](objects/complex_fields.md) 11 | - [Context](objects/Context.md) 12 | - [Error handling](objects/error/index.md) 13 | - [Field errors](objects/error/field.md) 14 | - [Schema errors](objects/error/schema.md) 15 | - [Generics](objects/generics.md) 16 | - [Interfaces](interfaces.md) 17 | - [Unions](unions.md) 18 | - [Enums](enums.md) 19 | - [Input objects](input_objects.md) 20 | - [Scalars](scalars.md) 21 | 22 | 23 | 24 | 25 | [Juniper]: https://docs.rs/juniper 26 | [Rust]: https://www.rust-lang.org 27 | 28 | [0]: https://spec.graphql.org/October2021#sec-Type-System 29 | -------------------------------------------------------------------------------- /book/src/types/objects/error/index.md: -------------------------------------------------------------------------------- 1 | Error handling 2 | ============== 3 | 4 | Error handling in [GraphQL] can be done in multiple ways. We will cover the two different error handling models mostly used: 5 | 1. [Implicit field results](field.md). 6 | 2. [Explicit errors backend by GraphQL schema](schema.md). 7 | 8 | Choosing the right error handling method depends on the requirements of the application and the concrete error happening. Investigating both approaches is beneficial. 9 | 10 | 11 | 12 | 13 | ## Comparison 14 | 15 | The [first approach](field.md) (where every error is a [field error][1]) is easier to implement. However, clients won't know what errors may occur and instead will have to infer what happens from the [error message][2]. This is brittle and could change over time due to either clients or server changing. Therefore, extensive integration testing between clients and server is required to maintain the implicit contract between the two. 16 | 17 | [Encoding non-critical errors in a GraphQL schema](schema.md) makes the contract between clients and the server explicit. This allows clients to understand and handle these errors correctly and the server to know when changes are potentially breaking clients. However, encoding this error information into a [GraphQL schema][8] requires additional code and up-front definition of non-critical errors. 18 | 19 | 20 | 21 | 22 | [GraphQL]: https://graphql.org 23 | 24 | [1]: https://spec.graphql.org/October2021#sec-Errors.Field-errors 25 | [2]: https://spec.graphql.org/October2021/#sel-GAPHRPDCAACCyD57Z 26 | [8]: https://graphql.org/learn/schema 27 | -------------------------------------------------------------------------------- /juniper/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /package-lock.json 3 | /yarn.lock 4 | -------------------------------------------------------------------------------- /juniper/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2016-2025 Magnus Hallin , 4 | Christoph Herzog , 5 | Christian Legnitto , 6 | Ilya Solovyiov , 7 | Kai Ren 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | * Redistributions of source code must retain the above copyright notice, this 14 | list of conditions and the following disclaimer. 15 | 16 | * Redistributions in binary form must reproduce the above copyright notice, 17 | this list of conditions and the following disclaimer in the documentation 18 | and/or other materials provided with the distribution. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /juniper/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "postinstall": "make graphiql graphql-playground" 5 | }, 6 | "dependencies": { 7 | "graphiql": "4.1.1", 8 | "graphql-playground-react": "1.7.28" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /juniper/src/executor_tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod directives; 2 | mod enums; 3 | mod executor; 4 | mod introspection; 5 | mod variables; 6 | 7 | mod interfaces_unions; 8 | 9 | mod async_await; 10 | -------------------------------------------------------------------------------- /juniper/src/http/graphiql.js: -------------------------------------------------------------------------------- 1 | function normalizeSubscriptionEndpoint(endpoint, subscriptionEndpoint) { 2 | if (subscriptionEndpoint) { 3 | if (subscriptionEndpoint.startsWith('/')) { 4 | const secure = 5 | endpoint.includes('https') || location.href.includes('https') 6 | ? 's' 7 | : '' 8 | return `ws${secure}://${location.host}${subscriptionEndpoint}` 9 | } else { 10 | return subscriptionEndpoint.replace(/^http/, 'ws') 11 | } 12 | } 13 | return null 14 | } 15 | -------------------------------------------------------------------------------- /juniper/src/http/graphiql.rs: -------------------------------------------------------------------------------- 1 | //! Utility module to generate a GraphiQL interface 2 | 3 | /// Generate the HTML source to show a GraphiQL interface 4 | /// 5 | /// The subscriptions endpoint URL can optionally be provided. For example: 6 | /// 7 | /// ``` 8 | /// # use juniper::http::graphiql::graphiql_source; 9 | /// let graphiql = graphiql_source("/graphql", Some("/subscriptions")); 10 | /// ``` 11 | pub fn graphiql_source( 12 | graphql_endpoint_url: &str, 13 | subscriptions_endpoint_url: Option<&str>, 14 | ) -> String { 15 | include_str!("graphiql.html").replace( 16 | "", 17 | &format!( 18 | // language=JavaScript 19 | " 20 | const JUNIPER_URL = '{juniper_url}'; 21 | const JUNIPER_SUBSCRIPTIONS_URL = '{juniper_subscriptions_url}'; 22 | 23 | {grahiql_js} 24 | 25 | ", 26 | juniper_url = graphql_endpoint_url, 27 | juniper_subscriptions_url = subscriptions_endpoint_url.unwrap_or_default(), 28 | grahiql_js = include_str!("graphiql.js"), 29 | ), 30 | ) 31 | } 32 | -------------------------------------------------------------------------------- /juniper/src/http/playground.rs: -------------------------------------------------------------------------------- 1 | //! Utility module to generate a GraphQL Playground interface. 2 | 3 | /// Generate the HTML source to show a GraphQL Playground interface. 4 | pub fn playground_source( 5 | graphql_endpoint_url: &str, 6 | subscriptions_endpoint_url: Option<&str>, 7 | ) -> String { 8 | let subscriptions_endpoint = if let Some(sub_url) = subscriptions_endpoint_url { 9 | sub_url 10 | } else { 11 | graphql_endpoint_url 12 | }; 13 | 14 | include_str!("playground.html") 15 | .replace("JUNIPER_URL", graphql_endpoint_url) 16 | .replace("JUNIPER_SUBSCRIPTIONS_URL", subscriptions_endpoint) 17 | } 18 | -------------------------------------------------------------------------------- /juniper/src/integrations/mod.rs: -------------------------------------------------------------------------------- 1 | //! Provides GraphQLType implementations for some external types 2 | 3 | #[cfg(feature = "anyhow")] 4 | pub mod anyhow; 5 | #[cfg(feature = "bigdecimal")] 6 | pub mod bigdecimal; 7 | #[cfg(feature = "bson")] 8 | pub mod bson; 9 | #[cfg(feature = "chrono")] 10 | pub mod chrono; 11 | #[cfg(feature = "chrono-tz")] 12 | pub mod chrono_tz; 13 | #[cfg(feature = "jiff")] 14 | pub mod jiff; 15 | #[cfg(feature = "rust_decimal")] 16 | pub mod rust_decimal; 17 | #[doc(hidden)] 18 | pub mod serde; 19 | #[cfg(feature = "time")] 20 | pub mod time; 21 | #[cfg(feature = "url")] 22 | pub mod url; 23 | #[cfg(feature = "uuid")] 24 | pub mod uuid; 25 | -------------------------------------------------------------------------------- /juniper/src/introspection/mod.rs: -------------------------------------------------------------------------------- 1 | /// From 2 | pub(crate) const INTROSPECTION_QUERY: &str = include_str!("./query.graphql"); 3 | pub(crate) const INTROSPECTION_QUERY_WITHOUT_DESCRIPTIONS: &str = 4 | include_str!("./query_without_descriptions.graphql"); 5 | 6 | /// The desired GraphQL introspection format for the canonical query 7 | /// () 8 | #[derive(Clone, Copy, Debug, Default)] 9 | pub enum IntrospectionFormat { 10 | /// The canonical GraphQL introspection query. 11 | #[default] 12 | All, 13 | 14 | /// The canonical GraphQL introspection query without descriptions. 15 | WithoutDescriptions, 16 | } 17 | -------------------------------------------------------------------------------- /juniper/src/introspection/query_without_descriptions.graphql: -------------------------------------------------------------------------------- 1 | query IntrospectionQuery { 2 | __schema { 3 | queryType { 4 | name 5 | } 6 | mutationType { 7 | name 8 | } 9 | subscriptionType { 10 | name 11 | } 12 | types { 13 | ...FullType 14 | } 15 | directives { 16 | name 17 | isRepeatable 18 | locations 19 | args { 20 | ...InputValue 21 | } 22 | } 23 | } 24 | } 25 | fragment FullType on __Type { 26 | kind 27 | name 28 | specifiedByUrl 29 | fields(includeDeprecated: true) { 30 | name 31 | args { 32 | ...InputValue 33 | } 34 | type { 35 | ...TypeRef 36 | } 37 | isDeprecated 38 | deprecationReason 39 | } 40 | inputFields { 41 | ...InputValue 42 | } 43 | interfaces { 44 | ...TypeRef 45 | } 46 | enumValues(includeDeprecated: true) { 47 | name 48 | isDeprecated 49 | deprecationReason 50 | } 51 | possibleTypes { 52 | ...TypeRef 53 | } 54 | } 55 | fragment InputValue on __InputValue { 56 | name 57 | type { 58 | ...TypeRef 59 | } 60 | defaultValue 61 | } 62 | fragment TypeRef on __Type { 63 | kind 64 | name 65 | ofType { 66 | kind 67 | name 68 | ofType { 69 | kind 70 | name 71 | ofType { 72 | kind 73 | name 74 | ofType { 75 | kind 76 | name 77 | ofType { 78 | kind 79 | name 80 | ofType { 81 | kind 82 | name 83 | ofType { 84 | kind 85 | name 86 | } 87 | } 88 | } 89 | } 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /juniper/src/macros/helper/mod.rs: -------------------------------------------------------------------------------- 1 | //! Helper traits and definitions for macros. 2 | 3 | pub mod subscription; 4 | 5 | use std::fmt; 6 | 7 | use futures::future::{self, BoxFuture}; 8 | 9 | use crate::FieldError; 10 | 11 | /// This trait is used by [`graphql_scalar!`] macro to retrieve [`Error`] type 12 | /// from a [`Result`]. 13 | /// 14 | /// [`Error`]: Result::Error 15 | /// [`graphql_scalar!`]: macro@crate::graphql_scalar 16 | pub trait ExtractError { 17 | /// Extracted [`Error`] type of this [`Result`]. 18 | /// 19 | /// [`Error`]: Result::Error 20 | type Error; 21 | } 22 | 23 | impl ExtractError for Result { 24 | type Error = E; 25 | } 26 | 27 | /// Wraps `msg` with [`Display`] implementation into opaque [`Send`] [`Future`] 28 | /// which immediately resolves into [`FieldError`]. 29 | pub fn err_fut<'ok, D, Ok, S>(msg: D) -> BoxFuture<'ok, Result>> 30 | where 31 | D: fmt::Display, 32 | Ok: Send + 'ok, 33 | S: Send + 'static, 34 | { 35 | Box::pin(future::err(FieldError::from(msg))) 36 | } 37 | 38 | /// Generates a [`FieldError`] for the given Rust type expecting to have 39 | /// [`GraphQLType::name`]. 40 | /// 41 | /// [`GraphQLType::name`]: crate::GraphQLType::name 42 | pub fn err_unnamed_type(name: &str) -> FieldError { 43 | FieldError::from(format!( 44 | "Expected `{name}` type to implement `GraphQLType::name`", 45 | )) 46 | } 47 | 48 | /// Returns a [`future::err`] wrapping the [`err_unnamed_type`]. 49 | pub fn err_unnamed_type_fut<'ok, Ok, S>(name: &str) -> BoxFuture<'ok, Result>> 50 | where 51 | Ok: Send + 'ok, 52 | S: Send + 'static, 53 | { 54 | Box::pin(future::err(err_unnamed_type(name))) 55 | } 56 | -------------------------------------------------------------------------------- /juniper/src/macros/mod.rs: -------------------------------------------------------------------------------- 1 | //! Declarative macros and helper definitions for procedural macros. 2 | 3 | #[doc(hidden)] 4 | pub mod helper; 5 | #[doc(hidden)] 6 | #[macro_use] 7 | pub mod reflect; 8 | 9 | #[macro_use] 10 | mod graphql_input_value; 11 | #[macro_use] 12 | mod graphql_value; 13 | #[macro_use] 14 | mod graphql_vars; 15 | -------------------------------------------------------------------------------- /juniper/src/parser/mod.rs: -------------------------------------------------------------------------------- 1 | //! Query parser and language utilities 2 | 3 | mod document; 4 | mod lexer; 5 | #[expect(clippy::module_inception, reason = "intended")] 6 | mod parser; 7 | mod utils; 8 | mod value; 9 | 10 | #[cfg(test)] 11 | mod tests; 12 | 13 | pub use self::document::parse_document_source; 14 | 15 | pub use self::{ 16 | lexer::{Lexer, LexerError, ScalarToken, Token}, 17 | parser::{OptionParseResult, ParseError, ParseResult, Parser, UnlocatedParseResult}, 18 | utils::{SourcePosition, Span, Spanning}, 19 | }; 20 | -------------------------------------------------------------------------------- /juniper/src/parser/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod document; 2 | mod lexer; 3 | mod value; 4 | -------------------------------------------------------------------------------- /juniper/src/schema/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod meta; 2 | pub mod model; 3 | #[expect(clippy::module_inception, reason = "intended")] 4 | pub mod schema; 5 | pub mod translate; 6 | -------------------------------------------------------------------------------- /juniper/src/schema/translate/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::{ScalarValue, SchemaType}; 2 | 3 | #[cfg_attr( 4 | not(feature = "schema-language"), 5 | expect(dead_code, reason = "common abstraction") 6 | )] 7 | pub trait SchemaTranslator<'a, T> { 8 | fn translate_schema(s: &'a SchemaType) -> T; 9 | } 10 | 11 | #[cfg(feature = "schema-language")] 12 | pub mod graphql_parser; 13 | -------------------------------------------------------------------------------- /juniper/src/tests/fixtures/mod.rs: -------------------------------------------------------------------------------- 1 | //! Library fixtures 2 | 3 | /// GraphQL schema and data from Star Wars. 4 | pub mod starwars; 5 | -------------------------------------------------------------------------------- /juniper/src/tests/fixtures/starwars/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod schema; 2 | #[cfg(feature = "schema-language")] 3 | pub mod schema_language; 4 | -------------------------------------------------------------------------------- /juniper/src/tests/fixtures/starwars/schema_language.rs: -------------------------------------------------------------------------------- 1 | //! GraphQL SDL (schema definition language) definitions for test fixtures. 2 | 3 | /// The schema as a static/hardcoded GraphQL SDL (schema definition language). 4 | pub const STATIC_GRAPHQL_SCHEMA_DEFINITION: &str = include_str!("starwars.graphql"); 5 | 6 | #[cfg(test)] 7 | mod tests { 8 | use pretty_assertions::assert_eq; 9 | 10 | use crate::{ 11 | schema::model::RootNode, 12 | tests::fixtures::starwars::{ 13 | schema::{Database, Query}, 14 | schema_language::STATIC_GRAPHQL_SCHEMA_DEFINITION, 15 | }, 16 | types::scalars::{EmptyMutation, EmptySubscription}, 17 | }; 18 | 19 | #[test] 20 | fn dynamic_schema_language_matches_static() { 21 | let schema = RootNode::new( 22 | Query, 23 | EmptyMutation::::new(), 24 | EmptySubscription::::new(), 25 | ); 26 | 27 | //dbg!("{}", schema.as_sdl()); 28 | 29 | // `include_str()` keeps line endings. `git` will sadly by default 30 | // convert them, making this test fail without runtime tweaks on 31 | // Windows. 32 | // 33 | // See https://github.com/rust-lang/rust/pull/63681. 34 | #[cfg(windows)] 35 | let expected = STATIC_GRAPHQL_SCHEMA_DEFINITION.replace("\r\n", "\n"); 36 | #[cfg(not(windows))] 37 | let expected = STATIC_GRAPHQL_SCHEMA_DEFINITION; 38 | 39 | assert_eq!(schema.as_sdl(), expected); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /juniper/src/tests/fixtures/starwars/starwars.graphql: -------------------------------------------------------------------------------- 1 | schema { 2 | query: Query 3 | } 4 | 5 | enum Episode { 6 | NEW_HOPE 7 | EMPIRE 8 | JEDI 9 | } 10 | 11 | "A character in the Star Wars Trilogy" 12 | interface Character { 13 | "The id of the character" 14 | id: String! 15 | "The name of the character" 16 | name: String 17 | "The friends of the character" 18 | friends: [Character!]! 19 | "Which movies they appear in" 20 | appearsIn: [Episode!]! 21 | } 22 | 23 | "A mechanical creature in the Star Wars universe." 24 | type Droid implements Character { 25 | "The id of the droid" 26 | id: String! 27 | "The name of the droid" 28 | name: String 29 | "The friends of the droid" 30 | friends: [Character!]! 31 | "Which movies they appear in" 32 | appearsIn: [Episode!]! 33 | "The primary function of the droid" 34 | primaryFunction: String 35 | } 36 | 37 | "A humanoid creature in the Star Wars universe." 38 | type Human implements Character { 39 | "The id of the human" 40 | id: String! 41 | "The name of the human" 42 | name: String 43 | "The friends of the human" 44 | friends: [Character!]! 45 | "Which movies they appear in" 46 | appearsIn: [Episode!]! 47 | "The home planet of the human" 48 | homePlanet: String 49 | } 50 | 51 | "The root query object of the schema" 52 | type Query { 53 | human("id of the human" id: String!): Human 54 | droid("id of the droid" id: String!): Droid 55 | hero("If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode" episode: Episode): Character 56 | } 57 | -------------------------------------------------------------------------------- /juniper/src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | //! Library tests and fixtures 2 | 3 | pub mod fixtures; 4 | #[cfg(test)] 5 | mod introspection_tests; 6 | #[cfg(test)] 7 | mod query_tests; 8 | #[cfg(test)] 9 | mod schema_introspection; 10 | #[cfg(test)] 11 | mod subscriptions; 12 | #[cfg(test)] 13 | mod type_info_tests; 14 | -------------------------------------------------------------------------------- /juniper/src/types/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod async_await; 2 | pub mod base; 3 | pub mod containers; 4 | pub mod marker; 5 | pub mod name; 6 | pub mod nullable; 7 | pub mod pointers; 8 | pub mod scalars; 9 | pub mod subscriptions; 10 | pub mod utilities; 11 | -------------------------------------------------------------------------------- /juniper/src/util.rs: -------------------------------------------------------------------------------- 1 | use std::borrow::Cow; 2 | 3 | /// Convert string to camel case. 4 | /// 5 | /// Note: needs to be public because several macros use it. 6 | #[doc(hidden)] 7 | pub fn to_camel_case(s: &'_ str) -> Cow<'_, str> { 8 | let mut dest = Cow::Borrowed(s); 9 | 10 | // handle '_' to be more friendly with the 11 | // _var convention for unused variables 12 | let s_iter = if let Some(stripped) = s.strip_prefix('_') { 13 | stripped 14 | } else { 15 | s 16 | } 17 | .split('_') 18 | .enumerate(); 19 | 20 | for (i, part) in s_iter { 21 | if i > 0 && part.len() == 1 { 22 | dest += Cow::Owned(part.to_uppercase()); 23 | } else if i > 0 && part.len() > 1 { 24 | let first = part 25 | .chars() 26 | .next() 27 | .unwrap() 28 | .to_uppercase() 29 | .collect::(); 30 | let second = &part[1..]; 31 | 32 | dest += Cow::Owned(first); 33 | dest += second; 34 | } else if i == 0 { 35 | dest = Cow::Borrowed(part); 36 | } 37 | } 38 | 39 | dest 40 | } 41 | 42 | #[test] 43 | fn test_to_camel_case() { 44 | assert_eq!(&to_camel_case("test")[..], "test"); 45 | assert_eq!(&to_camel_case("_test")[..], "test"); 46 | assert_eq!(&to_camel_case("first_second")[..], "firstSecond"); 47 | assert_eq!(&to_camel_case("first_")[..], "first"); 48 | assert_eq!(&to_camel_case("a_b_c")[..], "aBC"); 49 | assert_eq!(&to_camel_case("a_bc")[..], "aBc"); 50 | assert_eq!(&to_camel_case("a_b")[..], "aB"); 51 | assert_eq!(&to_camel_case("a")[..], "a"); 52 | assert_eq!(&to_camel_case("")[..], ""); 53 | } 54 | -------------------------------------------------------------------------------- /juniper/src/validation/mod.rs: -------------------------------------------------------------------------------- 1 | //! Query validation related methods and data structures 2 | 3 | mod context; 4 | mod input_value; 5 | mod multi_visitor; 6 | pub mod rules; 7 | mod traits; 8 | mod visitor; 9 | 10 | #[cfg(test)] 11 | pub(crate) mod test_harness; 12 | 13 | pub use self::{ 14 | context::{RuleError, ValidatorContext}, 15 | input_value::validate_input_values, 16 | multi_visitor::MultiVisitorNil, 17 | rules::visit_all_rules, 18 | traits::Visitor, 19 | visitor::visit, 20 | }; 21 | 22 | #[cfg(test)] 23 | pub(crate) use self::test_harness::{ 24 | expect_fails_fn, expect_fails_rule, expect_fails_rule_with_schema, expect_passes_rule, 25 | expect_passes_rule_with_schema, 26 | }; 27 | -------------------------------------------------------------------------------- /juniper_actix/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018-2025 Jordao Rosario , 4 | Kai Ren 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /juniper_actix/release.toml: -------------------------------------------------------------------------------- 1 | [[pre-release-replacements]] 2 | file = "CHANGELOG.md" 3 | max = 1 4 | min = 0 5 | search = "## master" 6 | replace = "## [{{version}}] · {{date}}\n[{{version}}]: /../../tree/{{crate_name}}-v{{version}}/{{crate_name}}" 7 | 8 | [[pre-release-replacements]] 9 | file = "README.md" 10 | exactly = 3 11 | search = "graphql-rust/juniper/blob/[^/]+/" 12 | replace = "graphql-rust/juniper/blob/{{crate_name}}-v{{version}}/" 13 | -------------------------------------------------------------------------------- /juniper_axum/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2022-2025 Benno Tielen , 4 | Kai Ren 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /juniper_axum/release.toml: -------------------------------------------------------------------------------- 1 | [[pre-release-replacements]] 2 | file = "CHANGELOG.md" 3 | max = 1 4 | min = 0 5 | search = "## master" 6 | replace = "## [{{version}}] · {{date}}\n[{{version}}]: /../../tree/{{crate_name}}-v{{version}}/{{crate_name}}" 7 | 8 | [[pre-release-replacements]] 9 | file = "README.md" 10 | exactly = 4 11 | search = "graphql-rust/juniper/blob/[^/]+/" 12 | replace = "graphql-rust/juniper/blob/{{crate_name}}-v{{version}}/" 13 | -------------------------------------------------------------------------------- /juniper_axum/src/response.rs: -------------------------------------------------------------------------------- 1 | //! [`JuniperResponse`] definition. 2 | 3 | use axum::{ 4 | Json, 5 | http::StatusCode, 6 | response::{IntoResponse, Response}, 7 | }; 8 | use juniper::{DefaultScalarValue, ScalarValue, http::GraphQLBatchResponse}; 9 | 10 | /// Wrapper around a [`GraphQLBatchResponse`], implementing [`IntoResponse`], so it can be returned 11 | /// from [`axum`] handlers. 12 | pub struct JuniperResponse(pub GraphQLBatchResponse) 13 | where 14 | S: ScalarValue; 15 | 16 | impl IntoResponse for JuniperResponse { 17 | fn into_response(self) -> Response { 18 | if self.0.is_ok() { 19 | Json(self.0).into_response() 20 | } else { 21 | (StatusCode::BAD_REQUEST, Json(self.0)).into_response() 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /juniper_codegen/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "juniper_codegen" 3 | version = "0.16.0" 4 | edition = "2024" 5 | rust-version = "1.85" 6 | description = "Code generation for `juniper` crate." 7 | license = "BSD-2-Clause" 8 | authors = [ 9 | "Magnus Hallin ", 10 | "Christoph Herzog ", 11 | "Ilya Solovyiov ", 12 | "Kai Ren ", 13 | ] 14 | documentation = "https://docs.rs/juniper-codegen" 15 | homepage = "https://github.com/graphql-rust/juniper/tree/master/juniper_codegen" 16 | repository = "https://github.com/graphql-rust/juniper" 17 | readme = "README.md" 18 | keywords = ["codegen", "graphql", "juniper", "macros"] 19 | exclude = ["/release.toml"] 20 | 21 | [lib] 22 | proc-macro = true 23 | 24 | [dependencies] 25 | derive_more = { version = "2.0", features = ["as_ref", "deref", "display"] } 26 | proc-macro2 = "1.0.4" 27 | quote = "1.0.9" 28 | syn = { version = "2.0", features = ["extra-traits", "full", "visit", "visit-mut"] } 29 | url = "2.0" 30 | 31 | [dev-dependencies] 32 | derive_more = { version = "2.0", features = ["from"] } 33 | futures = "0.3.22" 34 | juniper = { path = "../juniper" } 35 | serde = "1.0.122" 36 | 37 | [lints.clippy] 38 | allow_attributes = "warn" 39 | allow_attributes_without_reason = "warn" 40 | [lints.rust] 41 | closure_returning_async_block = "warn" 42 | future_incompatible = { level = "warn", priority = -1 } 43 | impl_trait_redundant_captures = "warn" 44 | missing_docs = "warn" 45 | non_ascii_idents = "forbid" 46 | unsafe_code = "forbid" 47 | unused_crate_dependencies = "warn" 48 | -------------------------------------------------------------------------------- /juniper_codegen/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2016-2025 Magnus Hallin , 4 | Christoph Herzog , 5 | Ilya Solovyiov , 6 | Kai Ren 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | 12 | * Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | 15 | * Redistributions in binary form must reproduce the above copyright notice, 16 | this list of conditions and the following disclaimer in the documentation 17 | and/or other materials provided with the distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /juniper_codegen/README.md: -------------------------------------------------------------------------------- 1 | `juniper_codegen` crate 2 | ======================= 3 | 4 | [![Crates.io](https://img.shields.io/crates/v/juniper_codegen.svg?maxAge=2592000)](https://crates.io/crates/juniper_codegen) 5 | [![Documentation](https://docs.rs/juniper_codegen/badge.svg)](https://docs.rs/juniper_codegen) 6 | [![CI](https://github.com/graphql-rust/juniper/actions/workflows/ci.yml/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) 7 | [![Rust 1.85+](https://img.shields.io/badge/rustc-1.85+-lightgray.svg "Rust 1.85+")](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0.html) 8 | 9 | - [Changelog](https://github.com/graphql-rust/juniper/blob/juniper_codegen-v0.16.0/juniper_codegen/CHANGELOG.md) 10 | 11 | Code generation for [`juniper`] crate. 12 | 13 | DO NOT use it directly, use [`juniper`] crate instead. 14 | 15 | 16 | 17 | 18 | ## License 19 | 20 | This project is licensed under [BSD 2-Clause License](https://github.com/graphql-rust/juniper/blob/juniper_codegen-v0.16.0/juniper_codegen/LICENSE). 21 | 22 | 23 | 24 | 25 | [`juniper`]: https://docs.rs/juniper 26 | -------------------------------------------------------------------------------- /juniper_codegen/release.toml: -------------------------------------------------------------------------------- 1 | [[pre-release-replacements]] 2 | file = "../juniper/Cargo.toml" 3 | exactly = 1 4 | search = "juniper_codegen = \\{ version = \"[^\"]+\"" 5 | replace = "{{crate_name}} = { version = \"{{version}}\"" 6 | 7 | [[pre-release-replacements]] 8 | file = "CHANGELOG.md" 9 | max = 1 10 | min = 0 11 | search = "## master" 12 | replace = "## [{{version}}] · {{date}}\n[{{version}}]: /../../tree/{{crate_name}}-v{{version}}/{{crate_name}}" 13 | 14 | [[pre-release-replacements]] 15 | file = "README.md" 16 | exactly = 2 17 | search = "graphql-rust/juniper/blob/[^/]+/" 18 | replace = "graphql-rust/juniper/blob/{{crate_name}}-v{{version}}/" 19 | -------------------------------------------------------------------------------- /juniper_codegen/src/common/mod.rs: -------------------------------------------------------------------------------- 1 | //! Common functions, definitions and extensions for code generation, used by this crate. 2 | 3 | pub(crate) mod default; 4 | pub(crate) mod deprecation; 5 | mod description; 6 | pub(crate) mod diagnostic; 7 | pub(crate) mod field; 8 | pub(crate) mod generate; 9 | pub(crate) mod parse; 10 | pub(crate) mod rename; 11 | pub(crate) mod scalar; 12 | mod span_container; 13 | 14 | use std::slice; 15 | 16 | pub(crate) use self::{description::Description, span_container::SpanContainer}; 17 | 18 | /// Checks whether the specified [`syn::Path`] equals to one of specified one-segment 19 | /// [`AttrNames::values`]. 20 | pub(crate) fn path_eq_single(path: &syn::Path, names: impl AttrNames) -> bool { 21 | path.segments.len() == 1 22 | && names 23 | .values() 24 | .iter() 25 | .any(|name| path.segments[0].ident == name) 26 | } 27 | 28 | /// Filters the provided [`syn::Attribute`] to contain only ones with the 29 | /// specified `name`. 30 | pub(crate) fn filter_attrs<'a>( 31 | names: impl AttrNames + 'a, 32 | attrs: &'a [syn::Attribute], 33 | ) -> impl Iterator + 'a { 34 | attrs 35 | .iter() 36 | .filter(move |attr| path_eq_single(attr.path(), names)) 37 | } 38 | 39 | /// Input-type polymorphism helper for checking names of multiple attribute names. 40 | pub(crate) trait AttrNames: Copy { 41 | /// Returns values to be checked. 42 | fn values(&self) -> &[&str]; 43 | } 44 | 45 | impl AttrNames for &str { 46 | fn values(&self) -> &[&str] { 47 | slice::from_ref(self) 48 | } 49 | } 50 | 51 | impl AttrNames for &[&str] { 52 | fn values(&self) -> &[&str] { 53 | self 54 | } 55 | } 56 | 57 | impl AttrNames for [&str; N] { 58 | fn values(&self) -> &[&str] { 59 | self 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /juniper_codegen/src/graphql_subscription/attr.rs: -------------------------------------------------------------------------------- 1 | //! Code generation for `#[graphql_subscription]` macro. 2 | 3 | use proc_macro2::{Span, TokenStream}; 4 | 5 | use crate::{ 6 | common::parse, 7 | graphql_object::{Attr, attr::expand_on_impl}, 8 | }; 9 | 10 | use super::Subscription; 11 | 12 | /// Expands `#[graphql_subscription]` macro into generated code. 13 | pub fn expand(attr_args: TokenStream, body: TokenStream) -> syn::Result { 14 | if let Ok(mut ast) = syn::parse2::(body) { 15 | if ast.trait_.is_none() { 16 | let impl_attrs = parse::attr::unite(("graphql_subscription", &attr_args), &ast.attrs); 17 | ast.attrs = parse::attr::strip(["graphql_subscription", "graphql"], ast.attrs); 18 | return expand_on_impl::( 19 | Attr::from_attrs(["graphql_subscription", "graphql"], &impl_attrs)?, 20 | ast, 21 | ); 22 | } 23 | } 24 | 25 | Err(syn::Error::new( 26 | Span::call_site(), 27 | "#[graphql_subscription] attribute is applicable to non-trait `impl` blocks only", 28 | )) 29 | } 30 | -------------------------------------------------------------------------------- /juniper_graphql_ws/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "juniper_graphql_ws" 3 | version = "0.4.0" 4 | edition = "2024" 5 | rust-version = "1.85" 6 | description = "GraphQL over WebSocket Protocol implementations for `juniper` crate." 7 | license = "BSD-2-Clause" 8 | authors = [ 9 | "Christopher Brown ", 10 | "Kai Ren ", 11 | ] 12 | documentation = "https://docs.rs/juniper_graphql_ws" 13 | homepage = "https://github.com/graphql-rust/juniper/tree/master/juniper_graphql_ws" 14 | repository = "https://github.com/graphql-rust/juniper" 15 | readme = "README.md" 16 | categories = ["asynchronous", "web-programming", "web-programming::http-server"] 17 | keywords = ["apollo", "graphql-transport-ws", "graphql-ws", "subscription", "websocket"] 18 | exclude = ["/release.toml"] 19 | 20 | [package.metadata.docs.rs] 21 | all-features = true 22 | rustdoc-args = ["--cfg", "docsrs"] 23 | 24 | [features] 25 | graphql-transport-ws = [] 26 | graphql-ws = [] 27 | 28 | [dependencies] 29 | derive_more = { version = "2.0", features = ["debug", "from"] } 30 | juniper = { version = "0.16", path = "../juniper", default-features = false } 31 | juniper_subscriptions = { version = "0.17.0", path = "../juniper_subscriptions" } 32 | serde = { version = "1.0.122", features = ["derive"], default-features = false } 33 | tokio = { version = "1.0", features = ["macros", "rt", "time"], default-features = false } 34 | 35 | [dev-dependencies] 36 | serde_json = "1.0.18" 37 | 38 | [lints.clippy] 39 | allow_attributes = "warn" 40 | allow_attributes_without_reason = "warn" 41 | [lints.rust] 42 | closure_returning_async_block = "warn" 43 | future_incompatible = { level = "warn", priority = -1 } 44 | impl_trait_redundant_captures = "warn" 45 | missing_docs = "warn" 46 | non_ascii_idents = "forbid" 47 | unused_crate_dependencies = "warn" 48 | -------------------------------------------------------------------------------- /juniper_graphql_ws/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018-2025 Christopher Brown , 4 | Kai Ren 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /juniper_graphql_ws/release.toml: -------------------------------------------------------------------------------- 1 | [[pre-release-replacements]] 2 | file = "../juniper_actix/Cargo.toml" 3 | exactly = 1 4 | search = "juniper_graphql_ws = \\{ version = \"[^\"]+\"" 5 | replace = "juniper_graphql_ws = { version = \"{{version}}\"" 6 | 7 | [[pre-release-replacements]] 8 | file = "../juniper_axum/Cargo.toml" 9 | exactly = 1 10 | search = "juniper_graphql_ws = \\{ version = \"[^\"]+\"" 11 | replace = "juniper_graphql_ws = { version = \"{{version}}\"" 12 | 13 | [[pre-release-replacements]] 14 | file = "../juniper_warp/Cargo.toml" 15 | exactly = 1 16 | search = "juniper_graphql_ws = \\{ version = \"[^\"]+\"" 17 | replace = "juniper_graphql_ws = { version = \"{{version}}\"" 18 | 19 | [[pre-release-replacements]] 20 | file = "CHANGELOG.md" 21 | max = 1 22 | min = 0 23 | search = "## master" 24 | replace = "## [{{version}}] · {{date}}\n[{{version}}]: /../../tree/{{crate_name}}-v{{version}}/{{crate_name}}" 25 | 26 | [[pre-release-replacements]] 27 | file = "README.md" 28 | exactly = 2 29 | search = "graphql-rust/juniper/blob/[^/]+/" 30 | replace = "graphql-rust/juniper/blob/{{crate_name}}-v{{version}}/" 31 | -------------------------------------------------------------------------------- /juniper_graphql_ws/src/util.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Deserializer}; 2 | 3 | /// Deserializes `null`able value by placing the [`Default`] value instead of `null`. 4 | pub(crate) fn default_for_null<'de, D, T>(deserializer: D) -> Result 5 | where 6 | D: Deserializer<'de>, 7 | T: Deserialize<'de> + Default, 8 | { 9 | Ok(Option::::deserialize(deserializer)?.unwrap_or_default()) 10 | } 11 | -------------------------------------------------------------------------------- /juniper_hyper/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | `juniper_hyper` changelog 2 | ========================= 3 | 4 | All user visible changes to `juniper_hyper` crate will be documented in this file. This project uses [Semantic Versioning 2.0.0]. 5 | 6 | 7 | 8 | 9 | ## master 10 | 11 | ### BC Breaks 12 | 13 | - Bumped up [MSRV] to 1.85. ([#1263], [todo]) 14 | - Made `hyper::Request` in `graphql()` and `graphql_sync()` functions generic over `B: hyper::body::Body`. ([#1263], [#1102]) 15 | 16 | [#1102]: /../../issues/1102 17 | [#1263]: /../../pull/1263 18 | [todo]: /../../commit/todo 19 | 20 | 21 | 22 | 23 | ## [0.9.0] · 2024-03-20 24 | [0.9.0]: /../../tree/juniper_hyper-v0.9.0/juniper_hyper 25 | 26 | ### BC Breaks 27 | 28 | - Switched to 0.16 version of [`juniper` crate]. 29 | - Switched to 1 version of [`hyper` crate]. ([#1217]) 30 | - Changed return type of all functions from `Response` to `Response`. ([#1101], [#1096]) 31 | 32 | [#1096]: /../../issues/1096 33 | [#1101]: /../../pull/1101 34 | [#1217]: /../../pull/1217 35 | 36 | 37 | 38 | 39 | ## Previous releases 40 | 41 | See [old CHANGELOG](/../../blob/juniper_hyper-v0.8.0/juniper_hyper/CHANGELOG.md). 42 | 43 | 44 | 45 | 46 | [`juniper` crate]: https://docs.rs/juniper 47 | [`hyper` crate]: https://docs.rs/hyper 48 | [MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field 49 | [Semantic Versioning 2.0.0]: https://semver.org 50 | -------------------------------------------------------------------------------- /juniper_hyper/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "juniper_hyper" 3 | version = "0.9.0" 4 | edition = "2024" 5 | rust-version = "1.85" 6 | description = "`juniper` GraphQL integration with `hyper`." 7 | license = "BSD-2-Clause" 8 | authors = [ 9 | "Damir Vandic ", 10 | "Kai Ren ", 11 | ] 12 | documentation = "https://docs.rs/juniper_hyper" 13 | homepage = "https://github.com/graphql-rust/juniper/tree/master/juniper_hyper" 14 | repository = "https://github.com/graphql-rust/juniper" 15 | readme = "README.md" 16 | categories = ["asynchronous", "web-programming", "web-programming::http-server"] 17 | keywords = ["apollo", "graphql", "hyper", "juniper"] 18 | exclude = ["/examples/", "/release.toml"] 19 | 20 | [dependencies] 21 | derive_more = { version = "2.0", features = ["debug", "display", "error"] } 22 | http-body-util = "0.1" 23 | hyper = { version = "1.0", features = ["server"] } 24 | juniper = { version = "0.16", path = "../juniper", default-features = false } 25 | serde_json = "1.0.18" 26 | url = "2.0" 27 | 28 | [dev-dependencies] 29 | hyper = { version = "1.0", features = ["http1"] } 30 | hyper-util = { version = "0.1", features = ["tokio"] } 31 | juniper = { version = "0.16", path = "../juniper", features = ["expose-test-schema"] } 32 | log = "0.4" 33 | pretty_env_logger = "0.5" 34 | reqwest = { version = "0.12", features = ["blocking", "rustls-tls"], default-features = false } 35 | tokio = { version = "1.0", features = ["macros", "net", "rt-multi-thread"] } 36 | 37 | [lints.clippy] 38 | allow_attributes = "warn" 39 | allow_attributes_without_reason = "warn" 40 | [lints.rust] 41 | closure_returning_async_block = "warn" 42 | future_incompatible = { level = "warn", priority = -1 } 43 | impl_trait_redundant_captures = "warn" 44 | missing_docs = "warn" 45 | non_ascii_idents = "forbid" 46 | unsafe_code = "forbid" 47 | unused_crate_dependencies = "warn" 48 | -------------------------------------------------------------------------------- /juniper_hyper/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018-2025 Damir Vandic , 4 | Kai Ren 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /juniper_hyper/README.md: -------------------------------------------------------------------------------- 1 | `juniper_hyper` crate 2 | ===================== 3 | 4 | [![Crates.io](https://img.shields.io/crates/v/juniper_hyper.svg?maxAge=2592000)](https://crates.io/crates/juniper_hyper) 5 | [![Documentation](https://docs.rs/juniper_hyper/badge.svg)](https://docs.rs/juniper_hyper) 6 | [![CI](https://github.com/graphql-rust/juniper/actions/workflows/ci.yml/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) 7 | [![Rust 1.85+](https://img.shields.io/badge/rustc-1.85+-lightgray.svg "Rust 1.85+")](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0.html) 8 | 9 | - [Changelog](https://github.com/graphql-rust/juniper/blob/juniper_hyper-v0.9.0/juniper_hyper/CHANGELOG.md) 10 | 11 | [`hyper`] web server integration for [`juniper`] ([GraphQL] implementation for [Rust]). 12 | 13 | 14 | 15 | 16 | ## Documentation 17 | 18 | For documentation, including guides and examples, check out [Juniper Book]. 19 | 20 | A basic usage example can also be found in the [API docs][`juniper_hyper`]. 21 | 22 | 23 | 24 | 25 | ## Examples 26 | 27 | Check [`examples/hyper_server.rs`][1] for example code of a working [`hyper`] server with [GraphQL] handlers. 28 | 29 | 30 | 31 | 32 | ## License 33 | 34 | This project is licensed under [BSD 2-Clause License](https://github.com/graphql-rust/juniper/blob/juniper_hyper-v0.9.0/juniper_hyper/LICENSE). 35 | 36 | 37 | 38 | 39 | [`hyper`]: https://docs.rs/hyper 40 | [`juniper`]: https://docs.rs/juniper 41 | [`juniper_hyper`]: https://docs.rs/juniper_hyper 42 | [GraphQL]: http://graphql.org 43 | [Juniper Book]: https://graphql-rust.github.io/juniper 44 | [Rust]: https://www.rust-lang.org 45 | 46 | [1]: https://github.com/graphql-rust/juniper/blob/juniper_hyper-v0.9.0/juniper_hyper/examples/hyper_server.rs 47 | -------------------------------------------------------------------------------- /juniper_hyper/release.toml: -------------------------------------------------------------------------------- 1 | [[pre-release-replacements]] 2 | file = "CHANGELOG.md" 3 | max = 1 4 | min = 0 5 | search = "## master" 6 | replace = "## [{{version}}] · {{date}}\n[{{version}}]: /../../tree/{{crate_name}}-v{{version}}/{{crate_name}}" 7 | 8 | [[pre-release-replacements]] 9 | file = "README.md" 10 | exactly = 3 11 | search = "graphql-rust/juniper/blob/[^/]+/" 12 | replace = "graphql-rust/juniper/blob/{{crate_name}}-v{{version}}/" 13 | -------------------------------------------------------------------------------- /juniper_rocket/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | `juniper_rocket` changelog 2 | ========================== 3 | 4 | All user visible changes to `juniper_rocket` crate will be documented in this file. This project uses [Semantic Versioning 2.0.0]. 5 | 6 | 7 | 8 | 9 | ## master 10 | 11 | ### BC Breaks 12 | 13 | - Bumped up [MSRV] to 1.85. ([#1272], [todo]) 14 | 15 | [#1272]: /../../pull/1272 16 | [todo]: /../../commit/todo 17 | 18 | 19 | 20 | 21 | ## [0.9.0] · 2024-03-20 22 | [0.9.0]: /../../tree/juniper_rocket-v0.9.0/juniper_rocket 23 | 24 | ### BC Breaks 25 | 26 | - Switched to 0.16 version of [`juniper` crate]. 27 | - Switched to 0.5 version of [`rocket` crate]. ([#1205], [#1220]) 28 | 29 | ### Added 30 | 31 | - `AsRef` and `AsMut` implementation for `GraphQLRequest` to its inner type. ([#968], [#930]) 32 | 33 | ### Changed 34 | 35 | - Made `subscriptions_endpoint_url` argument polymorphic in `graphiql_source()` and `playground_source()`. ([#1223]) 36 | 37 | [#930]: /../../issues/930 38 | [#968]: /../../pull/968 39 | [#1205]: /../../pull/1205 40 | [#1220]: /../../pull/1220 41 | [#1223]: /../../pull/1223 42 | 43 | 44 | 45 | 46 | ## Previous releases 47 | 48 | See [old CHANGELOG](/../../blob/juniper_rocket-v0.8.2/juniper_rocket/CHANGELOG.md). 49 | 50 | 51 | 52 | 53 | [`juniper` crate]: https://docs.rs/juniper 54 | [`rocket` crate]: https://docs.rs/rocket 55 | [MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field 56 | [Semantic Versioning 2.0.0]: https://semver.org 57 | -------------------------------------------------------------------------------- /juniper_rocket/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "juniper_rocket" 3 | version = "0.9.0" 4 | edition = "2024" 5 | rust-version = "1.85" 6 | description = "`juniper` GraphQL integration with `rocket`." 7 | license = "BSD-2-Clause" 8 | authors = [ 9 | "Magnus Hallin ", 10 | "Christoph Herzog ", 11 | "Kai Ren ", 12 | ] 13 | documentation = "https://docs.rs/juniper_rocket" 14 | homepage = "https://github.com/graphql-rust/juniper/tree/master/juniper_rocket" 15 | repository = "https://github.com/graphql-rust/juniper" 16 | readme = "README.md" 17 | categories = ["asynchronous", "web-programming", "web-programming::http-server"] 18 | keywords = ["apollo", "graphql", "juniper", "rocket"] 19 | exclude = ["/examples/", "/tests/", "/release.toml"] 20 | 21 | [dependencies] 22 | derive_more = { version = "2.0", features = ["as_ref"] } 23 | juniper = { version = "0.16", path = "../juniper", default-features = false } 24 | rocket = { version = "0.5", default-features = false } 25 | serde_json = "1.0.18" 26 | 27 | # Fixes for `minimal-versions` check. 28 | # TODO: Try remove on upgrade of `rocket` crate. 29 | either = "1.8" 30 | inlinable_string = "0.1.15" 31 | pear = "0.2.4" 32 | tempfile = "3.3" 33 | 34 | [dev-dependencies] 35 | futures = "0.3.22" 36 | juniper = { version = "0.16", path = "../juniper", features = ["expose-test-schema"] } 37 | 38 | [lints.clippy] 39 | allow_attributes = "warn" 40 | allow_attributes_without_reason = "warn" 41 | [lints.rust] 42 | closure_returning_async_block = "warn" 43 | future_incompatible = { level = "warn", priority = -1 } 44 | impl_trait_redundant_captures = "warn" 45 | missing_docs = "warn" 46 | non_ascii_idents = "forbid" 47 | unsafe_code = "forbid" 48 | unused_crate_dependencies = "warn" 49 | -------------------------------------------------------------------------------- /juniper_rocket/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2016-2025 Magnus Hallin , 4 | Christoph Herzog , 5 | Kai Ren 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /juniper_rocket/README.md: -------------------------------------------------------------------------------- 1 | `juniper_rocket` crate 2 | ====================== 3 | 4 | [![Crates.io](https://img.shields.io/crates/v/juniper_rocket.svg?maxAge=2592000)](https://crates.io/crates/juniper_rocket) 5 | [![Documentation](https://docs.rs/juniper_rocket/badge.svg)](https://docs.rs/juniper_rocket) 6 | [![CI](https://github.com/graphql-rust/juniper/actions/workflows/ci.yml/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) 7 | [![Rust 1.85+](https://img.shields.io/badge/rustc-1.85+-lightgray.svg "Rust 1.85+")](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0.html) 8 | 9 | - [Changelog](https://github.com/graphql-rust/juniper/blob/juniper_rocket-v0.9.0/juniper_rocket/CHANGELOG.md) 10 | 11 | [`rocket`] web server integration for [`juniper`] ([GraphQL] implementation for [Rust]). 12 | 13 | 14 | 15 | 16 | ## Documentation 17 | 18 | For documentation, including guides and examples, check out [Juniper Book]. 19 | 20 | A basic usage example can also be found in the [API docs][`juniper_rocket`]. 21 | 22 | 23 | 24 | 25 | ## Examples 26 | 27 | Check [`examples/simple.rs`][1] for example code of a working [`rocket`] server with [GraphQL] handlers. 28 | 29 | 30 | 31 | 32 | ## License 33 | 34 | This project is licensed under [BSD 2-Clause License](https://github.com/graphql-rust/juniper/blob/juniper_rocket-v0.9.0/juniper_rocket/LICENSE). 35 | 36 | 37 | 38 | 39 | [`juniper`]: https://docs.rs/juniper 40 | [`juniper_rocket`]: https://docs.rs/juniper_rocket 41 | [`rocket`]: https://docs.rs/rocket 42 | [GraphQL]: http://graphql.org 43 | [Juniper Book]: https://graphql-rust.github.io/juniper 44 | [Rust]: https://www.rust-lang.org 45 | 46 | [1]: https://github.com/graphql-rust/juniper/blob/juniper_rocket-v0.9.0/juniper_rocket/examples/simple.rs 47 | -------------------------------------------------------------------------------- /juniper_rocket/release.toml: -------------------------------------------------------------------------------- 1 | [[pre-release-replacements]] 2 | file = "CHANGELOG.md" 3 | max = 1 4 | min = 0 5 | search = "## master" 6 | replace = "## [{{version}}] · {{date}}\n[{{version}}]: /../../tree/{{crate_name}}-v{{version}}/{{crate_name}}" 7 | 8 | [[pre-release-replacements]] 9 | file = "README.md" 10 | exactly = 3 11 | search = "graphql-rust/juniper/blob/[^/]+/" 12 | replace = "graphql-rust/juniper/blob/{{crate_name}}-v{{version}}/" 13 | -------------------------------------------------------------------------------- /juniper_rocket/tests/custom_response_tests.rs: -------------------------------------------------------------------------------- 1 | //! Ensuring that [`GraphQLResponse`] could be built by crate users. 2 | 3 | #![expect(unused_crate_dependencies, reason = "single test case")] 4 | 5 | use juniper_rocket::GraphQLResponse; 6 | use rocket::http::Status; 7 | 8 | #[test] 9 | fn test_graphql_response_is_public() { 10 | let _ = GraphQLResponse(Status::Unauthorized, "Unauthorized".into()); 11 | } 12 | -------------------------------------------------------------------------------- /juniper_subscriptions/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | `juniper_subscriptions` changelog 2 | ================================= 3 | 4 | All user visible changes to `juniper_subscriptions` crate will be documented in this file. This project uses [Semantic Versioning 2.0.0]. 5 | 6 | 7 | 8 | 9 | ## master 10 | 11 | ### BC Breaks 12 | 13 | - Removed lifetime parameters from `Coordinator`. ([#1247], [#819]) 14 | - Bumped up [MSRV] to 1.85. ([#1272], [todo]) 15 | 16 | [#819]: /../../issues/819 17 | [#1247]: /../../pull/1247 18 | [#1272]: /../../pull/1272 19 | [todo]: /../../commit/todo 20 | 21 | 22 | 23 | 24 | ## [0.17.0] · 2024-03-20 25 | [0.17.0]: /../../tree/juniper_subscriptions-v0.17.0/juniper_subscriptions 26 | 27 | ### BC Breaks 28 | 29 | - Switched to 0.16 version of [`juniper` crate]. 30 | 31 | 32 | 33 | 34 | ## Previous releases 35 | 36 | See [old CHANGELOG](/../../blob/juniper_subscriptions-v0.16.0/juniper_subscriptions/CHANGELOG.md). 37 | 38 | 39 | 40 | 41 | [`juniper` crate]: https://docs.rs/juniper 42 | [MSRV]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field 43 | [Semantic Versioning 2.0.0]: https://semver.org 44 | -------------------------------------------------------------------------------- /juniper_subscriptions/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "juniper_subscriptions" 3 | version = "0.17.0" 4 | edition = "2024" 5 | rust-version = "1.85" 6 | description = "Juniper `SubscriptionCoordinator` and `SubscriptionConnection` implementations." 7 | license = "BSD-2-Clause" 8 | authors = ["nWacky "] 9 | documentation = "https://docs.rs/juniper_subscriptions" 10 | homepage = "https://github.com/graphql-rust/juniper/tree/master/juniper_subscriptions" 11 | repository = "https://github.com/graphql-rust/juniper" 12 | readme = "README.md" 13 | categories = ["asynchronous", "web-programming", "web-programming::http-server"] 14 | keywords = ["graphql", "server", "subscription", "web", "websocket"] 15 | exclude = ["/release.toml"] 16 | 17 | [dependencies] 18 | futures = "0.3.22" 19 | juniper = { version = "0.16", path = "../juniper", default-features = false } 20 | 21 | [dev-dependencies] 22 | serde_json = "1.0.18" 23 | tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } 24 | 25 | [lints.clippy] 26 | allow_attributes = "warn" 27 | allow_attributes_without_reason = "warn" 28 | [lints.rust] 29 | closure_returning_async_block = "warn" 30 | future_incompatible = { level = "warn", priority = -1 } 31 | impl_trait_redundant_captures = "warn" 32 | missing_docs = "warn" 33 | non_ascii_idents = "forbid" 34 | unsafe_code = "forbid" 35 | unused_crate_dependencies = "warn" 36 | -------------------------------------------------------------------------------- /juniper_subscriptions/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018-2025 nWacky 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /juniper_subscriptions/release.toml: -------------------------------------------------------------------------------- 1 | [[pre-release-replacements]] 2 | file = "../juniper_graphql_ws/Cargo.toml" 3 | exactly = 1 4 | search = "juniper_subscriptions = \\{ version = \"[^\"]+\"" 5 | replace = "juniper_subscriptions = { version = \"{{version}}\"" 6 | 7 | [[pre-release-replacements]] 8 | file = "CHANGELOG.md" 9 | max = 1 10 | min = 0 11 | search = "## master" 12 | replace = "## [{{version}}] · {{date}}\n[{{version}}]: /../../tree/{{crate_name}}-v{{version}}/{{crate_name}}" 13 | 14 | [[pre-release-replacements]] 15 | file = "README.md" 16 | exactly = 3 17 | search = "graphql-rust/juniper/blob/[^/]+/" 18 | replace = "graphql-rust/juniper/blob/{{crate_name}}-v{{version}}/" 19 | 20 | [[pre-release-replacements]] 21 | file = "../book/src/schema/subscriptions.md" 22 | exactly = 2 23 | search = "docs.rs/juniper_subscriptions/[^/]+/" 24 | replace = "docs.rs/juniper_subscriptions/{{version}}/" 25 | -------------------------------------------------------------------------------- /juniper_warp/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018-2025 Tom Houlé , 4 | Kai Ren 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /juniper_warp/README.md: -------------------------------------------------------------------------------- 1 | `juniper_warp` crate 2 | ==================== 3 | 4 | [![Crates.io](https://img.shields.io/crates/v/juniper_warp.svg?maxAge=2592000)](https://crates.io/crates/juniper_warp) 5 | [![Documentation](https://docs.rs/juniper_warp/badge.svg)](https://docs.rs/juniper_warp) 6 | [![CI](https://github.com/graphql-rust/juniper/actions/workflows/ci.yml/badge.svg?branch=master "CI")](https://github.com/graphql-rust/juniper/actions?query=workflow%3ACI+branch%3Amaster) 7 | [![Rust 1.85+](https://img.shields.io/badge/rustc-1.85+-lightgray.svg "Rust 1.85+")](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0.html) 8 | 9 | - [Changelog](https://github.com/graphql-rust/juniper/blob/juniper_warp-v0.8.0/juniper_warp/CHANGELOG.md) 10 | 11 | [`warp`] web server integration for [`juniper`] ([GraphQL] implementation for [Rust]). 12 | 13 | 14 | 15 | 16 | ## Documentation 17 | 18 | For documentation, including guides and examples, check out [Juniper Book]. 19 | 20 | A basic usage example can also be found in the [API docs][`juniper_warp`]. 21 | 22 | 23 | 24 | 25 | ## Examples 26 | 27 | Check [`examples/subscription.rs`][1] for example code of a working [`warp`] server with [GraphQL] handlers and subscriptions. 28 | 29 | 30 | 31 | 32 | ## License 33 | 34 | This project is licensed under [BSD 2-Clause License](https://github.com/graphql-rust/juniper/blob/juniper_warp-v0.8.0/juniper_warp/LICENSE). 35 | 36 | 37 | 38 | 39 | [`juniper`]: https://docs.rs/juniper 40 | [`juniper_warp`]: https://docs.rs/juniper_warp 41 | [`warp`]: https://docs.rs/warp 42 | [GraphQL]: http://graphql.org 43 | [Juniper Book]: https://graphql-rust.github.io/juniper 44 | [Rust]: https://www.rust-lang.org 45 | 46 | [1]: https://github.com/graphql-rust/juniper/blob/juniper_warp-v0.8.0/juniper_warp/examples/subscription.rs 47 | -------------------------------------------------------------------------------- /juniper_warp/release.toml: -------------------------------------------------------------------------------- 1 | [[pre-release-replacements]] 2 | file = "CHANGELOG.md" 3 | max = 1 4 | min = 0 5 | search = "## master" 6 | replace = "## [{{version}}] · {{date}}\n[{{version}}]: /../../tree/{{crate_name}}-v{{version}}/{{crate_name}}" 7 | 8 | [[pre-release-replacements]] 9 | file = "README.md" 10 | exactly = 3 11 | search = "graphql-rust/juniper/blob/[^/]+/" 12 | replace = "graphql-rust/juniper/blob/{{crate_name}}-v{{version}}/" 13 | -------------------------------------------------------------------------------- /juniper_warp/src/response.rs: -------------------------------------------------------------------------------- 1 | //! [`JuniperResponse`] definition. 2 | 3 | use juniper::{DefaultScalarValue, ScalarValue, http::GraphQLBatchResponse}; 4 | use warp::{ 5 | http::{self, StatusCode}, 6 | reply::{self, Reply}, 7 | }; 8 | 9 | /// Wrapper around a [`GraphQLBatchResponse`], implementing [`warp::Reply`], so it can be returned 10 | /// from [`warp`] handlers. 11 | pub(crate) struct JuniperResponse(pub(crate) GraphQLBatchResponse) 12 | where 13 | S: ScalarValue; 14 | 15 | impl Reply for JuniperResponse 16 | where 17 | S: ScalarValue + Send, 18 | { 19 | fn into_response(self) -> reply::Response { 20 | match serde_json::to_vec(&self.0) { 21 | Ok(json) => http::Response::builder() 22 | .status(if self.0.is_ok() { 23 | StatusCode::OK 24 | } else { 25 | StatusCode::BAD_REQUEST 26 | }) 27 | .header("content-type", "application/json") 28 | .body(json.into()), 29 | Err(e) => http::Response::builder() 30 | .status(StatusCode::INTERNAL_SERVER_ERROR) 31 | .body(e.to_string().into()), 32 | } 33 | .unwrap_or_else(|e| { 34 | unreachable!("cannot build `reply::Response` out of `JuniperResponse`: {e}") 35 | }) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /release.toml: -------------------------------------------------------------------------------- 1 | allow-branch = ["*"] 2 | consolidate-commits = false 3 | pre-release-commit-message = "Prepare {{version}} release of `{{crate_name}}` crate" 4 | tag-message = "{{version}} version of `{{crate_name}}` crate" 5 | tag-name = "{{crate_name}}-v{{version}}" 6 | -------------------------------------------------------------------------------- /tests/codegen/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "juniper_codegen_tests" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dependencies] 8 | rustversion = "1.0" 9 | 10 | [dev-dependencies] 11 | futures = "0.3" 12 | juniper = { path = "../../juniper" } 13 | trybuild = "1.0.63" 14 | 15 | [lints.clippy] 16 | allow_attributes = "warn" 17 | allow_attributes_without_reason = "warn" 18 | [lints.rust] 19 | closure_returning_async_block = "warn" 20 | future_incompatible = { level = "warn", priority = -1 } 21 | impl_trait_redundant_captures = "warn" 22 | missing_docs = "warn" 23 | non_ascii_idents = "forbid" 24 | unsafe_code = "forbid" 25 | unused_crate_dependencies = "warn" 26 | -------------------------------------------------------------------------------- /tests/codegen/fail/enum/derive_duplicated_value_names.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLEnum; 2 | 3 | #[derive(GraphQLEnum)] 4 | enum Test { 5 | Test, 6 | #[graphql(name = "TEST")] 7 | Test1, 8 | } 9 | 10 | fn main() {} 11 | -------------------------------------------------------------------------------- /tests/codegen/fail/enum/derive_duplicated_value_names.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL enum expected all GraphQL enum values to have unique names 2 | --> fail/enum/derive_duplicated_value_names.rs:5:5 3 | | 4 | 5 | Test, 5 | | ^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/enum/derive_name_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLEnum; 2 | 3 | #[derive(GraphQLEnum)] 4 | enum __Test { 5 | Test, 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/enum/derive_name_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/enum/derive_name_double_underscored.rs:4:6 4 | | 5 | 4 | enum __Test { 6 | | ^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/enum/derive_no_values.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLEnum; 2 | 3 | #[derive(GraphQLEnum)] 4 | enum Test {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/enum/derive_no_values.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL enum expected at least 1 non-ignored enum variant 2 | --> fail/enum/derive_no_values.rs:3:10 3 | | 4 | 3 | #[derive(GraphQLEnum)] 5 | | ^^^^^^^^^^^ 6 | | 7 | = note: this error originates in the derive macro `GraphQLEnum` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/enum/derive_variant_with_field.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLEnum; 2 | 3 | #[derive(GraphQLEnum)] 4 | enum Test { 5 | Variant(i32), 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/enum/derive_variant_with_field.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL enum no fields allowed for non-ignored variants 2 | · note: https://spec.graphql.org/October2021#sec-Enums 3 | --> fail/enum/derive_variant_with_field.rs:5:12 4 | | 5 | 5 | Variant(i32), 6 | | ^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/enum/derive_wrong_item.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLEnum; 2 | 3 | #[derive(GraphQLEnum)] 4 | struct Test {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/enum/derive_wrong_item.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL enum can only be derived on enums 2 | --> fail/enum/derive_wrong_item.rs:4:1 3 | | 4 | 4 | struct Test {} 5 | | ^^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/input-object/derive_incompatible_field_type.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLInputObject, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | struct ObjectA { 5 | test: String, 6 | } 7 | 8 | #[derive(GraphQLInputObject)] 9 | struct Object { 10 | field: ObjectA, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/input-object/derive_no_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLInputObject; 2 | 3 | #[derive(GraphQLInputObject)] 4 | struct Object {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/input-object/derive_no_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL input object expected at least 1 non-ignored field 2 | --> fail/input-object/derive_no_fields.rs:4:15 3 | | 4 | 4 | struct Object {} 5 | | ^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/input-object/derive_no_underscore.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLInputObject; 2 | 3 | #[derive(GraphQLInputObject)] 4 | struct Object { 5 | #[graphql(name = "__test")] 6 | test: String, 7 | } 8 | 9 | fn main() {} 10 | -------------------------------------------------------------------------------- /tests/codegen/fail/input-object/derive_no_underscore.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/input-object/derive_no_underscore.rs:5:5 4 | | 5 | 5 | #[graphql(name = "__test")] 6 | | ^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/input-object/derive_unique_name.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLInputObject; 2 | 3 | #[derive(GraphQLInputObject)] 4 | struct Object { 5 | test: String, 6 | #[graphql(name = "test")] 7 | test2: String, 8 | } 9 | 10 | fn main() {} 11 | -------------------------------------------------------------------------------- /tests/codegen/fail/input-object/derive_unique_name.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL input object expected all fields to have unique names 2 | --> fail/input-object/derive_unique_name.rs:4:15 3 | | 4 | 4 | struct Object { 5 | | _______________^ 6 | 5 | | test: String, 7 | 6 | | #[graphql(name = "test")] 8 | 7 | | test2: String, 9 | 8 | | } 10 | | |_^ 11 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/attr_wrong_item.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | pub struct ObjA { 5 | test: String, 6 | } 7 | 8 | #[graphql_interface(for = ObjA)] 9 | enum Character {} 10 | 11 | fn main() {} 12 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/attr_wrong_item.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface #[graphql_interface] attribute is applicable to trait and struct definitions only 2 | --> fail/interface/attr_wrong_item.rs:9:1 3 | | 4 | 9 | enum Character {} 5 | | ^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/derive_wrong_item.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLInterface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | pub struct ObjA { 5 | test: String, 6 | } 7 | 8 | #[derive(GraphQLInterface)] 9 | #[graphql(for = ObjA)] 10 | enum Character {} 11 | 12 | fn main() {} 13 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/derive_wrong_item.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface can only be derived on structs 2 | --> fail/interface/derive_wrong_item.rs:9:1 3 | | 4 | 9 | #[graphql(for = ObjA)] 5 | | ^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_additional_non_nullable_argument.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, graphql_object}; 2 | 3 | pub struct ObjA { 4 | id: String, 5 | } 6 | 7 | #[graphql_object(impl = CharacterValue)] 8 | impl ObjA { 9 | fn id(&self, is_present: bool) -> &str { 10 | is_present.then_some(&*self.id).unwrap_or("missing") 11 | } 12 | } 13 | 14 | #[graphql_interface(for = ObjA)] 15 | struct Character { 16 | id: String, 17 | } 18 | 19 | fn main() {} 20 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_additional_non_nullable_argument.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/struct/attr_additional_non_nullable_argument.rs:16:5 3 | | 4 | 16 | id: String, 5 | | ^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: Field `id`: Argument `isPresent` of type `Boolean!` isn't present on the interface and so has to be nullable. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_cyclic_impl.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface(impl = Node2Value, for = Node2Value)] 4 | struct Node1 { 5 | id: String, 6 | } 7 | 8 | #[graphql_interface(impl = Node1Value, for = Node1Value)] 9 | struct Node2 { 10 | id: String, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_cyclic_impl.stderr: -------------------------------------------------------------------------------- 1 | error[E0391]: cycle detected when expanding type alias `Node1Value` 2 | --> fail/interface/struct/attr_cyclic_impl.rs:3:46 3 | | 4 | 3 | #[graphql_interface(impl = Node2Value, for = Node2Value)] 5 | | ^^^^^^^^^^ 6 | | 7 | note: ...which requires expanding type alias `Node2Value`... 8 | --> fail/interface/struct/attr_cyclic_impl.rs:8:46 9 | | 10 | 8 | #[graphql_interface(impl = Node1Value, for = Node1Value)] 11 | | ^^^^^^^^^^ 12 | = note: ...which again requires expanding type alias `Node1Value`, completing the cycle 13 | = note: type aliases cannot be recursive 14 | = help: consider using a struct, enum, or union instead to break the cycle 15 | = help: see for more information 16 | note: cycle used when computing type of `` 17 | --> fail/interface/struct/attr_cyclic_impl.rs:3:1 18 | | 19 | 3 | #[graphql_interface(impl = Node2Value, for = Node2Value)] 20 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information 22 | = note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) 23 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_field_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | struct Character { 5 | __id: String, 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_field_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/interface/struct/attr_field_double_underscored.rs:5:5 4 | | 5 | 5 | __id: String, 6 | | ^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_field_non_output_return_type.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLInputObject}; 2 | 3 | #[derive(GraphQLInputObject)] 4 | pub struct ObjB { 5 | id: i32, 6 | } 7 | 8 | #[graphql_interface] 9 | struct Character { 10 | id: ObjB, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_field_non_output_return_type.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied 2 | --> fail/interface/struct/attr_field_non_output_return_type.rs:8:1 3 | | 4 | 8 | #[graphql_interface] 5 | | ^^^^^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` 6 | | 7 | = help: the following other types implement trait `IsOutputType`: 8 | `&T` implements `IsOutputType` 9 | `Arc` implements `IsOutputType` 10 | `ArcStr` implements `IsOutputType<__S>` 11 | `Argument` implements `IsOutputType` 12 | `Box` implements `IsOutputType` 13 | `CharacterValueEnum` implements `IsOutputType<__S>` 14 | `EnumValue` implements `IsOutputType<__S>` 15 | `ID` implements `IsOutputType<__S>` 16 | and $N others 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_fields_duplicate.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | struct Character { 5 | id: String, 6 | 7 | #[graphql(name = "id")] 8 | id2: String, 9 | } 10 | 11 | fn main() {} 12 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_fields_duplicate.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface must have a different name for each field 2 | · note: https://spec.graphql.org/October2021#sec-Interfaces 3 | --> fail/interface/struct/attr_fields_duplicate.rs:4:1 4 | | 5 | 4 | struct Character { 6 | | ^^^^^^ 7 | 8 | error: cannot find attribute `graphql` in this scope 9 | --> fail/interface/struct/attr_fields_duplicate.rs:7:7 10 | | 11 | 7 | #[graphql(name = "id")] 12 | | ^^^^^^^ 13 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_implementers_duplicate_pretty.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: String, 7 | } 8 | 9 | #[graphql_interface(for = [ObjA, ObjA])] 10 | struct Character { 11 | id: String, 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_implementers_duplicate_pretty.stderr: -------------------------------------------------------------------------------- 1 | error: duplicated attribute argument found 2 | --> fail/interface/struct/attr_implementers_duplicate_pretty.rs:9:34 3 | | 4 | 9 | #[graphql_interface(for = [ObjA, ObjA])] 5 | | ^^^^ 6 | 7 | error[E0412]: cannot find type `CharacterValue` in this scope 8 | --> fail/interface/struct/attr_implementers_duplicate_pretty.rs:4:18 9 | | 10 | 4 | #[graphql(impl = CharacterValue)] 11 | | ^^^^^^^^^^^^^^ not found in this scope 12 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_implementers_duplicate_ugly.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: String, 7 | } 8 | 9 | type ObjAlias = ObjA; 10 | 11 | #[graphql_interface(for = [ObjA, ObjAlias])] 12 | struct Character { 13 | id: String, 14 | } 15 | 16 | fn main() {} 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_implementers_duplicate_ugly.stderr: -------------------------------------------------------------------------------- 1 | error[E0119]: conflicting implementations of trait `From` for type `CharacterValueEnum` 2 | --> fail/interface/struct/attr_implementers_duplicate_ugly.rs:11:1 3 | | 4 | 11 | #[graphql_interface(for = [ObjA, ObjAlias])] 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | | | 7 | | first implementation here 8 | | conflicting implementation for `CharacterValueEnum` 9 | | 10 | = note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) 11 | 12 | error[E0119]: conflicting implementations of trait `MutuallyExclusive` for type `ObjA` 13 | --> fail/interface/struct/attr_implementers_duplicate_ugly.rs:11:1 14 | | 15 | 11 | #[graphql_interface(for = [ObjA, ObjAlias])] 16 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | | | 18 | | first implementation here 19 | | conflicting implementation for `ObjA` 20 | | 21 | = note: this error originates in the macro `::juniper::sa::assert_type_ne_all` which comes from the expansion of the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) 22 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_missing_field.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | test: String, 7 | } 8 | 9 | #[graphql_interface(for = ObjA)] 10 | struct Character { 11 | id: String, 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_missing_for_attr.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: String, 7 | } 8 | 9 | #[graphql_interface] 10 | struct Character { 11 | id: String, 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_missing_for_attr.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/struct/attr_missing_for_attr.rs:3:10 3 | | 4 | 3 | #[derive(GraphQLObject)] 5 | | ^^^^^^^^^^^^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: missing implementer reference in interface's `for` attribute. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the derive macro `GraphQLObject` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_missing_impl_attr.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | pub struct ObjA { 5 | id: String, 6 | } 7 | 8 | #[graphql_interface(for = ObjA)] 9 | struct Character { 10 | id: String, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_missing_impl_attr.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/struct/attr_missing_impl_attr.rs:8:1 3 | | 4 | 8 | #[graphql_interface(for = ObjA)] 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: missing interface reference in implementer's `impl` attribute. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_missing_transitive_impl.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface(for = Node2Value)] 4 | struct Node1 { 5 | id: String, 6 | } 7 | 8 | #[graphql_interface(impl = Node1Value, for = Node3Value)] 9 | struct Node2 { 10 | id: String, 11 | } 12 | 13 | #[graphql_interface(impl = Node2Value)] 14 | struct Node3 { 15 | id: String, 16 | } 17 | 18 | fn main() {} 19 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_missing_transitive_impl.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/struct/attr_missing_transitive_impl.rs:8:46 3 | | 4 | 8 | #[graphql_interface(impl = Node1Value, for = Node3Value)] 5 | | ^^^^^^^^^^ evaluation panicked: Failed to implement interface `Node2` on `Node3`: missing `impl = ` for transitive interface `Node1` on `Node3`. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_transitive_impls` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_name_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | struct __Character { 5 | id: String, 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_name_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/interface/struct/attr_name_double_underscored.rs:4:8 4 | | 5 | 4 | struct __Character { 6 | | ^^^^^^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_no_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | struct Character {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_no_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface must have at least one field 2 | · note: https://spec.graphql.org/October2021#sec-Interfaces 3 | --> fail/interface/struct/attr_no_fields.rs:4:1 4 | | 5 | 4 | struct Character {} 6 | | ^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_non_subtype_return.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: Vec, 7 | } 8 | 9 | #[graphql_interface(for = ObjA)] 10 | struct Character { 11 | id: String, 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_non_subtype_return.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/struct/attr_non_subtype_return.rs:11:5 3 | | 4 | 11 | id: String, 5 | | ^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: Field `id`: implementor is expected to return a subtype of interface's return object: `[String!]!` is not a subtype of `String!`. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_unnamed_field.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | struct Character(i32); 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/attr_unnamed_field.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface expected named struct field 2 | · note: https://spec.graphql.org/October2021#sec-Interfaces 3 | --> fail/interface/struct/attr_unnamed_field.rs:4:18 4 | | 5 | 4 | struct Character(i32); 6 | | ^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_additional_non_nullable_argument.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_object, GraphQLInterface}; 2 | 3 | pub struct ObjA { 4 | id: String, 5 | } 6 | 7 | #[graphql_object(impl = CharacterValue)] 8 | impl ObjA { 9 | fn id(&self, is_present: bool) -> &str { 10 | is_present.then_some(&*self.id).unwrap_or("missing") 11 | } 12 | } 13 | 14 | #[derive(GraphQLInterface)] 15 | #[graphql(for = ObjA)] 16 | struct Character { 17 | id: String, 18 | } 19 | 20 | fn main() {} 21 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_additional_non_nullable_argument.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/struct/derive_additional_non_nullable_argument.rs:17:5 3 | | 4 | 17 | id: String, 5 | | ^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: Field `id`: Argument `isPresent` of type `Boolean!` isn't present on the interface and so has to be nullable. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_cyclic_impl.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLInterface; 2 | 3 | #[derive(GraphQLInterface)] 4 | #[graphql(impl = Node2Value, for = Node2Value)] 5 | struct Node1 { 6 | id: String, 7 | } 8 | 9 | #[derive(GraphQLInterface)] 10 | #[graphql(impl = Node1Value, for = Node1Value)] 11 | struct Node2 { 12 | id: String, 13 | } 14 | 15 | fn main() {} 16 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_cyclic_impl.stderr: -------------------------------------------------------------------------------- 1 | error[E0391]: cycle detected when expanding type alias `Node1Value` 2 | --> fail/interface/struct/derive_cyclic_impl.rs:4:36 3 | | 4 | 4 | #[graphql(impl = Node2Value, for = Node2Value)] 5 | | ^^^^^^^^^^ 6 | | 7 | note: ...which requires expanding type alias `Node2Value`... 8 | --> fail/interface/struct/derive_cyclic_impl.rs:10:36 9 | | 10 | 10 | #[graphql(impl = Node1Value, for = Node1Value)] 11 | | ^^^^^^^^^^ 12 | = note: ...which again requires expanding type alias `Node1Value`, completing the cycle 13 | = note: type aliases cannot be recursive 14 | = help: consider using a struct, enum, or union instead to break the cycle 15 | = help: see for more information 16 | note: cycle used when computing type of `` 17 | --> fail/interface/struct/derive_cyclic_impl.rs:3:10 18 | | 19 | 3 | #[derive(GraphQLInterface)] 20 | | ^^^^^^^^^^^^^^^^ 21 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information 22 | = note: this error originates in the derive macro `GraphQLInterface` (in Nightly builds, run with -Z macro-backtrace for more info) 23 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_field_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLInterface; 2 | 3 | #[derive(GraphQLInterface)] 4 | struct Character { 5 | __id: String, 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_field_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/interface/struct/derive_field_double_underscored.rs:5:5 4 | | 5 | 5 | __id: String, 6 | | ^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_field_non_output_return_type.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLInputObject, GraphQLInterface}; 2 | 3 | #[derive(GraphQLInputObject)] 4 | pub struct ObjB { 5 | id: i32, 6 | } 7 | 8 | #[derive(GraphQLInterface)] 9 | struct Character { 10 | id: ObjB, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_field_non_output_return_type.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied 2 | --> fail/interface/struct/derive_field_non_output_return_type.rs:8:10 3 | | 4 | 8 | #[derive(GraphQLInterface)] 5 | | ^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` 6 | | 7 | = help: the following other types implement trait `IsOutputType`: 8 | `&T` implements `IsOutputType` 9 | `Arc` implements `IsOutputType` 10 | `ArcStr` implements `IsOutputType<__S>` 11 | `Argument` implements `IsOutputType` 12 | `Box` implements `IsOutputType` 13 | `CharacterValueEnum` implements `IsOutputType<__S>` 14 | `EnumValue` implements `IsOutputType<__S>` 15 | `ID` implements `IsOutputType<__S>` 16 | and $N others 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_fields_duplicate.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLInterface; 2 | 3 | #[derive(GraphQLInterface)] 4 | struct Character { 5 | id: String, 6 | 7 | #[graphql(name = "id")] 8 | id2: String, 9 | } 10 | 11 | fn main() {} 12 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_fields_duplicate.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface must have a different name for each field 2 | · note: https://spec.graphql.org/October2021#sec-Interfaces 3 | --> fail/interface/struct/derive_fields_duplicate.rs:4:1 4 | | 5 | 4 | struct Character { 6 | | ^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_implementers_duplicate_pretty.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLInterface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: String, 7 | } 8 | 9 | #[derive(GraphQLInterface)] 10 | #[graphql(for = [ObjA, ObjA])] 11 | struct Character { 12 | id: String, 13 | } 14 | 15 | fn main() {} 16 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_implementers_duplicate_pretty.stderr: -------------------------------------------------------------------------------- 1 | error: duplicated attribute argument found 2 | --> fail/interface/struct/derive_implementers_duplicate_pretty.rs:10:24 3 | | 4 | 10 | #[graphql(for = [ObjA, ObjA])] 5 | | ^^^^ 6 | 7 | error[E0412]: cannot find type `CharacterValue` in this scope 8 | --> fail/interface/struct/derive_implementers_duplicate_pretty.rs:4:18 9 | | 10 | 4 | #[graphql(impl = CharacterValue)] 11 | | ^^^^^^^^^^^^^^ not found in this scope 12 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_implementers_duplicate_ugly.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLInterface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: String, 7 | } 8 | 9 | type ObjAlias = ObjA; 10 | 11 | #[derive(GraphQLInterface)] 12 | #[graphql(for = [ObjA, ObjAlias])] 13 | struct Character { 14 | id: String, 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_implementers_duplicate_ugly.stderr: -------------------------------------------------------------------------------- 1 | error[E0119]: conflicting implementations of trait `From` for type `CharacterValueEnum` 2 | --> fail/interface/struct/derive_implementers_duplicate_ugly.rs:11:10 3 | | 4 | 11 | #[derive(GraphQLInterface)] 5 | | ^^^^^^^^^^^^^^^^ 6 | | | 7 | | first implementation here 8 | | conflicting implementation for `CharacterValueEnum` 9 | | 10 | = note: this error originates in the derive macro `GraphQLInterface` (in Nightly builds, run with -Z macro-backtrace for more info) 11 | 12 | error[E0119]: conflicting implementations of trait `MutuallyExclusive` for type `ObjA` 13 | --> fail/interface/struct/derive_implementers_duplicate_ugly.rs:11:10 14 | | 15 | 11 | #[derive(GraphQLInterface)] 16 | | ^^^^^^^^^^^^^^^^ 17 | | | 18 | | first implementation here 19 | | conflicting implementation for `ObjA` 20 | | 21 | = note: this error originates in the macro `::juniper::sa::assert_type_ne_all` which comes from the expansion of the derive macro `GraphQLInterface` (in Nightly builds, run with -Z macro-backtrace for more info) 22 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_missing_field.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLInterface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | test: String, 7 | } 8 | 9 | #[derive(GraphQLInterface)] 10 | #[graphql(for = ObjA)] 11 | struct Character { 12 | id: String, 13 | } 14 | 15 | fn main() {} 16 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_missing_for_attr.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLInterface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: String, 7 | } 8 | 9 | #[derive(GraphQLInterface)] 10 | struct Character { 11 | id: String, 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_missing_for_attr.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/struct/derive_missing_for_attr.rs:3:10 3 | | 4 | 3 | #[derive(GraphQLObject)] 5 | | ^^^^^^^^^^^^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: missing implementer reference in interface's `for` attribute. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the derive macro `GraphQLObject` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_missing_impl_attr.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLInterface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | pub struct ObjA { 5 | id: String, 6 | } 7 | 8 | #[derive(GraphQLInterface)] 9 | #[graphql(for = ObjA)] 10 | struct Character { 11 | id: String, 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_missing_impl_attr.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/struct/derive_missing_impl_attr.rs:8:10 3 | | 4 | 8 | #[derive(GraphQLInterface)] 5 | | ^^^^^^^^^^^^^^^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: missing interface reference in implementer's `impl` attribute. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the derive macro `GraphQLInterface` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_missing_transitive_impl.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLInterface; 2 | 3 | #[derive(GraphQLInterface)] 4 | #[graphql(for = Node2Value)] 5 | struct Node1 { 6 | id: String, 7 | } 8 | 9 | #[derive(GraphQLInterface)] 10 | #[graphql(impl = Node1Value, for = Node3Value)] 11 | struct Node2 { 12 | id: String, 13 | } 14 | 15 | #[derive(GraphQLInterface)] 16 | #[graphql(impl = Node2Value)] 17 | struct Node3 { 18 | id: String, 19 | } 20 | 21 | fn main() {} 22 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_missing_transitive_impl.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/struct/derive_missing_transitive_impl.rs:10:36 3 | | 4 | 10 | #[graphql(impl = Node1Value, for = Node3Value)] 5 | | ^^^^^^^^^^ evaluation panicked: Failed to implement interface `Node2` on `Node3`: missing `impl = ` for transitive interface `Node1` on `Node3`. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_transitive_impls` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_name_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLInterface; 2 | 3 | #[derive(GraphQLInterface)] 4 | struct __Character { 5 | id: String, 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_name_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/interface/struct/derive_name_double_underscored.rs:4:8 4 | | 5 | 4 | struct __Character { 6 | | ^^^^^^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_no_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLInterface; 2 | 3 | #[derive(GraphQLInterface)] 4 | struct Character {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_no_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface must have at least one field 2 | · note: https://spec.graphql.org/October2021#sec-Interfaces 3 | --> fail/interface/struct/derive_no_fields.rs:4:1 4 | | 5 | 4 | struct Character {} 6 | | ^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_non_subtype_return.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLInterface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: Vec, 7 | } 8 | 9 | #[derive(GraphQLInterface)] 10 | #[graphql(for = ObjA)] 11 | struct Character { 12 | id: String, 13 | } 14 | 15 | fn main() {} 16 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_non_subtype_return.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/struct/derive_non_subtype_return.rs:12:5 3 | | 4 | 12 | id: String, 5 | | ^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: Field `id`: implementor is expected to return a subtype of interface's return object: `[String!]!` is not a subtype of `String!`. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_unnamed_field.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLInterface; 2 | 3 | #[derive(GraphQLInterface)] 4 | struct Character(i32); 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/struct/derive_unnamed_field.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface expected named struct field 2 | · note: https://spec.graphql.org/October2021#sec-Interfaces 3 | --> fail/interface/struct/derive_unnamed_field.rs:4:18 4 | | 5 | 4 | struct Character(i32); 6 | | ^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/additional_non_nullable_argument.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, graphql_object}; 2 | 3 | pub struct ObjA { 4 | id: String, 5 | } 6 | 7 | #[graphql_object(impl = CharacterValue)] 8 | impl ObjA { 9 | fn id(&self, is_present: bool) -> &str { 10 | is_present.then_some(&*self.id).unwrap_or("missing") 11 | } 12 | } 13 | 14 | #[graphql_interface(for = ObjA)] 15 | trait Character { 16 | fn id(&self) -> &str; 17 | } 18 | 19 | fn main() {} 20 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/additional_non_nullable_argument.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/trait/additional_non_nullable_argument.rs:16:8 3 | | 4 | 16 | fn id(&self) -> &str; 5 | | ^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: Field `id`: Argument `isPresent` of type `Boolean!` isn't present on the interface and so has to be nullable. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/argument_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | trait Character { 5 | fn id(&self, __num: i32) -> &str; 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/argument_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/interface/trait/argument_double_underscored.rs:5:18 4 | | 5 | 5 | fn id(&self, __num: i32) -> &str; 6 | | ^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/argument_non_input_type.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | pub struct ObjA { 5 | test: String, 6 | } 7 | 8 | #[graphql_interface] 9 | trait Character { 10 | fn id(&self, obj: ObjA) -> &str; 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/argument_wrong_default_array.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | trait Character { 5 | fn wrong(&self, #[graphql(default = [true, false, false])] input: [bool; 2]) -> bool; 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/argument_wrong_default_array.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `[bool; 2]: From<[bool; 3]>` is not satisfied 2 | --> fail/interface/trait/argument_wrong_default_array.rs:3:1 3 | | 4 | 3 | #[graphql_interface] 5 | | ^^^^^^^^^^^^^^^^^^^^ the trait `From<[bool; 3]>` is not implemented for `[bool; 2]` 6 | | 7 | = help: the following other types implement trait `From`: 8 | `[T; 10]` implements `From<(T, T, T, T, T, T, T, T, T, T)>` 9 | `[T; 11]` implements `From<(T, T, T, T, T, T, T, T, T, T, T)>` 10 | `[T; 12]` implements `From<(T, T, T, T, T, T, T, T, T, T, T, T)>` 11 | `[T; 1]` implements `From<(T,)>` 12 | `[T; 2]` implements `From<(T, T)>` 13 | `[T; 3]` implements `From<(T, T, T)>` 14 | `[T; 4]` implements `From<(T, T, T, T)>` 15 | `[T; 5]` implements `From<(T, T, T, T, T)>` 16 | and $N others 17 | = note: required for `[bool; 3]` to implement `Into<[bool; 2]>` 18 | = note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) 19 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/cyclic_impl.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface(impl = Node2Value, for = Node2Value)] 4 | trait Node1 { 5 | fn id(&self) -> &str; 6 | } 7 | 8 | #[graphql_interface(impl = Node1Value, for = Node1Value)] 9 | trait Node2 { 10 | fn id() -> String; 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/cyclic_impl.stderr: -------------------------------------------------------------------------------- 1 | error[E0391]: cycle detected when expanding type alias `Node1Value` 2 | --> fail/interface/trait/cyclic_impl.rs:3:46 3 | | 4 | 3 | #[graphql_interface(impl = Node2Value, for = Node2Value)] 5 | | ^^^^^^^^^^ 6 | | 7 | note: ...which requires expanding type alias `Node2Value`... 8 | --> fail/interface/trait/cyclic_impl.rs:8:46 9 | | 10 | 8 | #[graphql_interface(impl = Node1Value, for = Node1Value)] 11 | | ^^^^^^^^^^ 12 | = note: ...which again requires expanding type alias `Node1Value`, completing the cycle 13 | = note: type aliases cannot be recursive 14 | = help: consider using a struct, enum, or union instead to break the cycle 15 | = help: see for more information 16 | note: cycle used when computing type of `` 17 | --> fail/interface/trait/cyclic_impl.rs:3:1 18 | | 19 | 3 | #[graphql_interface(impl = Node2Value, for = Node2Value)] 20 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information 22 | = note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) 23 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/field_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | trait Character { 5 | fn __id(&self) -> &str; 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/field_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/interface/trait/field_double_underscored.rs:5:8 4 | | 5 | 5 | fn __id(&self) -> &str; 6 | | ^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/field_non_output_return_type.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLInputObject}; 2 | 3 | #[derive(GraphQLInputObject)] 4 | pub struct ObjB { 5 | id: i32, 6 | } 7 | 8 | #[graphql_interface] 9 | trait Character { 10 | fn id(&self) -> ObjB; 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/field_non_output_return_type.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied 2 | --> fail/interface/trait/field_non_output_return_type.rs:8:1 3 | | 4 | 8 | #[graphql_interface] 5 | | ^^^^^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` 6 | | 7 | = help: the following other types implement trait `IsOutputType`: 8 | `&T` implements `IsOutputType` 9 | `Arc` implements `IsOutputType` 10 | `ArcStr` implements `IsOutputType<__S>` 11 | `Argument` implements `IsOutputType` 12 | `Box` implements `IsOutputType` 13 | `CharacterValueEnum` implements `IsOutputType<__S>` 14 | `EnumValue` implements `IsOutputType<__S>` 15 | `ID` implements `IsOutputType<__S>` 16 | and $N others 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/fields_duplicate.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | trait Character { 5 | fn id(&self) -> &str; 6 | 7 | #[graphql(name = "id")] 8 | fn id2(&self) -> &str; 9 | } 10 | 11 | fn main() {} 12 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/fields_duplicate.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface must have a different name for each field 2 | · note: https://spec.graphql.org/October2021#sec-Interfaces 3 | --> fail/interface/trait/fields_duplicate.rs:4:1 4 | | 5 | 4 | trait Character { 6 | | ^^^^^ 7 | 8 | error: cannot find attribute `graphql` in this scope 9 | --> fail/interface/trait/fields_duplicate.rs:7:7 10 | | 11 | 7 | #[graphql(name = "id")] 12 | | ^^^^^^^ 13 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/implementers_duplicate_pretty.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: String, 7 | } 8 | 9 | #[graphql_interface(for = [ObjA, ObjA])] 10 | trait Character { 11 | fn id(&self) -> &str; 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/implementers_duplicate_pretty.stderr: -------------------------------------------------------------------------------- 1 | error: duplicated attribute argument found 2 | --> fail/interface/trait/implementers_duplicate_pretty.rs:9:34 3 | | 4 | 9 | #[graphql_interface(for = [ObjA, ObjA])] 5 | | ^^^^ 6 | 7 | error[E0412]: cannot find type `CharacterValue` in this scope 8 | --> fail/interface/trait/implementers_duplicate_pretty.rs:4:18 9 | | 10 | 4 | #[graphql(impl = CharacterValue)] 11 | | ^^^^^^^^^^^^^^ not found in this scope 12 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/implementers_duplicate_ugly.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: String, 7 | } 8 | 9 | type ObjAlias = ObjA; 10 | 11 | #[graphql_interface(for = [ObjA, ObjAlias])] 12 | trait Character { 13 | fn id(&self) -> &str; 14 | } 15 | 16 | fn main() {} 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/implementers_duplicate_ugly.stderr: -------------------------------------------------------------------------------- 1 | error[E0119]: conflicting implementations of trait `From` for type `CharacterValueEnum` 2 | --> fail/interface/trait/implementers_duplicate_ugly.rs:11:1 3 | | 4 | 11 | #[graphql_interface(for = [ObjA, ObjAlias])] 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | | | 7 | | first implementation here 8 | | conflicting implementation for `CharacterValueEnum` 9 | | 10 | = note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) 11 | 12 | error[E0119]: conflicting implementations of trait `MutuallyExclusive` for type `ObjA` 13 | --> fail/interface/trait/implementers_duplicate_ugly.rs:11:1 14 | | 15 | 11 | #[graphql_interface(for = [ObjA, ObjAlias])] 16 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 17 | | | 18 | | first implementation here 19 | | conflicting implementation for `ObjA` 20 | | 21 | = note: this error originates in the macro `::juniper::sa::assert_type_ne_all` which comes from the expansion of the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) 22 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/method_default_impl.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | trait Character { 5 | fn id(&self) -> &str { 6 | "default" 7 | } 8 | } 9 | 10 | fn main() {} 11 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/method_default_impl.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface trait method can't have default implementation 2 | · note: https://spec.graphql.org/October2021#sec-Interfaces 3 | --> fail/interface/trait/method_default_impl.rs:5:26 4 | | 5 | 5 | fn id(&self) -> &str { 6 | | __________________________^ 7 | 6 | | "default" 8 | 7 | | } 9 | | |_____^ 10 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/missing_field.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | test: String, 7 | } 8 | 9 | #[graphql_interface(for = ObjA)] 10 | trait Character { 11 | fn id(&self) -> &str; 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/missing_field_argument.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, graphql_object}; 2 | 3 | pub struct ObjA { 4 | id: String, 5 | } 6 | 7 | #[graphql_object(impl = CharacterValue)] 8 | impl ObjA { 9 | fn id(&self) -> &String { 10 | &self.id 11 | } 12 | } 13 | 14 | #[graphql_interface(for = ObjA)] 15 | trait Character { 16 | fn id(&self, is_present: bool) -> &str; 17 | } 18 | 19 | fn main() {} 20 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/missing_field_argument.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/trait/missing_field_argument.rs:16:8 3 | | 4 | 16 | fn id(&self, is_present: bool) -> &str; 5 | | ^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: Field `id`: Argument `isPresent` of type `Boolean!` was expected, but not found. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/missing_for_attr.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: String, 7 | } 8 | 9 | #[graphql_interface] 10 | trait Character { 11 | fn id(&self) -> &str; 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/missing_for_attr.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/trait/missing_for_attr.rs:3:10 3 | | 4 | 3 | #[derive(GraphQLObject)] 5 | | ^^^^^^^^^^^^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: missing implementer reference in interface's `for` attribute. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the derive macro `GraphQLObject` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/missing_impl_attr.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | pub struct ObjA { 5 | id: String, 6 | } 7 | 8 | #[graphql_interface(for = ObjA)] 9 | trait Character { 10 | fn id(&self) -> &str; 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/missing_impl_attr.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/trait/missing_impl_attr.rs:8:1 3 | | 4 | 8 | #[graphql_interface(for = ObjA)] 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: missing interface reference in implementer's `impl` attribute. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/missing_transitive_impl.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface(for = Node2Value)] 4 | trait Node1 { 5 | fn id() -> String; 6 | } 7 | 8 | #[graphql_interface(impl = Node1Value, for = Node3Value)] 9 | trait Node2 { 10 | fn id(&self) -> &str; 11 | } 12 | 13 | #[graphql_interface(impl = Node2Value)] 14 | trait Node3 { 15 | fn id() -> &'static str; 16 | } 17 | 18 | fn main() {} 19 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/missing_transitive_impl.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/trait/missing_transitive_impl.rs:8:46 3 | | 4 | 8 | #[graphql_interface(impl = Node1Value, for = Node3Value)] 5 | | ^^^^^^^^^^ evaluation panicked: Failed to implement interface `Node2` on `Node3`: missing `impl = ` for transitive interface `Node1` on `Node3`. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_transitive_impls` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/name_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | trait __Character { 5 | fn id(&self) -> &str; 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/name_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/interface/trait/name_double_underscored.rs:4:7 4 | | 5 | 4 | trait __Character { 6 | | ^^^^^^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/no_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | trait Character {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/no_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL interface must have at least one field 2 | · note: https://spec.graphql.org/October2021#sec-Interfaces 3 | --> fail/interface/trait/no_fields.rs:4:1 4 | | 5 | 4 | trait Character {} 6 | | ^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/non_subtype_return.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | #[graphql(impl = CharacterValue)] 5 | pub struct ObjA { 6 | id: Vec, 7 | } 8 | 9 | #[graphql_interface(for = ObjA)] 10 | trait Character { 11 | fn id(&self) -> &str; 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/non_subtype_return.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/trait/non_subtype_return.rs:11:8 3 | | 4 | 11 | fn id(&self) -> &str; 5 | | ^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: Field `id`: implementor is expected to return a subtype of interface's return object: `[String!]!` is not a subtype of `String!`. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/wrong_argument_type.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_interface, graphql_object}; 2 | 3 | pub struct ObjA { 4 | id: String, 5 | } 6 | 7 | #[graphql_object(impl = CharacterValue)] 8 | impl ObjA { 9 | fn id(&self, _is_present: i32) -> &str { 10 | &self.id 11 | } 12 | } 13 | 14 | #[graphql_interface(for = ObjA)] 15 | trait Character { 16 | fn id(&self, is_present: bool) -> &str; 17 | } 18 | 19 | fn main() {} 20 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/wrong_argument_type.stderr: -------------------------------------------------------------------------------- 1 | error[E0080]: evaluation of constant value failed 2 | --> fail/interface/trait/wrong_argument_type.rs:16:8 3 | | 4 | 16 | fn id(&self, is_present: bool) -> &str; 5 | | ^^ evaluation panicked: Failed to implement interface `Character` on `ObjA`: Field `id`: Argument `isPresent`: expected type `Boolean!`, found: `Int!`. 6 | | 7 | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `::juniper::assert_field` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/wrong_syntax.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_interface; 2 | 3 | #[graphql_interface] 4 | trait Character { 5 | fn id(&self) -> &str; 6 | 7 | #[graphql(ignore)] 8 | fn id2(&self) -> &str { 9 | self.self.id() 10 | } 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/interface/trait/wrong_syntax.stderr: -------------------------------------------------------------------------------- 1 | error: #[graphql_interface] attribute is applicable to trait and struct definitions only 2 | --> fail/interface/trait/wrong_syntax.rs:3:1 3 | | 4 | 3 | #[graphql_interface] 5 | | ^^^^^^^^^^^^^^^^^^^^ 6 | | 7 | = note: this error originates in the attribute macro `graphql_interface` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | 9 | error: cannot find attribute `graphql` in this scope 10 | --> fail/interface/trait/wrong_syntax.rs:7:7 11 | | 12 | 7 | #[graphql(ignore)] 13 | | ^^^^^^^ 14 | 15 | error[E0609]: no field `self` on type `&Self` 16 | --> fail/interface/trait/wrong_syntax.rs:9:14 17 | | 18 | 4 | trait Character { 19 | | --------------- type parameter 'Self' declared here 20 | ... 21 | 9 | self.self.id() 22 | | ^^^^ unknown field 23 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/argument_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_object; 2 | 3 | struct Obj; 4 | 5 | #[graphql_object] 6 | impl Obj { 7 | fn id(&self, __num: i32) -> &str { 8 | "funA" 9 | } 10 | } 11 | 12 | fn main() {} 13 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/argument_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/object/argument_double_underscored.rs:7:18 4 | | 5 | 7 | fn id(&self, __num: i32) -> &str { 6 | | ^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/argument_non_input_type.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_object, GraphQLObject}; 2 | 3 | #[derive(GraphQLObject)] 4 | struct ObjA { 5 | test: String, 6 | } 7 | 8 | struct ObjB; 9 | 10 | #[graphql_object] 11 | impl ObjB { 12 | fn id(&self, obj: ObjA) -> &str { 13 | "funA" 14 | } 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/argument_wrong_default_array.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_object; 2 | 3 | struct ObjA; 4 | 5 | #[graphql_object] 6 | impl ObjA { 7 | fn wrong(&self, #[graphql(default = [true, false, false])] input: [bool; 2]) -> bool { 8 | input[0] 9 | } 10 | } 11 | 12 | fn main() {} 13 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/argument_wrong_default_array.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `[bool; 2]: From<[bool; 3]>` is not satisfied 2 | --> fail/object/argument_wrong_default_array.rs:5:1 3 | | 4 | 5 | #[graphql_object] 5 | | ^^^^^^^^^^^^^^^^^ the trait `From<[bool; 3]>` is not implemented for `[bool; 2]` 6 | | 7 | = help: the following other types implement trait `From`: 8 | `[T; 10]` implements `From<(T, T, T, T, T, T, T, T, T, T)>` 9 | `[T; 11]` implements `From<(T, T, T, T, T, T, T, T, T, T, T)>` 10 | `[T; 12]` implements `From<(T, T, T, T, T, T, T, T, T, T, T, T)>` 11 | `[T; 1]` implements `From<(T,)>` 12 | `[T; 2]` implements `From<(T, T)>` 13 | `[T; 3]` implements `From<(T, T, T)>` 14 | `[T; 4]` implements `From<(T, T, T, T)>` 15 | `[T; 5]` implements `From<(T, T, T, T, T)>` 16 | and $N others 17 | = note: required for `[bool; 3]` to implement `Into<[bool; 2]>` 18 | = note: this error originates in the attribute macro `graphql_object` (in Nightly builds, run with -Z macro-backtrace for more info) 19 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_field_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_object; 2 | 3 | struct ObjA; 4 | 5 | #[graphql_object] 6 | impl ObjA { 7 | fn __id(&self) -> &str { 8 | "funA" 9 | } 10 | } 11 | 12 | fn main() {} 13 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_field_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/object/attr_field_double_underscored.rs:7:8 4 | | 5 | 7 | fn __id(&self) -> &str { 6 | | ^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_field_non_output_return_type.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_object, GraphQLInputObject}; 2 | 3 | #[derive(GraphQLInputObject)] 4 | struct ObjB { 5 | id: i32, 6 | } 7 | 8 | struct ObjA; 9 | 10 | #[graphql_object] 11 | impl ObjA { 12 | fn id(&self) -> ObjB { 13 | ObjB { id: 34 } 14 | } 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_field_non_output_return_type.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied 2 | --> fail/object/attr_field_non_output_return_type.rs:10:1 3 | | 4 | 10 | #[graphql_object] 5 | | ^^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` 6 | | 7 | = help: the following other types implement trait `IsOutputType`: 8 | `&T` implements `IsOutputType` 9 | `Arc` implements `IsOutputType` 10 | `ArcStr` implements `IsOutputType<__S>` 11 | `Argument` implements `IsOutputType` 12 | `Box` implements `IsOutputType` 13 | `EnumValue` implements `IsOutputType<__S>` 14 | `ID` implements `IsOutputType<__S>` 15 | `ObjA` implements `IsOutputType<__S>` 16 | and $N others 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_fields_duplicate.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_object; 2 | 3 | struct ObjA; 4 | 5 | #[graphql_object] 6 | impl ObjA { 7 | fn id(&self) -> &str { 8 | "funA" 9 | } 10 | 11 | #[graphql(name = "id")] 12 | fn id2(&self) -> &str { 13 | "funB" 14 | } 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_fields_duplicate.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL object must have a different name for each field 2 | · note: https://spec.graphql.org/October2021#sec-Objects 3 | --> fail/object/attr_fields_duplicate.rs:6:6 4 | | 5 | 6 | impl ObjA { 6 | | ^^^^ 7 | 8 | error: cannot find attribute `graphql` in this scope 9 | --> fail/object/attr_fields_duplicate.rs:11:7 10 | | 11 | 11 | #[graphql(name = "id")] 12 | | ^^^^^^^ 13 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_name_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_object; 2 | 3 | struct __Obj; 4 | 5 | #[graphql_object] 6 | impl __Obj { 7 | fn id(&self) -> &str { 8 | "funA" 9 | } 10 | } 11 | 12 | fn main() {} 13 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_name_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/object/attr_name_double_underscored.rs:6:6 4 | | 5 | 6 | impl __Obj { 6 | | ^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_no_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_object; 2 | 3 | struct Obj; 4 | 5 | #[graphql_object] 6 | impl Obj {} 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_no_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL object must have at least one field 2 | · note: https://spec.graphql.org/October2021#sec-Objects 3 | --> fail/object/attr_no_fields.rs:6:6 4 | | 5 | 6 | impl Obj {} 6 | | ^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_wrong_item.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_object; 2 | 3 | #[graphql_object] 4 | enum Character {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_wrong_item.stderr: -------------------------------------------------------------------------------- 1 | error: #[graphql_object] attribute is applicable to non-trait `impl` blocks only 2 | --> fail/object/attr_wrong_item.rs:3:1 3 | | 4 | 3 | #[graphql_object] 5 | | ^^^^^^^^^^^^^^^^^ 6 | | 7 | = note: this error originates in the attribute macro `graphql_object` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_wrong_syntax.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_object; 2 | 3 | struct MyObject { 4 | my_field: i32, 5 | } 6 | 7 | #[graphql_object] 8 | impl MyObject { 9 | fn my_field(&self) -> i32 { 10 | self.self.my_field 11 | } 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/attr_wrong_syntax.stderr: -------------------------------------------------------------------------------- 1 | error: #[graphql_object] attribute is applicable to non-trait `impl` blocks only 2 | --> fail/object/attr_wrong_syntax.rs:7:1 3 | | 4 | 7 | #[graphql_object] 5 | | ^^^^^^^^^^^^^^^^^ 6 | | 7 | = note: this error originates in the attribute macro `graphql_object` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | 9 | error[E0609]: no field `self` on type `&MyObject` 10 | --> fail/object/attr_wrong_syntax.rs:10:14 11 | | 12 | 10 | self.self.my_field 13 | | ^^^^ unknown field 14 | | 15 | = note: available field is: `my_field` 16 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_field_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLObject; 2 | 3 | #[derive(GraphQLObject)] 4 | struct Object { 5 | __test: String, 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_field_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/object/derive_field_double_underscored.rs:5:5 4 | | 5 | 5 | __test: String, 6 | | ^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_field_non_output_return_type.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLInputObject, GraphQLObject}; 2 | 3 | #[derive(GraphQLInputObject)] 4 | struct ObjB { 5 | id: i32, 6 | } 7 | 8 | #[derive(GraphQLObject)] 9 | struct ObjA { 10 | id: ObjB, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_field_non_output_return_type.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied 2 | --> fail/object/derive_field_non_output_return_type.rs:8:10 3 | | 4 | 8 | #[derive(GraphQLObject)] 5 | | ^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` 6 | | 7 | = help: the following other types implement trait `IsOutputType`: 8 | `&T` implements `IsOutputType` 9 | `Arc` implements `IsOutputType` 10 | `ArcStr` implements `IsOutputType<__S>` 11 | `Argument` implements `IsOutputType` 12 | `Box` implements `IsOutputType` 13 | `EnumValue` implements `IsOutputType<__S>` 14 | `ID` implements `IsOutputType<__S>` 15 | `ObjA` implements `IsOutputType<__S>` 16 | and $N others 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_fields_duplicate.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLObject; 2 | 3 | #[derive(GraphQLObject)] 4 | struct ObjA { 5 | id: String, 6 | #[graphql(name = "id")] 7 | id2: String, 8 | } 9 | 10 | fn main() {} 11 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_fields_duplicate.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL object must have a different name for each field 2 | · note: https://spec.graphql.org/October2021#sec-Objects 3 | --> fail/object/derive_fields_duplicate.rs:4:1 4 | | 5 | 4 | struct ObjA { 6 | | ^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_name_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLObject; 2 | 3 | #[derive(GraphQLObject)] 4 | struct __Obj { 5 | id: String, 6 | } 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_name_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/object/derive_name_double_underscored.rs:4:8 4 | | 5 | 4 | struct __Obj { 6 | | ^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_no_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLObject; 2 | 3 | #[derive(GraphQLObject)] 4 | struct Obj {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_no_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL object must have at least one field 2 | · note: https://spec.graphql.org/October2021#sec-Objects 3 | --> fail/object/derive_no_fields.rs:4:1 4 | | 5 | 4 | struct Obj {} 6 | | ^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_wrong_item.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLObject; 2 | 3 | #[derive(GraphQLObject)] 4 | enum Character {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/object/derive_wrong_item.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL object can only be derived for structs 2 | --> fail/object/derive_wrong_item.rs:4:1 3 | | 4 | 4 | enum Character {} 5 | | ^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/attr_invalid_url.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_scalar; 2 | 3 | #[graphql_scalar(specified_by_url = "not an url", transparent)] 4 | struct ScalarSpecifiedByUrl(i32); 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/attr_invalid_url.stderr: -------------------------------------------------------------------------------- 1 | error: Invalid URL: relative URL without a base 2 | --> fail/scalar/derive_input/attr_invalid_url.rs:3:37 3 | | 4 | 3 | #[graphql_scalar(specified_by_url = "not an url", transparent)] 5 | | ^^^^^^^^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/attr_transparent_and_with.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_scalar; 2 | 3 | #[graphql_scalar(with = Self, transparent)] 4 | struct Scalar; 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/attr_transparent_and_with.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL scalar `with = ` attribute argument cannot be combined with `transparent`. You can specify custom resolvers with `to_output_with`, `from_input_with`, `parse_token`/`parse_token_with` attribute arguments and still use `transparent` for unspecified ones. 2 | --> fail/scalar/derive_input/attr_transparent_and_with.rs:3:25 3 | | 4 | 3 | #[graphql_scalar(with = Self, transparent)] 5 | | ^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_named_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_scalar; 2 | 3 | #[graphql_scalar(transparent)] 4 | struct Scalar { 5 | id: i32, 6 | another: i32, 7 | } 8 | 9 | fn main() {} 10 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_named_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL scalar `transparent` attribute argument requires exactly 1 field 2 | --> fail/scalar/derive_input/attr_transparent_multiple_named_fields.rs:4:1 3 | | 4 | 4 | struct Scalar { 5 | | ^^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_unnamed_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_scalar; 2 | 3 | #[graphql_scalar(transparent)] 4 | struct Scalar(i32, i32); 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/attr_transparent_multiple_unnamed_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL scalar `transparent` attribute argument requires exactly 1 field 2 | --> fail/scalar/derive_input/attr_transparent_multiple_unnamed_fields.rs:4:1 3 | | 4 | 4 | struct Scalar(i32, i32); 5 | | ^^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/attr_transparent_unit_struct.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_scalar; 2 | 3 | #[graphql_scalar(transparent)] 4 | struct ScalarSpecifiedByUrl; 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/attr_transparent_unit_struct.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL scalar `transparent` attribute argument requires exactly 1 field 2 | --> fail/scalar/derive_input/attr_transparent_unit_struct.rs:4:1 3 | | 4 | 4 | struct ScalarSpecifiedByUrl; 5 | | ^^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/derive_invalid_url.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLScalar; 2 | 3 | #[derive(GraphQLScalar)] 4 | #[graphql(specified_by_url = "not an url", transparent)] 5 | struct ScalarSpecifiedByUrl(i64); 6 | 7 | fn main() {} 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/derive_invalid_url.stderr: -------------------------------------------------------------------------------- 1 | error: Invalid URL: relative URL without a base 2 | --> fail/scalar/derive_input/derive_invalid_url.rs:4:30 3 | | 4 | 4 | #[graphql(specified_by_url = "not an url", transparent)] 5 | | ^^^^^^^^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/derive_transparent_and_with.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLScalar; 2 | 3 | #[derive(GraphQLScalar)] 4 | #[graphql(with = Self, transparent)] 5 | struct Scalar; 6 | 7 | fn main() {} 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/derive_transparent_and_with.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL scalar `with = ` attribute argument cannot be combined with `transparent`. You can specify custom resolvers with `to_output_with`, `from_input_with`, `parse_token`/`parse_token_with` attribute arguments and still use `transparent` for unspecified ones. 2 | --> fail/scalar/derive_input/derive_transparent_and_with.rs:4:18 3 | | 4 | 4 | #[graphql(with = Self, transparent)] 5 | | ^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_named_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLScalar; 2 | 3 | #[derive(GraphQLScalar)] 4 | #[graphql(transparent)] 5 | struct Scalar { 6 | id: i32, 7 | another: i32, 8 | } 9 | 10 | fn main() {} 11 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_named_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL scalar `transparent` attribute argument requires exactly 1 field 2 | --> fail/scalar/derive_input/derive_transparent_multiple_named_fields.rs:4:1 3 | | 4 | 4 | #[graphql(transparent)] 5 | | ^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_unnamed_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLScalar; 2 | 3 | #[derive(GraphQLScalar)] 4 | #[graphql(transparent)] 5 | struct Scalar(i32, i32); 6 | 7 | fn main() {} 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/derive_transparent_multiple_unnamed_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL scalar `transparent` attribute argument requires exactly 1 field 2 | --> fail/scalar/derive_input/derive_transparent_multiple_unnamed_fields.rs:4:1 3 | | 4 | 4 | #[graphql(transparent)] 5 | | ^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/derive_transparent_unit_struct.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLScalar; 2 | 3 | #[derive(GraphQLScalar)] 4 | #[graphql(transparent)] 5 | struct ScalarSpecifiedByUrl; 6 | 7 | fn main() {} 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/derive_input/derive_transparent_unit_struct.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL scalar `transparent` attribute argument requires exactly 1 field 2 | --> fail/scalar/derive_input/derive_transparent_unit_struct.rs:4:1 3 | | 4 | 4 | #[graphql(transparent)] 5 | | ^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/type_alias/attr_invalid_url.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_scalar, InputValue, ScalarValue, Value}; 2 | 3 | struct ScalarSpecifiedByUrl; 4 | 5 | #[graphql_scalar( 6 | specified_by_url = "not an url", 7 | with = scalar, 8 | parse_token(i32), 9 | )] 10 | type Scalar = ScalarSpecifiedByUrl; 11 | 12 | mod scalar { 13 | use super::*; 14 | 15 | pub(super) fn to_output(_: &ScalarSpecifiedByUrl) -> Value { 16 | Value::scalar(0) 17 | } 18 | 19 | pub(super) fn from_input( 20 | _: &InputValue, 21 | ) -> Result { 22 | Ok(ScalarSpecifiedByUrl) 23 | } 24 | } 25 | 26 | fn main() {} 27 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/type_alias/attr_invalid_url.stderr: -------------------------------------------------------------------------------- 1 | error: Invalid URL: relative URL without a base 2 | --> fail/scalar/type_alias/attr_invalid_url.rs:6:24 3 | | 4 | 6 | specified_by_url = "not an url", 5 | | ^^^^^^^^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/type_alias/attr_with_not_all_resolvers.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_scalar, Value}; 2 | 3 | struct Scalar; 4 | 5 | #[graphql_scalar(to_output_with = Scalar::to_output)] 6 | type CustomScalar = Scalar; 7 | 8 | impl Scalar { 9 | fn to_output(&self) -> Value { 10 | Value::scalar(0) 11 | } 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/type_alias/attr_with_not_all_resolvers.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL scalar all the resolvers have to be provided via `with` attribute argument or a combination of `to_output_with`, `from_input_with`, `parse_token_with`/`parse_token` attribute arguments 2 | --> fail/scalar/type_alias/attr_with_not_all_resolvers.rs:6:1 3 | | 4 | 6 | type CustomScalar = Scalar; 5 | | ^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/type_alias/attr_without_resolvers.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_scalar; 2 | 3 | struct Scalar; 4 | 5 | #[graphql_scalar] 6 | type CustomScalar = Scalar; 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar/type_alias/attr_without_resolvers.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL scalar all the resolvers have to be provided via `with` attribute argument or a combination of `to_output_with`, `from_input_with`, `parse_token_with`/`parse_token` attribute arguments 2 | --> fail/scalar/type_alias/attr_without_resolvers.rs:6:1 3 | | 4 | 6 | type CustomScalar = Scalar; 5 | | ^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar_value/missing_attributes.rs: -------------------------------------------------------------------------------- 1 | use juniper::ScalarValue; 2 | 3 | #[derive(Clone, Debug, PartialEq, ScalarValue)] 4 | pub enum DefaultScalarValue { 5 | Int(i32), 6 | Float(f64), 7 | #[value(as_str, as_string, into_string)] 8 | String(String), 9 | #[value(as_bool)] 10 | Boolean(bool), 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar_value/missing_attributes.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL built-in scalars missing `#[value(as_int, as_float)]` attributes. In case you are sure that it's ok, use `#[value(allow_missing_attributes)]` to suppress this error. 2 | --> fail/scalar_value/missing_attributes.rs:4:1 3 | | 4 | 4 | pub enum DefaultScalarValue { 5 | | ^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar_value/multiple_named_fields.rs: -------------------------------------------------------------------------------- 1 | #[derive(juniper::ScalarValue)] 2 | enum ScalarValue { 3 | Variant { first: i32, second: u64 }, 4 | } 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar_value/multiple_named_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL built-in scalars expected exactly 1 field 2 | --> fail/scalar_value/multiple_named_fields.rs:3:13 3 | | 4 | 3 | Variant { first: i32, second: u64 }, 5 | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar_value/multiple_unnamed_fields.rs: -------------------------------------------------------------------------------- 1 | #[derive(juniper::ScalarValue)] 2 | enum ScalarValue { 3 | Variant(u32, i64), 4 | } 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar_value/multiple_unnamed_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL built-in scalars expected exactly 1 field 2 | --> fail/scalar_value/multiple_unnamed_fields.rs:3:12 3 | | 4 | 3 | Variant(u32, i64), 5 | | ^^^^^^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar_value/not_enum.rs: -------------------------------------------------------------------------------- 1 | #[derive(juniper::ScalarValue)] 2 | struct ScalarValue; 3 | 4 | fn main() {} 5 | -------------------------------------------------------------------------------- /tests/codegen/fail/scalar_value/not_enum.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL built-in scalars can only be derived for enums 2 | --> fail/scalar_value/not_enum.rs:2:1 3 | | 4 | 2 | struct ScalarValue; 5 | | ^^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/argument_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use std::{future, pin::Pin}; 2 | 3 | use futures::{stream, Stream}; 4 | use juniper::graphql_subscription; 5 | 6 | type BoxStream<'a, I> = Pin + Send + 'a>>; 7 | 8 | struct Obj; 9 | 10 | #[graphql_subscription] 11 | impl Obj { 12 | async fn id(&self, __num: i32) -> BoxStream<'static, &'static str> { 13 | Box::pin(stream::once(future::ready("funA"))) 14 | } 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/argument_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/subscription/argument_double_underscored.rs:12:24 4 | | 5 | 12 | async fn id(&self, __num: i32) -> BoxStream<'static, &'static str> { 6 | | ^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/argument_non_input_type.rs: -------------------------------------------------------------------------------- 1 | use std::{future, pin::Pin}; 2 | 3 | use futures::{stream, Stream}; 4 | use juniper::{graphql_subscription, GraphQLObject}; 5 | 6 | type BoxStream<'a, I> = Pin + Send + 'a>>; 7 | 8 | #[derive(GraphQLObject)] 9 | struct ObjA { 10 | test: String, 11 | } 12 | 13 | struct ObjB; 14 | 15 | #[graphql_subscription] 16 | impl ObjB { 17 | async fn id(&self, obj: ObjA) -> BoxStream<'static, &'static str> { 18 | Box::pin(stream::once(future::ready("funA"))) 19 | } 20 | } 21 | 22 | fn main() {} 23 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/argument_wrong_default_array.rs: -------------------------------------------------------------------------------- 1 | use std::{future, pin::Pin}; 2 | 3 | use futures::{stream, Stream}; 4 | use juniper::graphql_subscription; 5 | 6 | type BoxStream<'a, I> = Pin + Send + 'a>>; 7 | 8 | struct ObjA; 9 | 10 | #[graphql_subscription] 11 | impl ObjA { 12 | async fn wrong( 13 | &self, 14 | #[graphql(default = [true, false, false])] input: [bool; 2], 15 | ) -> BoxStream<'static, bool> { 16 | Box::pin(stream::once(future::ready(input[0]))) 17 | } 18 | } 19 | 20 | fn main() {} 21 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/argument_wrong_default_array.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `[bool; 2]: From<[bool; 3]>` is not satisfied 2 | --> fail/subscription/argument_wrong_default_array.rs:10:1 3 | | 4 | 10 | #[graphql_subscription] 5 | | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<[bool; 3]>` is not implemented for `[bool; 2]` 6 | | 7 | = help: the following other types implement trait `From`: 8 | `[T; 10]` implements `From<(T, T, T, T, T, T, T, T, T, T)>` 9 | `[T; 11]` implements `From<(T, T, T, T, T, T, T, T, T, T, T)>` 10 | `[T; 12]` implements `From<(T, T, T, T, T, T, T, T, T, T, T, T)>` 11 | `[T; 1]` implements `From<(T,)>` 12 | `[T; 2]` implements `From<(T, T)>` 13 | `[T; 3]` implements `From<(T, T, T)>` 14 | `[T; 4]` implements `From<(T, T, T, T)>` 15 | `[T; 5]` implements `From<(T, T, T, T, T)>` 16 | and $N others 17 | = note: required for `[bool; 3]` to implement `Into<[bool; 2]>` 18 | = note: this error originates in the attribute macro `graphql_subscription` (in Nightly builds, run with -Z macro-backtrace for more info) 19 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/field_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use std::{future, pin::Pin}; 2 | 3 | use futures::{stream, Stream}; 4 | use juniper::graphql_subscription; 5 | 6 | type BoxStream<'a, I> = Pin + Send + 'a>>; 7 | 8 | struct ObjA; 9 | 10 | #[graphql_subscription] 11 | impl ObjA { 12 | async fn __id() -> BoxStream<'static, &'static str> { 13 | Box::pin(stream::once(future::ready("funA"))) 14 | } 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/field_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/subscription/field_double_underscored.rs:12:14 4 | | 5 | 12 | async fn __id() -> BoxStream<'static, &'static str> { 6 | | ^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/field_non_output_return_type.rs: -------------------------------------------------------------------------------- 1 | use std::{future, pin::Pin}; 2 | 3 | use futures::{stream, Stream}; 4 | use juniper::{graphql_subscription, GraphQLInputObject}; 5 | 6 | type BoxStream<'a, I> = Pin + Send + 'a>>; 7 | 8 | #[derive(GraphQLInputObject)] 9 | struct ObjB { 10 | id: i32, 11 | } 12 | 13 | struct ObjA; 14 | 15 | #[graphql_subscription] 16 | impl ObjA { 17 | async fn id(&self) -> BoxStream<'static, ObjB> { 18 | Box::pin(stream::once(future::ready(ObjB { id: 34 }))) 19 | } 20 | } 21 | 22 | fn main() {} 23 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/field_non_output_return_type.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `ObjB: IsOutputType<__S>` is not satisfied 2 | --> fail/subscription/field_non_output_return_type.rs:15:1 3 | | 4 | 15 | #[graphql_subscription] 5 | | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `IsOutputType<__S>` is not implemented for `ObjB` 6 | | 7 | = help: the following other types implement trait `IsOutputType`: 8 | `&T` implements `IsOutputType` 9 | `Arc` implements `IsOutputType` 10 | `ArcStr` implements `IsOutputType<__S>` 11 | `Argument` implements `IsOutputType` 12 | `Box` implements `IsOutputType` 13 | `EnumValue` implements `IsOutputType<__S>` 14 | `ID` implements `IsOutputType<__S>` 15 | `ObjA` implements `IsOutputType<__S>` 16 | and $N others 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/field_not_async.rs: -------------------------------------------------------------------------------- 1 | use std::{future, pin::Pin}; 2 | 3 | use futures::{stream, Stream}; 4 | use juniper::graphql_subscription; 5 | 6 | type BoxStream<'a, I> = Pin + Send + 'a>>; 7 | 8 | struct ObjA; 9 | 10 | #[graphql_subscription] 11 | impl ObjA { 12 | fn id(&self) -> BoxStream<'static, bool> { 13 | Box::pin(stream::once(future::ready(true))) 14 | } 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/field_not_async.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL object synchronous resolvers are not supported 2 | · note: https://spec.graphql.org/October2021#sec-Objects 3 | · note: Specify that this function is async: `async fn foo()` 4 | --> fail/subscription/field_not_async.rs:12:5 5 | | 6 | 12 | fn id(&self) -> BoxStream<'static, bool> { 7 | | ^^ 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/fields_duplicate.rs: -------------------------------------------------------------------------------- 1 | use std::{future, pin::Pin}; 2 | 3 | use futures::{stream, Stream}; 4 | use juniper::graphql_subscription; 5 | 6 | type BoxStream<'a, I> = Pin + Send + 'a>>; 7 | 8 | struct ObjA; 9 | 10 | #[graphql_subscription] 11 | impl ObjA { 12 | async fn id(&self) -> BoxStream<'static, &'static str> { 13 | Box::pin(stream::once(future::ready("funA"))) 14 | } 15 | 16 | #[graphql(name = "id")] 17 | async fn id2(&self) -> BoxStream<'static, &'static str> { 18 | Box::pin(stream::once(future::ready("funB"))) 19 | } 20 | } 21 | 22 | fn main() {} 23 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/fields_duplicate.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL object must have a different name for each field 2 | · note: https://spec.graphql.org/October2021#sec-Objects 3 | --> fail/subscription/fields_duplicate.rs:11:6 4 | | 5 | 11 | impl ObjA { 6 | | ^^^^ 7 | 8 | error: cannot find attribute `graphql` in this scope 9 | --> fail/subscription/fields_duplicate.rs:16:7 10 | | 11 | 16 | #[graphql(name = "id")] 12 | | ^^^^^^^ 13 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/name_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use std::{future, pin::Pin}; 2 | 3 | use futures::{stream, Stream}; 4 | use juniper::graphql_subscription; 5 | 6 | type BoxStream<'a, I> = Pin + Send + 'a>>; 7 | 8 | struct __Obj; 9 | 10 | #[graphql_subscription] 11 | impl __Obj { 12 | fn id(&self) -> BoxStream<'static, &'static str> { 13 | Box::pin(stream::once(future::ready("funA"))) 14 | } 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/name_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/subscription/name_double_underscored.rs:11:6 4 | | 5 | 11 | impl __Obj { 6 | | ^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/no_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_subscription; 2 | 3 | struct Obj; 4 | 5 | #[graphql_subscription] 6 | impl Obj {} 7 | 8 | fn main() {} 9 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/no_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL object must have at least one field 2 | · note: https://spec.graphql.org/October2021#sec-Objects 3 | --> fail/subscription/no_fields.rs:6:6 4 | | 5 | 6 | impl Obj {} 6 | | ^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/wrong_item.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_subscription; 2 | 3 | #[graphql_subscription] 4 | enum Character {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/wrong_item.stderr: -------------------------------------------------------------------------------- 1 | error: #[graphql_subscription] attribute is applicable to non-trait `impl` blocks only 2 | --> fail/subscription/wrong_item.rs:3:1 3 | | 4 | 3 | #[graphql_subscription] 5 | | ^^^^^^^^^^^^^^^^^^^^^^^ 6 | | 7 | = note: this error originates in the attribute macro `graphql_subscription` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/wrong_syntax.rs: -------------------------------------------------------------------------------- 1 | use std::{future, pin::Pin}; 2 | 3 | use futures::{stream, Stream}; 4 | use juniper::graphql_subscription; 5 | 6 | type BoxStream<'a, I> = Pin + Send + 'a>>; 7 | 8 | struct ObjA { 9 | field: bool 10 | } 11 | 12 | #[graphql_subscription] 13 | impl ObjA { 14 | fn id(&self) -> BoxStream<'static, bool> { 15 | Box::pin(stream::once(future::ready(self.self.field))) 16 | } 17 | } 18 | 19 | fn main() {} 20 | -------------------------------------------------------------------------------- /tests/codegen/fail/subscription/wrong_syntax.stderr: -------------------------------------------------------------------------------- 1 | error: #[graphql_subscription] attribute is applicable to non-trait `impl` blocks only 2 | --> fail/subscription/wrong_syntax.rs:12:1 3 | | 4 | 12 | #[graphql_subscription] 5 | | ^^^^^^^^^^^^^^^^^^^^^^^ 6 | | 7 | = note: this error originates in the attribute macro `graphql_subscription` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | 9 | error[E0609]: no field `self` on type `&ObjA` 10 | --> fail/subscription/wrong_syntax.rs:15:50 11 | | 12 | 15 | Box::pin(stream::once(future::ready(self.self.field))) 13 | | ^^^^ unknown field 14 | | 15 | = note: available field is: `field` 16 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/attr_wrong_item.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_union; 2 | 3 | #[graphql_union] 4 | enum Character {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/attr_wrong_item.stderr: -------------------------------------------------------------------------------- 1 | error: #[graphql_union] attribute is applicable to trait definitions only 2 | --> fail/union/attr_wrong_item.rs:3:1 3 | | 4 | 3 | #[graphql_union] 5 | | ^^^^^^^^^^^^^^^^ 6 | | 7 | = note: this error originates in the attribute macro `graphql_union` (in Nightly builds, run with -Z macro-backtrace for more info) 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/derive_wrong_item.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLUnion; 2 | 3 | #[derive(GraphQLUnion)] 4 | union Character { id: i32 } 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/derive_wrong_item.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union can only be derived for enums and structs 2 | --> fail/union/derive_wrong_item.rs:4:1 3 | | 4 | 4 | union Character { id: i32 } 5 | | ^^^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_external_resolver_fn_conflicts_with_variant_external_resolver_fn.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLObject, GraphQLUnion}; 2 | 3 | #[derive(GraphQLUnion)] 4 | #[graphql(on Human = resolve_fn1)] 5 | enum Character { 6 | #[graphql(with = resolve_fn2)] 7 | A(Human), 8 | } 9 | 10 | #[derive(GraphQLObject)] 11 | pub struct Human { 12 | id: String, 13 | } 14 | 15 | fn main() {} 16 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_external_resolver_fn_conflicts_with_variant_external_resolver_fn.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union variant `Human` already has external resolver function `resolve_fn1` declared on the enum 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | --> fail/union/enum_external_resolver_fn_conflicts_with_variant_external_resolver_fn.rs:6:15 4 | | 5 | 6 | #[graphql(with = resolve_fn2)] 6 | | ^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_name_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLObject, GraphQLUnion}; 2 | 3 | #[derive(GraphQLUnion)] 4 | enum __Character { 5 | A(Human), 6 | } 7 | 8 | #[derive(GraphQLObject)] 9 | pub struct Human { 10 | id: String, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_name_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/union/enum_name_double_underscored.rs:4:6 4 | | 5 | 4 | enum __Character { 6 | | ^^^^^^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_no_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLUnion; 2 | 3 | #[derive(GraphQLUnion)] 4 | enum Character {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_no_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union expects at least one union variant 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | --> fail/union/enum_no_fields.rs:4:1 4 | | 5 | 4 | enum Character {} 6 | | ^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_non_object_variant.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLEnum, GraphQLUnion}; 2 | 3 | #[derive(GraphQLEnum)] 4 | pub enum Test { 5 | A, 6 | B, 7 | } 8 | 9 | #[derive(GraphQLUnion)] 10 | enum Character { 11 | Test(Test), 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_non_object_variant.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `Test: GraphQLObject<__S>` is not satisfied 2 | --> fail/union/enum_non_object_variant.rs:11:10 3 | | 4 | 11 | Test(Test), 5 | | ^^^^ the trait `GraphQLObject<__S>` is not implemented for `Test` 6 | | 7 | = help: the following other types implement trait `GraphQLObject`: 8 | `&T` implements `GraphQLObject` 9 | `Arc` implements `GraphQLObject` 10 | `Argument` implements `GraphQLObject` 11 | `Box` implements `GraphQLObject` 12 | `EnumValue` implements `GraphQLObject<__S>` 13 | `SchemaType` implements `GraphQLObject` 14 | `juniper::meta::Field` implements `GraphQLObject` 15 | `juniper::schema::model::DirectiveType` implements `GraphQLObject` 16 | `juniper::schema::model::TypeType<'a, S>` implements `GraphQLObject` 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_same_type_pretty.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLUnion; 2 | 3 | #[derive(GraphQLUnion)] 4 | enum Character { 5 | A(u8), 6 | B(u8), 7 | } 8 | 9 | fn main() {} 10 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_same_type_pretty.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union must have a different type for each union variant 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | --> fail/union/enum_same_type_pretty.rs:4:1 4 | | 5 | 4 | enum Character { 6 | | ^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_same_type_ugly.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLUnion; 2 | 3 | #[derive(GraphQLUnion)] 4 | enum Character { 5 | A(std::string::String), 6 | B(String), 7 | } 8 | 9 | fn main() {} 10 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_wrong_variant_field.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLObject, GraphQLUnion}; 2 | 3 | #[derive(GraphQLUnion)] 4 | enum Character1 { 5 | A { human: Human }, 6 | } 7 | 8 | #[derive(GraphQLUnion)] 9 | enum Character2 { 10 | A(Human, u8), 11 | } 12 | 13 | #[derive(GraphQLObject)] 14 | pub struct Human { 15 | id: String, 16 | } 17 | 18 | fn main() {} 19 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/enum_wrong_variant_field.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union enum allows only unnamed variants with a single field, e.g. `Some(T)` 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | --> fail/union/enum_wrong_variant_field.rs:5:5 4 | | 5 | 5 | A { human: Human }, 6 | | ^ 7 | 8 | error: GraphQL union enum allows only unnamed variants with a single field, e.g. `Some(T)` 9 | · note: https://spec.graphql.org/October2021#sec-Unions 10 | --> fail/union/enum_wrong_variant_field.rs:10:6 11 | | 12 | 10 | A(Human, u8), 13 | | ^^^^^^^^^^^ 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/struct_name_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLObject, GraphQLUnion}; 2 | 3 | #[derive(GraphQLUnion)] 4 | #[graphql(on Human = __Character::a)] 5 | struct __Character; 6 | 7 | impl __Character { 8 | fn a(&self, _: &()) -> Option<&Human> { 9 | None 10 | } 11 | } 12 | 13 | #[derive(GraphQLObject)] 14 | pub struct Human { 15 | id: String, 16 | } 17 | 18 | fn main() {} 19 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/struct_name_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/union/struct_name_double_underscored.rs:5:8 4 | | 5 | 5 | struct __Character; 6 | | ^^^^^^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/struct_no_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLUnion; 2 | 3 | #[derive(GraphQLUnion)] 4 | struct Character; 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/struct_no_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union expects at least one union variant 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | --> fail/union/struct_no_fields.rs:4:1 4 | | 5 | 4 | struct Character; 6 | | ^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/struct_non_object_variant.rs: -------------------------------------------------------------------------------- 1 | use juniper::{GraphQLEnum, GraphQLUnion}; 2 | 3 | #[derive(GraphQLEnum)] 4 | pub enum Test { 5 | A, 6 | B, 7 | } 8 | 9 | #[derive(GraphQLUnion)] 10 | #[graphql(on Test = Character::a)] 11 | struct Character; 12 | 13 | impl Character { 14 | fn a(&self, _: &()) -> Option<&Test> { 15 | None 16 | } 17 | } 18 | 19 | fn main() {} 20 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/struct_non_object_variant.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `Test: GraphQLObject<__S>` is not satisfied 2 | --> fail/union/struct_non_object_variant.rs:10:14 3 | | 4 | 10 | #[graphql(on Test = Character::a)] 5 | | ^^^^ the trait `GraphQLObject<__S>` is not implemented for `Test` 6 | | 7 | = help: the following other types implement trait `GraphQLObject`: 8 | `&T` implements `GraphQLObject` 9 | `Arc` implements `GraphQLObject` 10 | `Argument` implements `GraphQLObject` 11 | `Box` implements `GraphQLObject` 12 | `EnumValue` implements `GraphQLObject<__S>` 13 | `SchemaType` implements `GraphQLObject` 14 | `juniper::meta::Field` implements `GraphQLObject` 15 | `juniper::schema::model::DirectiveType` implements `GraphQLObject` 16 | `juniper::schema::model::TypeType<'a, S>` implements `GraphQLObject` 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/struct_same_type_pretty.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLUnion; 2 | 3 | #[derive(GraphQLUnion)] 4 | #[graphql(on i32 = Character::a)] 5 | #[graphql(on i32 = Character::b)] 6 | struct Character; 7 | 8 | impl Character { 9 | fn a(&self, _: &()) -> Option<&i32> { 10 | None 11 | } 12 | 13 | fn b(&self, _: &()) -> Option<&i32> { 14 | None 15 | } 16 | } 17 | 18 | fn main() {} 19 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/struct_same_type_pretty.stderr: -------------------------------------------------------------------------------- 1 | error: duplicated attribute argument found 2 | --> fail/union/struct_same_type_pretty.rs:5:14 3 | | 4 | 5 | #[graphql(on i32 = Character::b)] 5 | | ^^^ 6 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/struct_same_type_ugly.rs: -------------------------------------------------------------------------------- 1 | use juniper::GraphQLUnion; 2 | 3 | #[derive(GraphQLUnion)] 4 | #[graphql(on String = Character::a)] 5 | #[graphql(on std::string::String = Character::b)] 6 | struct Character; 7 | 8 | impl Character { 9 | fn a(&self, _: &()) -> Option<&String> { 10 | None 11 | } 12 | 13 | fn b(&self, _: &()) -> Option<&String> { 14 | None 15 | } 16 | } 17 | 18 | fn main() {} 19 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_fail_infer_context.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_union, FromContext, GraphQLObject}; 2 | 3 | #[graphql_union] 4 | trait Character { 5 | fn a(&self, ctx: &SubContext) -> Option<&Human>; 6 | fn b(&self, ctx: &CustomContext) -> Option<&Droid>; 7 | } 8 | 9 | #[derive(GraphQLObject)] 10 | #[graphql(context = CustomContext)] 11 | pub struct Human { 12 | id: String, 13 | home_planet: String, 14 | } 15 | 16 | #[derive(GraphQLObject)] 17 | #[graphql(context = CustomContext)] 18 | pub struct Droid { 19 | id: String, 20 | primary_function: String, 21 | } 22 | 23 | pub struct CustomContext; 24 | impl juniper::Context for CustomContext {} 25 | 26 | pub struct SubContext; 27 | impl juniper::Context for SubContext {} 28 | 29 | impl FromContext for SubContext { 30 | fn from(_: &CustomContext) -> &Self { 31 | &Self 32 | } 33 | } 34 | 35 | fn main() {} 36 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_fail_infer_context.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `CustomContext: FromContext` is not satisfied 2 | --> fail/union/trait_fail_infer_context.rs:3:1 3 | | 4 | 3 | #[graphql_union] 5 | | ^^^^^^^^^^^^^^^^ the trait `FromContext` is not implemented for `CustomContext` 6 | | 7 | = help: the following other types implement trait `FromContext`: 8 | `()` implements `FromContext` 9 | `SubContext` implements `FromContext` 10 | = note: this error originates in the attribute macro `graphql_union` (in Nightly builds, run with -Z macro-backtrace for more info) 11 | 12 | error[E0308]: mismatched types 13 | --> fail/union/trait_fail_infer_context.rs:3:1 14 | | 15 | 3 | #[graphql_union] 16 | | ^^^^^^^^^^^^^^^^ 17 | | | 18 | | expected `&CustomContext`, found `&SubContext` 19 | | arguments to this function are incorrect 20 | | 21 | = note: expected reference `&CustomContext` 22 | found reference `&SubContext` 23 | note: method defined here 24 | --> $WORKSPACE/juniper/src/executor/mod.rs 25 | | 26 | | fn into_resolvable(self, ctx: &'a C) -> FieldResult, S>; 27 | | ^^^^^^^^^^^^^^^ 28 | = note: this error originates in the attribute macro `graphql_union` (in Nightly builds, run with -Z macro-backtrace for more info) 29 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_method_conflicts_with_external_resolver_fn.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_union, GraphQLObject}; 2 | 3 | #[graphql_union(on Human = some_fn)] 4 | trait Character { 5 | fn a(&self) -> Option<&Human>; 6 | } 7 | 8 | #[derive(GraphQLObject)] 9 | pub struct Human { 10 | id: String, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_method_conflicts_with_external_resolver_fn.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union trait method `a` conflicts with the external resolver function `some_fn` declared on the trait to resolve the variant type `Human` 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | · note: use `#[graphql(ignore)]` attribute to ignore this trait method for union variants resolution 4 | --> fail/union/trait_method_conflicts_with_external_resolver_fn.rs:5:5 5 | | 6 | 5 | fn a(&self) -> Option<&Human>; 7 | | ^^ 8 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_name_double_underscored.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_union, GraphQLObject}; 2 | 3 | #[graphql_union] 4 | trait __Character { 5 | fn a(&self) -> Option<&Human>; 6 | } 7 | 8 | #[derive(GraphQLObject)] 9 | pub struct Human { 10 | id: String, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_name_double_underscored.stderr: -------------------------------------------------------------------------------- 1 | error: All types and directives defined within a schema must not have a name which begins with `__` (two underscores), as this is used exclusively by GraphQL’s introspection system. 2 | · note: https://spec.graphql.org/October2021#sec-Schema 3 | --> fail/union/trait_name_double_underscored.rs:4:7 4 | | 5 | 4 | trait __Character { 6 | | ^^^^^^^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_no_fields.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_union; 2 | 3 | #[graphql_union] 4 | trait Character {} 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_no_fields.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union expects at least one union variant 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | --> fail/union/trait_no_fields.rs:4:1 4 | | 5 | 4 | trait Character {} 6 | | ^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_non_object_variant.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_union, GraphQLEnum}; 2 | 3 | #[derive(GraphQLEnum)] 4 | pub enum Test { 5 | A, 6 | B, 7 | } 8 | 9 | #[graphql_union] 10 | trait Character { 11 | fn a(&self) -> Option<&Test>; 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_non_object_variant.stderr: -------------------------------------------------------------------------------- 1 | error[E0277]: the trait bound `Test: GraphQLObject<__S>` is not satisfied 2 | --> fail/union/trait_non_object_variant.rs:11:28 3 | | 4 | 11 | fn a(&self) -> Option<&Test>; 5 | | ^^^^ the trait `GraphQLObject<__S>` is not implemented for `Test` 6 | | 7 | = help: the following other types implement trait `GraphQLObject`: 8 | `&T` implements `GraphQLObject` 9 | `Arc` implements `GraphQLObject` 10 | `Argument` implements `GraphQLObject` 11 | `Box` implements `GraphQLObject` 12 | `EnumValue` implements `GraphQLObject<__S>` 13 | `SchemaType` implements `GraphQLObject` 14 | `juniper::meta::Field` implements `GraphQLObject` 15 | `juniper::schema::model::DirectiveType` implements `GraphQLObject` 16 | `juniper::schema::model::TypeType<'a, S>` implements `GraphQLObject` 17 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_same_type_pretty.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_union; 2 | 3 | #[graphql_union] 4 | trait Character { 5 | fn a(&self) -> Option<&u8>; 6 | fn b(&self) -> Option<&u8>; 7 | } 8 | 9 | fn main() {} 10 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_same_type_pretty.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union must have a different type for each union variant 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | --> fail/union/trait_same_type_pretty.rs:4:1 4 | | 5 | 4 | trait Character { 6 | | ^^^^^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_same_type_ugly.rs: -------------------------------------------------------------------------------- 1 | use juniper::graphql_union; 2 | 3 | #[graphql_union] 4 | trait Character { 5 | fn a(&self) -> Option<&String>; 6 | fn b(&self) -> Option<&std::string::String>; 7 | } 8 | 9 | fn main() {} 10 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_with_attr_on_method.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_union, GraphQLObject}; 2 | 3 | #[graphql_union] 4 | trait Character { 5 | #[graphql(with = something)] 6 | fn a(&self) -> Option<&Human>; 7 | } 8 | 9 | #[derive(GraphQLObject)] 10 | pub struct Human { 11 | id: String, 12 | } 13 | 14 | fn main() {} 15 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_with_attr_on_method.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union cannot use #[graphql(with = ...)] attribute on a trait method 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | · note: instead use #[graphql(ignore)] on the method with #[graphql_union(on ... = ...)] on the trait itself 4 | --> fail/union/trait_with_attr_on_method.rs:5:15 5 | | 6 | 5 | #[graphql(with = something)] 7 | | ^^^^ 8 | 9 | error: cannot find attribute `graphql` in this scope 10 | --> fail/union/trait_with_attr_on_method.rs:5:7 11 | | 12 | 5 | #[graphql(with = something)] 13 | | ^^^^^^^ 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_wrong_method_input_args.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_union, GraphQLObject}; 2 | 3 | #[graphql_union] 4 | trait Character { 5 | fn a(&self, ctx: &(), rand: u8) -> Option<&Human>; 6 | } 7 | 8 | #[derive(GraphQLObject)] 9 | pub struct Human { 10 | id: String, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_wrong_method_input_args.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union expects trait method to accept `&self` only and, optionally, `&Context` 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | --> fail/union/trait_wrong_method_input_args.rs:5:10 4 | | 5 | 5 | fn a(&self, ctx: &(), rand: u8) -> Option<&Human>; 6 | | ^ 7 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_wrong_method_return_type.rs: -------------------------------------------------------------------------------- 1 | use juniper::{graphql_union, GraphQLObject}; 2 | 3 | #[graphql_union] 4 | trait Character { 5 | fn a(&self) -> &Human; 6 | } 7 | 8 | #[derive(GraphQLObject)] 9 | pub struct Human { 10 | id: String, 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /tests/codegen/fail/union/trait_wrong_method_return_type.stderr: -------------------------------------------------------------------------------- 1 | error: GraphQL union expects trait method return type to be `Option<&VariantType>` only 2 | · note: https://spec.graphql.org/October2021#sec-Unions 3 | --> fail/union/trait_wrong_method_return_type.rs:5:20 4 | | 5 | 5 | fn a(&self) -> &Human; 6 | | ^ 7 | -------------------------------------------------------------------------------- /tests/codegen/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Tests for codegen compilation errors. 2 | 3 | // TODO: [Object] Type Validation: §4 (interfaces) for objects 4 | // TODO: [Non-Null] §1 A Non‐Null type must not wrap another Non‐Null type. 5 | 6 | #[cfg(test)] 7 | mod for_codegen_tests_only { 8 | use futures as _; 9 | use juniper as _; 10 | } 11 | 12 | #[rustversion::stable] 13 | #[test] 14 | fn test_failing_compilation() { 15 | let t = trybuild::TestCases::new(); 16 | t.compile_fail("fail/**/*.rs"); 17 | } 18 | -------------------------------------------------------------------------------- /tests/integration/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "juniper_integration_tests" 3 | version = "0.0.0" 4 | edition = "2024" 5 | publish = false 6 | 7 | [dev-dependencies] 8 | chrono = { version = "0.4", default-features = false } 9 | futures = "0.3" 10 | itertools = "0.14" 11 | juniper = { path = "../../juniper", features = ["chrono"] } 12 | juniper_subscriptions = { path = "../../juniper_subscriptions" } 13 | serde = { version = "1.0", features = ["derive"] } 14 | serde_json = "1.0" 15 | tokio = { version = "1.0", features = ["rt", "macros", "time"] } 16 | smartstring = "1.0" 17 | 18 | [lints.clippy] 19 | allow_attributes = "warn" 20 | allow_attributes_without_reason = "warn" 21 | [lints.rust] 22 | closure_returning_async_block = "warn" 23 | future_incompatible = { level = "warn", priority = -1 } 24 | impl_trait_redundant_captures = "warn" 25 | non_ascii_idents = "forbid" 26 | unsafe_code = "forbid" 27 | -------------------------------------------------------------------------------- /tests/integration/tests/arc_fields.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use juniper::{GraphQLInputObject, graphql_object}; 4 | 5 | struct Query; 6 | 7 | #[graphql_object] 8 | impl Query { 9 | fn ping() -> Arc { 10 | Arc::new(false) 11 | } 12 | } 13 | 14 | #[derive(GraphQLInputObject)] 15 | struct Ping { 16 | expect_result: Arc, 17 | } 18 | -------------------------------------------------------------------------------- /tests/integration/tests/cve_2022_31173.rs: -------------------------------------------------------------------------------- 1 | //! Checks that long looping chain of fragments doesn't cause a stack overflow. 2 | //! 3 | //! ```graphql 4 | //! # Fragment loop example 5 | //! query { 6 | //! ...a 7 | //! } 8 | //! 9 | //! fragment a on Query { 10 | //! ...b 11 | //! } 12 | //! 13 | //! fragment b on Query { 14 | //! ...a 15 | //! } 16 | //! ``` 17 | 18 | use std::iter; 19 | 20 | use itertools::Itertools as _; 21 | use juniper::{EmptyMutation, EmptySubscription, graphql_object, graphql_vars}; 22 | 23 | struct Query; 24 | 25 | #[graphql_object] 26 | impl Query { 27 | fn dummy() -> bool { 28 | false 29 | } 30 | } 31 | 32 | type Schema = juniper::RootNode; 33 | 34 | #[tokio::test] 35 | async fn test() { 36 | const PERM: &str = "abcefghijk"; 37 | const CIRCLE_SIZE: usize = 7500; 38 | 39 | let query = iter::once(format!("query {{ ...{PERM} }} ")) 40 | .chain( 41 | PERM.chars() 42 | .permutations(PERM.len()) 43 | .map(|vec| vec.into_iter().collect::()) 44 | .take(CIRCLE_SIZE) 45 | .collect::>() 46 | .into_iter() 47 | .circular_tuple_windows::<(_, _)>() 48 | .map(|(cur, next)| format!("fragment {cur} on Query {{ ...{next} }} ")), 49 | ) 50 | .collect::(); 51 | 52 | let schema = Schema::new(Query, EmptyMutation::new(), EmptySubscription::new()); 53 | let _ = juniper::execute(&query, None, &schema, &graphql_vars! {}, &()) 54 | .await 55 | .unwrap_err(); 56 | } 57 | -------------------------------------------------------------------------------- /tests/integration/tests/infallible_as_field_error.rs: -------------------------------------------------------------------------------- 1 | use std::convert::Infallible; 2 | 3 | use juniper::graphql_object; 4 | 5 | struct Query; 6 | 7 | #[graphql_object] 8 | impl Query { 9 | fn ping() -> Result { 10 | Ok(false) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/integration/tests/inside_macro.rs: -------------------------------------------------------------------------------- 1 | //! Checks that `#[graphql_object]` macro correctly expands inside a declarative 2 | //! macro definition. 3 | //! See [#1051](https://github.com/graphql-rust/juniper/pull/1051) and 4 | //! [#1054](https://github.com/graphql-rust/juniper/pull/1054) for details. 5 | 6 | use juniper::{ 7 | EmptyMutation, EmptySubscription, RootNode, graphql_object, graphql_value, graphql_vars, 8 | }; 9 | 10 | macro_rules! impl_id { 11 | ($typename:ident) => { 12 | #[graphql_object] 13 | impl $typename { 14 | fn id(&self) -> i32 { 15 | 42 16 | } 17 | } 18 | }; 19 | } 20 | 21 | struct Unit; 22 | impl_id!(Unit); 23 | 24 | #[tokio::test] 25 | async fn works() { 26 | let query = r#" 27 | query Unit { 28 | id 29 | } 30 | "#; 31 | 32 | let schema = RootNode::new(Unit, EmptyMutation::new(), EmptySubscription::new()); 33 | let (res, errs) = juniper::execute(query, None, &schema, &graphql_vars! {}, &()) 34 | .await 35 | .unwrap(); 36 | 37 | assert_eq!(errs.len(), 0); 38 | assert_eq!(res, graphql_value!({"id": 42})); 39 | } 40 | --------------------------------------------------------------------------------