graphql_cody 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +5 -0
- data/MIT-LICENSE +20 -0
- data/lib/generators/graphql/core.rb +74 -0
- data/lib/generators/graphql/enum_generator.rb +33 -0
- data/lib/generators/graphql/install_generator.rb +190 -0
- data/lib/generators/graphql/interface_generator.rb +27 -0
- data/lib/generators/graphql/loader_generator.rb +21 -0
- data/lib/generators/graphql/mutation_generator.rb +55 -0
- data/lib/generators/graphql/object_generator.rb +79 -0
- data/lib/generators/graphql/relay.rb +63 -0
- data/lib/generators/graphql/relay_generator.rb +21 -0
- data/lib/generators/graphql/scalar_generator.rb +20 -0
- data/lib/generators/graphql/templates/base_argument.erb +6 -0
- data/lib/generators/graphql/templates/base_connection.erb +8 -0
- data/lib/generators/graphql/templates/base_edge.erb +8 -0
- data/lib/generators/graphql/templates/base_enum.erb +6 -0
- data/lib/generators/graphql/templates/base_field.erb +7 -0
- data/lib/generators/graphql/templates/base_input_object.erb +7 -0
- data/lib/generators/graphql/templates/base_interface.erb +9 -0
- data/lib/generators/graphql/templates/base_mutation.erb +10 -0
- data/lib/generators/graphql/templates/base_object.erb +7 -0
- data/lib/generators/graphql/templates/base_scalar.erb +6 -0
- data/lib/generators/graphql/templates/base_union.erb +6 -0
- data/lib/generators/graphql/templates/enum.erb +7 -0
- data/lib/generators/graphql/templates/graphql_controller.erb +52 -0
- data/lib/generators/graphql/templates/interface.erb +8 -0
- data/lib/generators/graphql/templates/loader.erb +19 -0
- data/lib/generators/graphql/templates/mutation.erb +16 -0
- data/lib/generators/graphql/templates/mutation_type.erb +12 -0
- data/lib/generators/graphql/templates/node_type.erb +9 -0
- data/lib/generators/graphql/templates/object.erb +8 -0
- data/lib/generators/graphql/templates/query_type.erb +15 -0
- data/lib/generators/graphql/templates/scalar.erb +15 -0
- data/lib/generators/graphql/templates/schema.erb +27 -0
- data/lib/generators/graphql/templates/union.erb +7 -0
- data/lib/generators/graphql/type_generator.rb +98 -0
- data/lib/generators/graphql/union_generator.rb +33 -0
- data/lib/graphql/analysis/analyze_query.rb +98 -0
- data/lib/graphql/analysis/ast/analyzer.rb +84 -0
- data/lib/graphql/analysis/ast/field_usage.rb +51 -0
- data/lib/graphql/analysis/ast/max_query_complexity.rb +23 -0
- data/lib/graphql/analysis/ast/max_query_depth.rb +22 -0
- data/lib/graphql/analysis/ast/query_complexity.rb +230 -0
- data/lib/graphql/analysis/ast/query_depth.rb +56 -0
- data/lib/graphql/analysis/ast/visitor.rb +268 -0
- data/lib/graphql/analysis/ast.rb +91 -0
- data/lib/graphql/analysis/field_usage.rb +45 -0
- data/lib/graphql/analysis/max_query_complexity.rb +26 -0
- data/lib/graphql/analysis/max_query_depth.rb +26 -0
- data/lib/graphql/analysis/query_complexity.rb +88 -0
- data/lib/graphql/analysis/query_depth.rb +43 -0
- data/lib/graphql/analysis/reducer_state.rb +48 -0
- data/lib/graphql/analysis.rb +9 -0
- data/lib/graphql/analysis_error.rb +5 -0
- data/lib/graphql/argument.rb +131 -0
- data/lib/graphql/authorization.rb +82 -0
- data/lib/graphql/backtrace/inspect_result.rb +50 -0
- data/lib/graphql/backtrace/legacy_tracer.rb +56 -0
- data/lib/graphql/backtrace/table.rb +159 -0
- data/lib/graphql/backtrace/traced_error.rb +54 -0
- data/lib/graphql/backtrace/tracer.rb +81 -0
- data/lib/graphql/backtrace.rb +64 -0
- data/lib/graphql/backwards_compatibility.rb +61 -0
- data/lib/graphql/base_type.rb +230 -0
- data/lib/graphql/boolean_type.rb +2 -0
- data/lib/graphql/coercion_error.rb +13 -0
- data/lib/graphql/compatibility/execution_specification/counter_schema.rb +53 -0
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +200 -0
- data/lib/graphql/compatibility/execution_specification.rb +436 -0
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +111 -0
- data/lib/graphql/compatibility/lazy_execution_specification.rb +215 -0
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +87 -0
- data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +79 -0
- data/lib/graphql/compatibility/query_parser_specification.rb +266 -0
- data/lib/graphql/compatibility/schema_parser_specification.rb +682 -0
- data/lib/graphql/compatibility.rb +5 -0
- data/lib/graphql/dataloader/null_dataloader.rb +22 -0
- data/lib/graphql/dataloader/request.rb +19 -0
- data/lib/graphql/dataloader/request_all.rb +19 -0
- data/lib/graphql/dataloader/source.rb +155 -0
- data/lib/graphql/dataloader.rb +308 -0
- data/lib/graphql/define/assign_argument.rb +12 -0
- data/lib/graphql/define/assign_connection.rb +13 -0
- data/lib/graphql/define/assign_enum_value.rb +18 -0
- data/lib/graphql/define/assign_global_id_field.rb +11 -0
- data/lib/graphql/define/assign_mutation_function.rb +34 -0
- data/lib/graphql/define/assign_object_field.rb +42 -0
- data/lib/graphql/define/defined_object_proxy.rb +53 -0
- data/lib/graphql/define/instance_definable.rb +240 -0
- data/lib/graphql/define/no_definition_error.rb +7 -0
- data/lib/graphql/define/non_null_with_bang.rb +16 -0
- data/lib/graphql/define/type_definer.rb +31 -0
- data/lib/graphql/define.rb +31 -0
- data/lib/graphql/deprecated_dsl.rb +55 -0
- data/lib/graphql/deprecation.rb +9 -0
- data/lib/graphql/dig.rb +19 -0
- data/lib/graphql/directive/deprecated_directive.rb +2 -0
- data/lib/graphql/directive/include_directive.rb +2 -0
- data/lib/graphql/directive/skip_directive.rb +2 -0
- data/lib/graphql/directive.rb +107 -0
- data/lib/graphql/enum_type.rb +133 -0
- data/lib/graphql/execution/directive_checks.rb +37 -0
- data/lib/graphql/execution/errors.rb +163 -0
- data/lib/graphql/execution/execute.rb +333 -0
- data/lib/graphql/execution/flatten.rb +40 -0
- data/lib/graphql/execution/instrumentation.rb +92 -0
- data/lib/graphql/execution/interpreter/argument_value.rb +28 -0
- data/lib/graphql/execution/interpreter/arguments.rb +88 -0
- data/lib/graphql/execution/interpreter/arguments_cache.rb +103 -0
- data/lib/graphql/execution/interpreter/execution_errors.rb +29 -0
- data/lib/graphql/execution/interpreter/handles_raw_value.rb +18 -0
- data/lib/graphql/execution/interpreter/resolve.rb +70 -0
- data/lib/graphql/execution/interpreter/runtime.rb +949 -0
- data/lib/graphql/execution/interpreter.rb +122 -0
- data/lib/graphql/execution/lazy/lazy_method_map.rb +98 -0
- data/lib/graphql/execution/lazy/resolve.rb +91 -0
- data/lib/graphql/execution/lazy.rb +83 -0
- data/lib/graphql/execution/lookahead.rb +307 -0
- data/lib/graphql/execution/multiplex.rb +214 -0
- data/lib/graphql/execution/typecast.rb +50 -0
- data/lib/graphql/execution.rb +11 -0
- data/lib/graphql/execution_error.rb +58 -0
- data/lib/graphql/field/resolve.rb +59 -0
- data/lib/graphql/field.rb +226 -0
- data/lib/graphql/filter.rb +53 -0
- data/lib/graphql/float_type.rb +2 -0
- data/lib/graphql/function.rb +128 -0
- data/lib/graphql/id_type.rb +2 -0
- data/lib/graphql/input_object_type.rb +138 -0
- data/lib/graphql/int_type.rb +2 -0
- data/lib/graphql/integer_decoding_error.rb +17 -0
- data/lib/graphql/integer_encoding_error.rb +36 -0
- data/lib/graphql/interface_type.rb +72 -0
- data/lib/graphql/internal_representation/document.rb +27 -0
- data/lib/graphql/internal_representation/node.rb +206 -0
- data/lib/graphql/internal_representation/print.rb +51 -0
- data/lib/graphql/internal_representation/rewrite.rb +184 -0
- data/lib/graphql/internal_representation/scope.rb +88 -0
- data/lib/graphql/internal_representation/visit.rb +36 -0
- data/lib/graphql/internal_representation.rb +7 -0
- data/lib/graphql/introspection/base_object.rb +13 -0
- data/lib/graphql/introspection/directive_location_enum.rb +15 -0
- data/lib/graphql/introspection/directive_type.rb +29 -0
- data/lib/graphql/introspection/dynamic_fields.rb +17 -0
- data/lib/graphql/introspection/entry_points.rb +35 -0
- data/lib/graphql/introspection/enum_value_type.rb +23 -0
- data/lib/graphql/introspection/field_type.rb +28 -0
- data/lib/graphql/introspection/input_value_type.rb +67 -0
- data/lib/graphql/introspection/introspection_query.rb +7 -0
- data/lib/graphql/introspection/schema_type.rb +44 -0
- data/lib/graphql/introspection/type_kind_enum.rb +13 -0
- data/lib/graphql/introspection/type_type.rb +95 -0
- data/lib/graphql/introspection.rb +114 -0
- data/lib/graphql/invalid_name_error.rb +11 -0
- data/lib/graphql/invalid_null_error.rb +50 -0
- data/lib/graphql/language/block_string.rb +99 -0
- data/lib/graphql/language/cache.rb +37 -0
- data/lib/graphql/language/definition_slice.rb +41 -0
- data/lib/graphql/language/document_from_schema_definition.rb +347 -0
- data/lib/graphql/language/generation.rb +24 -0
- data/lib/graphql/language/lexer.rb +1467 -0
- data/lib/graphql/language/lexer.rl +258 -0
- data/lib/graphql/language/nodes.rb +707 -0
- data/lib/graphql/language/parser.rb +1974 -0
- data/lib/graphql/language/parser.y +544 -0
- data/lib/graphql/language/printer.rb +366 -0
- data/lib/graphql/language/sanitized_printer.rb +222 -0
- data/lib/graphql/language/token.rb +34 -0
- data/lib/graphql/language/visitor.rb +242 -0
- data/lib/graphql/language.rb +36 -0
- data/lib/graphql/list_type.rb +80 -0
- data/lib/graphql/load_application_object_failed_error.rb +22 -0
- data/lib/graphql/name_validator.rb +11 -0
- data/lib/graphql/non_null_type.rb +71 -0
- data/lib/graphql/object_type.rb +130 -0
- data/lib/graphql/pagination/active_record_relation_connection.rb +48 -0
- data/lib/graphql/pagination/array_connection.rb +77 -0
- data/lib/graphql/pagination/connection.rb +226 -0
- data/lib/graphql/pagination/connections.rb +160 -0
- data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
- data/lib/graphql/pagination/relation_connection.rb +196 -0
- data/lib/graphql/pagination/sequel_dataset_connection.rb +28 -0
- data/lib/graphql/pagination.rb +6 -0
- data/lib/graphql/parse_error.rb +24 -0
- data/lib/graphql/query/arguments.rb +189 -0
- data/lib/graphql/query/arguments_cache.rb +24 -0
- data/lib/graphql/query/context.rb +371 -0
- data/lib/graphql/query/executor.rb +52 -0
- data/lib/graphql/query/fingerprint.rb +26 -0
- data/lib/graphql/query/input_validation_result.rb +43 -0
- data/lib/graphql/query/literal_input.rb +136 -0
- data/lib/graphql/query/null_context.rb +55 -0
- data/lib/graphql/query/result.rb +63 -0
- data/lib/graphql/query/serial_execution/field_resolution.rb +92 -0
- data/lib/graphql/query/serial_execution/operation_resolution.rb +19 -0
- data/lib/graphql/query/serial_execution/selection_resolution.rb +23 -0
- data/lib/graphql/query/serial_execution/value_resolution.rb +87 -0
- data/lib/graphql/query/serial_execution.rb +40 -0
- data/lib/graphql/query/validation_pipeline.rb +139 -0
- data/lib/graphql/query/variable_validation_error.rb +44 -0
- data/lib/graphql/query/variables.rb +78 -0
- data/lib/graphql/query.rb +454 -0
- data/lib/graphql/railtie.rb +117 -0
- data/lib/graphql/rake_task/validate.rb +63 -0
- data/lib/graphql/rake_task.rb +145 -0
- data/lib/graphql/relay/array_connection.rb +83 -0
- data/lib/graphql/relay/base_connection.rb +189 -0
- data/lib/graphql/relay/connection_instrumentation.rb +54 -0
- data/lib/graphql/relay/connection_resolve.rb +43 -0
- data/lib/graphql/relay/connection_type.rb +41 -0
- data/lib/graphql/relay/edge.rb +27 -0
- data/lib/graphql/relay/edge_type.rb +19 -0
- data/lib/graphql/relay/edges_instrumentation.rb +39 -0
- data/lib/graphql/relay/global_id_resolve.rb +18 -0
- data/lib/graphql/relay/mongo_relation_connection.rb +50 -0
- data/lib/graphql/relay/mutation/instrumentation.rb +23 -0
- data/lib/graphql/relay/mutation/resolve.rb +56 -0
- data/lib/graphql/relay/mutation/result.rb +38 -0
- data/lib/graphql/relay/mutation.rb +106 -0
- data/lib/graphql/relay/node.rb +39 -0
- data/lib/graphql/relay/page_info.rb +7 -0
- data/lib/graphql/relay/range_add.rb +59 -0
- data/lib/graphql/relay/relation_connection.rb +188 -0
- data/lib/graphql/relay/type_extensions.rb +32 -0
- data/lib/graphql/relay.rb +18 -0
- data/lib/graphql/rubocop/graphql/base_cop.rb +36 -0
- data/lib/graphql/rubocop/graphql/default_null_true.rb +43 -0
- data/lib/graphql/rubocop/graphql/default_required_true.rb +43 -0
- data/lib/graphql/rubocop.rb +4 -0
- data/lib/graphql/runtime_type_error.rb +5 -0
- data/lib/graphql/scalar_type.rb +91 -0
- data/lib/graphql/schema/addition.rb +247 -0
- data/lib/graphql/schema/argument.rb +383 -0
- data/lib/graphql/schema/base_64_bp.rb +26 -0
- data/lib/graphql/schema/base_64_encoder.rb +21 -0
- data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +47 -0
- data/lib/graphql/schema/build_from_definition/resolve_map.rb +78 -0
- data/lib/graphql/schema/build_from_definition.rb +477 -0
- data/lib/graphql/schema/built_in_types.rb +12 -0
- data/lib/graphql/schema/catchall_middleware.rb +35 -0
- data/lib/graphql/schema/default_parse_error.rb +10 -0
- data/lib/graphql/schema/default_type_error.rb +17 -0
- data/lib/graphql/schema/directive/deprecated.rb +18 -0
- data/lib/graphql/schema/directive/feature.rb +66 -0
- data/lib/graphql/schema/directive/flagged.rb +57 -0
- data/lib/graphql/schema/directive/include.rb +25 -0
- data/lib/graphql/schema/directive/skip.rb +25 -0
- data/lib/graphql/schema/directive/transform.rb +60 -0
- data/lib/graphql/schema/directive.rb +210 -0
- data/lib/graphql/schema/enum.rb +193 -0
- data/lib/graphql/schema/enum_value.rb +97 -0
- data/lib/graphql/schema/field/connection_extension.rb +76 -0
- data/lib/graphql/schema/field/scope_extension.rb +22 -0
- data/lib/graphql/schema/field.rb +880 -0
- data/lib/graphql/schema/field_extension.rb +69 -0
- data/lib/graphql/schema/find_inherited_value.rb +36 -0
- data/lib/graphql/schema/finder.rb +155 -0
- data/lib/graphql/schema/input_object.rb +253 -0
- data/lib/graphql/schema/interface.rb +136 -0
- data/lib/graphql/schema/introspection_system.rb +169 -0
- data/lib/graphql/schema/invalid_type_error.rb +7 -0
- data/lib/graphql/schema/late_bound_type.rb +33 -0
- data/lib/graphql/schema/list.rb +75 -0
- data/lib/graphql/schema/loader.rb +226 -0
- data/lib/graphql/schema/member/accepts_definition.rb +159 -0
- data/lib/graphql/schema/member/base_dsl_methods.rb +129 -0
- data/lib/graphql/schema/member/build_type.rb +180 -0
- data/lib/graphql/schema/member/cached_graphql_definition.rb +31 -0
- data/lib/graphql/schema/member/graphql_type_names.rb +21 -0
- data/lib/graphql/schema/member/has_arguments.rb +332 -0
- data/lib/graphql/schema/member/has_ast_node.rb +20 -0
- data/lib/graphql/schema/member/has_deprecation_reason.rb +25 -0
- data/lib/graphql/schema/member/has_directives.rb +98 -0
- data/lib/graphql/schema/member/has_fields.rb +163 -0
- data/lib/graphql/schema/member/has_interfaces.rb +90 -0
- data/lib/graphql/schema/member/has_path.rb +25 -0
- data/lib/graphql/schema/member/has_unresolved_type_error.rb +15 -0
- data/lib/graphql/schema/member/has_validators.rb +31 -0
- data/lib/graphql/schema/member/instrumentation.rb +131 -0
- data/lib/graphql/schema/member/relay_shortcuts.rb +47 -0
- data/lib/graphql/schema/member/scoped.rb +21 -0
- data/lib/graphql/schema/member/type_system_helpers.rb +38 -0
- data/lib/graphql/schema/member/validates_input.rb +33 -0
- data/lib/graphql/schema/member.rb +161 -0
- data/lib/graphql/schema/middleware_chain.rb +82 -0
- data/lib/graphql/schema/mutation.rb +94 -0
- data/lib/graphql/schema/non_null.rb +67 -0
- data/lib/graphql/schema/null_mask.rb +11 -0
- data/lib/graphql/schema/object.rb +150 -0
- data/lib/graphql/schema/possible_types.rb +44 -0
- data/lib/graphql/schema/printer.rb +100 -0
- data/lib/graphql/schema/relay_classic_mutation.rb +160 -0
- data/lib/graphql/schema/rescue_middleware.rb +60 -0
- data/lib/graphql/schema/resolver/has_payload_type.rb +96 -0
- data/lib/graphql/schema/resolver.rb +397 -0
- data/lib/graphql/schema/scalar.rb +69 -0
- data/lib/graphql/schema/subscription.rb +155 -0
- data/lib/graphql/schema/timeout.rb +123 -0
- data/lib/graphql/schema/timeout_middleware.rb +88 -0
- data/lib/graphql/schema/traversal.rb +228 -0
- data/lib/graphql/schema/type_expression.rb +43 -0
- data/lib/graphql/schema/type_membership.rb +48 -0
- data/lib/graphql/schema/union.rb +95 -0
- data/lib/graphql/schema/unique_within_type.rb +34 -0
- data/lib/graphql/schema/validation.rb +313 -0
- data/lib/graphql/schema/validator/allow_blank_validator.rb +29 -0
- data/lib/graphql/schema/validator/allow_null_validator.rb +26 -0
- data/lib/graphql/schema/validator/exclusion_validator.rb +33 -0
- data/lib/graphql/schema/validator/format_validator.rb +48 -0
- data/lib/graphql/schema/validator/inclusion_validator.rb +35 -0
- data/lib/graphql/schema/validator/length_validator.rb +59 -0
- data/lib/graphql/schema/validator/numericality_validator.rb +82 -0
- data/lib/graphql/schema/validator/required_validator.rb +68 -0
- data/lib/graphql/schema/validator.rb +174 -0
- data/lib/graphql/schema/warden.rb +409 -0
- data/lib/graphql/schema/wrapper.rb +29 -0
- data/lib/graphql/schema.rb +1945 -0
- data/lib/graphql/static_validation/all_rules.rb +40 -0
- data/lib/graphql/static_validation/base_visitor.rb +217 -0
- data/lib/graphql/static_validation/default_visitor.rb +15 -0
- data/lib/graphql/static_validation/definition_dependencies.rb +198 -0
- data/lib/graphql/static_validation/error.rb +46 -0
- data/lib/graphql/static_validation/interpreter_visitor.rb +14 -0
- data/lib/graphql/static_validation/literal_validator.rb +139 -0
- data/lib/graphql/static_validation/no_validate_visitor.rb +10 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +66 -0
- data/lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb +48 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique.rb +31 -0
- data/lib/graphql/static_validation/rules/argument_names_are_unique_error.rb +30 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined.rb +71 -0
- data/lib/graphql/static_validation/rules/arguments_are_defined_error.rb +37 -0
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +23 -0
- data/lib/graphql/static_validation/rules/directives_are_defined_error.rb +29 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +65 -0
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb +31 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +30 -0
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb +32 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +73 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb +31 -0
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +418 -0
- data/lib/graphql/static_validation/rules/fields_will_merge_error.rb +53 -0
- data/lib/graphql/static_validation/rules/fragment_names_are_unique.rb +30 -0
- data/lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb +29 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +73 -0
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb +35 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +39 -0
- data/lib/graphql/static_validation/rules/fragment_types_exist_error.rb +29 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +21 -0
- data/lib/graphql/static_validation/rules/fragments_are_finite_error.rb +29 -0
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +16 -0
- data/lib/graphql/static_validation/rules/fragments_are_named_error.rb +26 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +37 -0
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb +30 -0
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +32 -0
- data/lib/graphql/static_validation/rules/fragments_are_used_error.rb +29 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique.rb +30 -0
- data/lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb +30 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +17 -0
- data/lib/graphql/static_validation/rules/mutation_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present.rb +41 -0
- data/lib/graphql/static_validation/rules/no_definitions_are_present_error.rb +25 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +36 -0
- data/lib/graphql/static_validation/rules/operation_names_are_valid_error.rb +28 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +37 -0
- data/lib/graphql/static_validation/rules/required_arguments_are_present_error.rb +35 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +59 -0
- data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb +35 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists.rb +17 -0
- data/lib/graphql/static_validation/rules/subscription_root_exists_error.rb +26 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +50 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location_error.rb +29 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +46 -0
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb +39 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique.rb +24 -0
- data/lib/graphql/static_validation/rules/variable_names_are_unique_error.rb +29 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +153 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb +38 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +39 -0
- data/lib/graphql/static_validation/rules/variables_are_input_types_error.rb +32 -0
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +155 -0
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb +37 -0
- data/lib/graphql/static_validation/type_stack.rb +216 -0
- data/lib/graphql/static_validation/validation_context.rb +49 -0
- data/lib/graphql/static_validation/validation_timeout_error.rb +25 -0
- data/lib/graphql/static_validation/validator.rb +96 -0
- data/lib/graphql/static_validation.rb +19 -0
- data/lib/graphql/string_encoding_error.rb +20 -0
- data/lib/graphql/string_type.rb +2 -0
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +245 -0
- data/lib/graphql/subscriptions/broadcast_analyzer.rb +81 -0
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +21 -0
- data/lib/graphql/subscriptions/event.rb +144 -0
- data/lib/graphql/subscriptions/instrumentation.rb +79 -0
- data/lib/graphql/subscriptions/serialize.rb +138 -0
- data/lib/graphql/subscriptions/subscription_root.rb +76 -0
- data/lib/graphql/subscriptions.rb +299 -0
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +35 -0
- data/lib/graphql/tracing/appoptics_tracing.rb +173 -0
- data/lib/graphql/tracing/appsignal_tracing.rb +51 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +76 -0
- data/lib/graphql/tracing/new_relic_tracing.rb +51 -0
- data/lib/graphql/tracing/platform_tracing.rb +139 -0
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +32 -0
- data/lib/graphql/tracing/prometheus_tracing.rb +67 -0
- data/lib/graphql/tracing/scout_tracing.rb +54 -0
- data/lib/graphql/tracing/skylight_tracing.rb +70 -0
- data/lib/graphql/tracing/statsd_tracing.rb +42 -0
- data/lib/graphql/tracing.rb +95 -0
- data/lib/graphql/type_kinds.rb +77 -0
- data/lib/graphql/types/big_int.rb +23 -0
- data/lib/graphql/types/boolean.rb +18 -0
- data/lib/graphql/types/float.rb +19 -0
- data/lib/graphql/types/id.rb +24 -0
- data/lib/graphql/types/int.rb +36 -0
- data/lib/graphql/types/iso_8601_date.rb +34 -0
- data/lib/graphql/types/iso_8601_date_time.rb +65 -0
- data/lib/graphql/types/json.rb +25 -0
- data/lib/graphql/types/relay/base_connection.rb +39 -0
- data/lib/graphql/types/relay/base_edge.rb +29 -0
- data/lib/graphql/types/relay/connection_behaviors.rb +156 -0
- data/lib/graphql/types/relay/default_relay.rb +27 -0
- data/lib/graphql/types/relay/edge_behaviors.rb +53 -0
- data/lib/graphql/types/relay/has_node_field.rb +41 -0
- data/lib/graphql/types/relay/has_nodes_field.rb +41 -0
- data/lib/graphql/types/relay/node.rb +15 -0
- data/lib/graphql/types/relay/node_behaviors.rb +15 -0
- data/lib/graphql/types/relay/node_field.rb +25 -0
- data/lib/graphql/types/relay/nodes_field.rb +27 -0
- data/lib/graphql/types/relay/page_info.rb +11 -0
- data/lib/graphql/types/relay/page_info_behaviors.rb +25 -0
- data/lib/graphql/types/relay.rb +41 -0
- data/lib/graphql/types/string.rb +29 -0
- data/lib/graphql/types.rb +11 -0
- data/lib/graphql/unauthorized_error.rb +29 -0
- data/lib/graphql/unauthorized_field_error.rb +23 -0
- data/lib/graphql/union_type.rb +115 -0
- data/lib/graphql/unresolved_type_error.rb +35 -0
- data/lib/graphql/upgrader/member.rb +937 -0
- data/lib/graphql/upgrader/schema.rb +38 -0
- data/lib/graphql/version.rb +4 -0
- data/lib/graphql.rb +168 -0
- data/readme.md +49 -0
- metadata +714 -0
| @@ -0,0 +1,53 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module GraphQL
         | 
| 4 | 
            +
              module Define
         | 
| 5 | 
            +
                # This object delegates most methods to a dictionary of functions, {@dictionary}.
         | 
| 6 | 
            +
                # {@target} is passed to the specified function, along with any arguments and block.
         | 
| 7 | 
            +
                # This allows a method-based DSL without adding methods to the defined class.
         | 
| 8 | 
            +
                class DefinedObjectProxy
         | 
| 9 | 
            +
                  extend GraphQL::Ruby2Keywords
         | 
| 10 | 
            +
                  # The object which will be defined by definition functions
         | 
| 11 | 
            +
                  attr_reader :target
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def initialize(target)
         | 
| 14 | 
            +
                    @target = target
         | 
| 15 | 
            +
                    @dictionary = target.class.dictionary
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  # Provides shorthand access to GraphQL's built-in types
         | 
| 19 | 
            +
                  def types
         | 
| 20 | 
            +
                    GraphQL::Define::TypeDefiner.instance
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  # Allow `plugin` to perform complex initialization on the definition.
         | 
| 24 | 
            +
                  # Calls `plugin.use(defn, **kwargs)`.
         | 
| 25 | 
            +
                  # @param plugin [<#use(defn, **kwargs)>] A plugin object
         | 
| 26 | 
            +
                  # @param kwargs [Hash] Any options for the plugin
         | 
| 27 | 
            +
                  def use(plugin, **kwargs)
         | 
| 28 | 
            +
                    # https://bugs.ruby-lang.org/issues/10708
         | 
| 29 | 
            +
                    if kwargs == {}
         | 
| 30 | 
            +
                      plugin.use(self)
         | 
| 31 | 
            +
                    else
         | 
| 32 | 
            +
                      plugin.use(self, **kwargs)
         | 
| 33 | 
            +
                    end
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  # Lookup a function from the dictionary and call it if it's found.
         | 
| 37 | 
            +
                  def method_missing(name, *args, &block)
         | 
| 38 | 
            +
                    definition = @dictionary[name]
         | 
| 39 | 
            +
                    if definition
         | 
| 40 | 
            +
                      definition.call(@target, *args, &block)
         | 
| 41 | 
            +
                    else
         | 
| 42 | 
            +
                      msg = "#{@target.class.name} can't define '#{name}'"
         | 
| 43 | 
            +
                      raise NoDefinitionError, msg, caller
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
                  ruby2_keywords :method_missing
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  def respond_to_missing?(name, include_private = false)
         | 
| 49 | 
            +
                    @dictionary[name] || super
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                end
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
            end
         | 
| @@ -0,0 +1,240 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            module GraphQL
         | 
| 3 | 
            +
              module Define
         | 
| 4 | 
            +
                # @api deprecated
         | 
| 5 | 
            +
                module InstanceDefinable
         | 
| 6 | 
            +
                  module DeprecatedDefine
         | 
| 7 | 
            +
                    def define(**kwargs, &block)
         | 
| 8 | 
            +
                      deprecated_caller = caller(1, 1).first
         | 
| 9 | 
            +
                      if deprecated_caller.include?("lib/graphql")
         | 
| 10 | 
            +
                        deprecated_caller = caller(2, 10).find { |c| !c.include?("lib/graphql") }
         | 
| 11 | 
            +
                      end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                      if deprecated_caller
         | 
| 14 | 
            +
                        GraphQL::Deprecation.warn <<-ERR
         | 
| 15 | 
            +
            #{self}.define will be removed in GraphQL-Ruby 2.0; use a class-based definition instead. See https://graphql-ruby.org/schema/class_based_api.html.
         | 
| 16 | 
            +
              -> called from #{deprecated_caller}
         | 
| 17 | 
            +
            ERR
         | 
| 18 | 
            +
                      end
         | 
| 19 | 
            +
                      deprecated_define(**kwargs, &block)
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def self.included(base)
         | 
| 24 | 
            +
                    base.extend(ClassMethods)
         | 
| 25 | 
            +
                    base.ensure_defined(:metadata)
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  # @api deprecated
         | 
| 29 | 
            +
                  def metadata
         | 
| 30 | 
            +
                    @metadata ||= {}
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  # @api deprecated
         | 
| 34 | 
            +
                  def deprecated_define(**kwargs, &block)
         | 
| 35 | 
            +
                    # make sure the previous definition_proc was executed:
         | 
| 36 | 
            +
                    ensure_defined
         | 
| 37 | 
            +
                    stash_dependent_methods
         | 
| 38 | 
            +
                    @pending_definition = Definition.new(kwargs, block)
         | 
| 39 | 
            +
                    nil
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  # @api deprecated
         | 
| 43 | 
            +
                  def define(**kwargs, &block)
         | 
| 44 | 
            +
                    deprecated_define(**kwargs, &block)
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  # @api deprecated
         | 
| 48 | 
            +
                  def redefine(**kwargs, &block)
         | 
| 49 | 
            +
                    ensure_defined
         | 
| 50 | 
            +
                    new_inst = self.dup
         | 
| 51 | 
            +
                    new_inst.deprecated_define(**kwargs, &block)
         | 
| 52 | 
            +
                    new_inst
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  def initialize_copy(other)
         | 
| 56 | 
            +
                    super
         | 
| 57 | 
            +
                    @metadata = other.metadata.dup
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  private
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  # Run the definition block if it hasn't been run yet.
         | 
| 63 | 
            +
                  # This can only be run once: the block is deleted after it's used.
         | 
| 64 | 
            +
                  # You have to call this before using any value which could
         | 
| 65 | 
            +
                  # come from the definition block.
         | 
| 66 | 
            +
                  # @return [void]
         | 
| 67 | 
            +
                  def ensure_defined
         | 
| 68 | 
            +
                    if @pending_definition
         | 
| 69 | 
            +
                      defn = @pending_definition
         | 
| 70 | 
            +
                      @pending_definition = nil
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                      revive_dependent_methods
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                      begin
         | 
| 75 | 
            +
                        defn_proxy = DefinedObjectProxy.new(self)
         | 
| 76 | 
            +
                        # Apply definition from `define(...)` kwargs
         | 
| 77 | 
            +
                        defn.define_keywords.each do |keyword, value|
         | 
| 78 | 
            +
                          # Don't splat string hashes, which blows up on Rubies before 2.7
         | 
| 79 | 
            +
                          if value.is_a?(Hash) && !value.empty? && value.each_key.all? { |k| k.is_a?(Symbol) }
         | 
| 80 | 
            +
                            defn_proxy.public_send(keyword, **value)
         | 
| 81 | 
            +
                          else
         | 
| 82 | 
            +
                            defn_proxy.public_send(keyword, value)
         | 
| 83 | 
            +
                          end
         | 
| 84 | 
            +
                        end
         | 
| 85 | 
            +
                        # and/or apply definition from `define { ... }` block
         | 
| 86 | 
            +
                        if defn.define_proc
         | 
| 87 | 
            +
                          defn_proxy.instance_eval(&defn.define_proc)
         | 
| 88 | 
            +
                        end
         | 
| 89 | 
            +
                      rescue StandardError
         | 
| 90 | 
            +
                        # The definition block failed to run, so make this object pending again:
         | 
| 91 | 
            +
                        stash_dependent_methods
         | 
| 92 | 
            +
                        @pending_definition = defn
         | 
| 93 | 
            +
                        raise
         | 
| 94 | 
            +
                      end
         | 
| 95 | 
            +
                    end
         | 
| 96 | 
            +
                    nil
         | 
| 97 | 
            +
                  end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                  # Take the pending methods and put them back on this object's singleton class.
         | 
| 100 | 
            +
                  # This reverts the process done by {#stash_dependent_methods}
         | 
| 101 | 
            +
                  # @return [void]
         | 
| 102 | 
            +
                  def revive_dependent_methods
         | 
| 103 | 
            +
                    pending_methods = @pending_methods
         | 
| 104 | 
            +
                    self.singleton_class.class_eval {
         | 
| 105 | 
            +
                      pending_methods.each do |method|
         | 
| 106 | 
            +
                        undef_method(method.name) if method_defined?(method.name)
         | 
| 107 | 
            +
                        define_method(method.name, method)
         | 
| 108 | 
            +
                      end
         | 
| 109 | 
            +
                    }
         | 
| 110 | 
            +
                    @pending_methods = nil
         | 
| 111 | 
            +
                  end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                  # Find the method names which were declared as definition-dependent,
         | 
| 114 | 
            +
                  # then grab the method definitions off of this object's class
         | 
| 115 | 
            +
                  # and store them for later.
         | 
| 116 | 
            +
                  #
         | 
| 117 | 
            +
                  # Then make a dummy method for each of those method names which:
         | 
| 118 | 
            +
                  #
         | 
| 119 | 
            +
                  # - Triggers the pending definition, if there is one
         | 
| 120 | 
            +
                  # - Calls the same method again.
         | 
| 121 | 
            +
                  #
         | 
| 122 | 
            +
                  # It's assumed that {#ensure_defined} will put the original method definitions
         | 
| 123 | 
            +
                  # back in place with {#revive_dependent_methods}.
         | 
| 124 | 
            +
                  # @return [void]
         | 
| 125 | 
            +
                  def stash_dependent_methods
         | 
| 126 | 
            +
                    method_names = self.class.ensure_defined_method_names
         | 
| 127 | 
            +
                    @pending_methods = method_names.map { |n| self.class.instance_method(n) }
         | 
| 128 | 
            +
                    self.singleton_class.class_eval do
         | 
| 129 | 
            +
                      method_names.each do |method_name|
         | 
| 130 | 
            +
                        undef_method(method_name) if method_defined?(method_name)
         | 
| 131 | 
            +
                        define_method(method_name) { |*args, &block|
         | 
| 132 | 
            +
                          ensure_defined
         | 
| 133 | 
            +
                          self.send(method_name, *args, &block)
         | 
| 134 | 
            +
                        }
         | 
| 135 | 
            +
                      end
         | 
| 136 | 
            +
                    end
         | 
| 137 | 
            +
                  end
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                  class Definition
         | 
| 140 | 
            +
                    attr_reader :define_keywords, :define_proc
         | 
| 141 | 
            +
                    def initialize(define_keywords, define_proc)
         | 
| 142 | 
            +
                      @define_keywords = define_keywords
         | 
| 143 | 
            +
                      @define_proc = define_proc
         | 
| 144 | 
            +
                    end
         | 
| 145 | 
            +
                  end
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                  module ClassMethods
         | 
| 148 | 
            +
                    # Create a new instance
         | 
| 149 | 
            +
                    # and prepare a definition using its {.definitions}.
         | 
| 150 | 
            +
                    # @api deprecated
         | 
| 151 | 
            +
                    # @param kwargs [Hash] Key-value pairs corresponding to defininitions from `accepts_definitions`
         | 
| 152 | 
            +
                    # @param block [Proc] Block which calls helper methods from `accepts_definitions`
         | 
| 153 | 
            +
                    def deprecated_define(**kwargs, &block)
         | 
| 154 | 
            +
                      instance = self.new
         | 
| 155 | 
            +
                      instance.deprecated_define(**kwargs, &block)
         | 
| 156 | 
            +
                      instance
         | 
| 157 | 
            +
                    end
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                    # @api deprecated
         | 
| 160 | 
            +
                    def define(**kwargs, &block)
         | 
| 161 | 
            +
                      instance = self.new
         | 
| 162 | 
            +
                      instance.define(**kwargs, &block)
         | 
| 163 | 
            +
                      instance
         | 
| 164 | 
            +
                    end
         | 
| 165 | 
            +
             | 
| 166 | 
            +
                    # Attach definitions to this class.
         | 
| 167 | 
            +
                    # Each symbol in `accepts` will be assigned with `{key}=`.
         | 
| 168 | 
            +
                    # The last entry in accepts may be a hash of name-proc pairs for custom definitions.
         | 
| 169 | 
            +
                    def accepts_definitions(*accepts)
         | 
| 170 | 
            +
                      new_assignments = if accepts.last.is_a?(Hash)
         | 
| 171 | 
            +
                        accepts.pop.dup
         | 
| 172 | 
            +
                      else
         | 
| 173 | 
            +
                        {}
         | 
| 174 | 
            +
                      end
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                      accepts.each do |key|
         | 
| 177 | 
            +
                        new_assignments[key] = AssignAttribute.new(key)
         | 
| 178 | 
            +
                      end
         | 
| 179 | 
            +
             | 
| 180 | 
            +
                      @own_dictionary = own_dictionary.merge(new_assignments)
         | 
| 181 | 
            +
                    end
         | 
| 182 | 
            +
             | 
| 183 | 
            +
                    def ensure_defined(*method_names)
         | 
| 184 | 
            +
                      @ensure_defined_method_names ||= []
         | 
| 185 | 
            +
                      @ensure_defined_method_names.concat(method_names)
         | 
| 186 | 
            +
                      nil
         | 
| 187 | 
            +
                    end
         | 
| 188 | 
            +
             | 
| 189 | 
            +
                    def ensure_defined_method_names
         | 
| 190 | 
            +
                      own_method_names = @ensure_defined_method_names || []
         | 
| 191 | 
            +
                      if superclass.respond_to?(:ensure_defined_method_names)
         | 
| 192 | 
            +
                        superclass.ensure_defined_method_names + own_method_names
         | 
| 193 | 
            +
                      else
         | 
| 194 | 
            +
                        own_method_names
         | 
| 195 | 
            +
                      end
         | 
| 196 | 
            +
                    end
         | 
| 197 | 
            +
             | 
| 198 | 
            +
                    # @return [Hash] combined definitions for self and ancestors
         | 
| 199 | 
            +
                    def dictionary
         | 
| 200 | 
            +
                      if superclass.respond_to?(:dictionary)
         | 
| 201 | 
            +
                        own_dictionary.merge(superclass.dictionary)
         | 
| 202 | 
            +
                      else
         | 
| 203 | 
            +
                        own_dictionary
         | 
| 204 | 
            +
                      end
         | 
| 205 | 
            +
                    end
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                    # @return [Hash] definitions for this class only
         | 
| 208 | 
            +
                    def own_dictionary
         | 
| 209 | 
            +
                      @own_dictionary ||= {}
         | 
| 210 | 
            +
                    end
         | 
| 211 | 
            +
                  end
         | 
| 212 | 
            +
             | 
| 213 | 
            +
                  class AssignMetadataKey
         | 
| 214 | 
            +
                    def initialize(key)
         | 
| 215 | 
            +
                      @key = key
         | 
| 216 | 
            +
                    end
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                    def call(defn, value = true)
         | 
| 219 | 
            +
                      defn.metadata[@key] = value
         | 
| 220 | 
            +
                    end
         | 
| 221 | 
            +
                  end
         | 
| 222 | 
            +
             | 
| 223 | 
            +
                  class AssignAttribute
         | 
| 224 | 
            +
                    extend GraphQL::Ruby2Keywords
         | 
| 225 | 
            +
             | 
| 226 | 
            +
                    def initialize(attr_name)
         | 
| 227 | 
            +
                      @attr_assign_method = :"#{attr_name}="
         | 
| 228 | 
            +
                    end
         | 
| 229 | 
            +
             | 
| 230 | 
            +
                    # Even though we're just using the first value here,
         | 
| 231 | 
            +
                    # We have to add a splat here to use `ruby2_keywords`,
         | 
| 232 | 
            +
                    # so that it will accept a `[{}]` input from the caller.
         | 
| 233 | 
            +
                    def call(defn, *value)
         | 
| 234 | 
            +
                      defn.public_send(@attr_assign_method, value.first)
         | 
| 235 | 
            +
                    end
         | 
| 236 | 
            +
                    ruby2_keywords :call
         | 
| 237 | 
            +
                  end
         | 
| 238 | 
            +
                end
         | 
| 239 | 
            +
              end
         | 
| 240 | 
            +
            end
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            module GraphQL
         | 
| 3 | 
            +
              module Define
         | 
| 4 | 
            +
                # Wrap the object in NonNullType in response to `!`
         | 
| 5 | 
            +
                # @example required Int type
         | 
| 6 | 
            +
                #   !GraphQL::INT_TYPE
         | 
| 7 | 
            +
                #
         | 
| 8 | 
            +
                module NonNullWithBang
         | 
| 9 | 
            +
                  # Make the type non-null
         | 
| 10 | 
            +
                  # @return [GraphQL::NonNullType] a non-null type which wraps the original type
         | 
| 11 | 
            +
                  def !
         | 
| 12 | 
            +
                    to_non_null_type
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            module GraphQL
         | 
| 3 | 
            +
              module Define
         | 
| 4 | 
            +
                # Some conveniences for definining return & argument types.
         | 
| 5 | 
            +
                #
         | 
| 6 | 
            +
                # Passed into initialization blocks, eg {ObjectType#initialize}, {Field#initialize}
         | 
| 7 | 
            +
                class TypeDefiner
         | 
| 8 | 
            +
                  include Singleton
         | 
| 9 | 
            +
                  # rubocop:disable Naming/MethodName
         | 
| 10 | 
            +
                  def Int;      GraphQL::DEPRECATED_INT_TYPE;      end
         | 
| 11 | 
            +
                  def String;   GraphQL::DEPRECATED_STRING_TYPE;   end
         | 
| 12 | 
            +
                  def Float;    GraphQL::DEPRECATED_FLOAT_TYPE;    end
         | 
| 13 | 
            +
                  def Boolean;  GraphQL::DEPRECATED_BOOLEAN_TYPE;  end
         | 
| 14 | 
            +
                  def ID;       GraphQL::DEPRECATED_ID_TYPE;       end
         | 
| 15 | 
            +
                  # rubocop:enable Naming/MethodName
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  # Make a {ListType} which wraps the input type
         | 
| 18 | 
            +
                  #
         | 
| 19 | 
            +
                  # @example making a list type
         | 
| 20 | 
            +
                  #   list_of_strings = types[types.String]
         | 
| 21 | 
            +
                  #   list_of_strings.inspect
         | 
| 22 | 
            +
                  #   # => "[String]"
         | 
| 23 | 
            +
                  #
         | 
| 24 | 
            +
                  # @param type [Type] A type to be wrapped in a ListType
         | 
| 25 | 
            +
                  # @return [GraphQL::ListType] A ListType wrapping `type`
         | 
| 26 | 
            +
                  def [](type)
         | 
| 27 | 
            +
                    type.to_list_type
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            require "graphql/define/assign_argument"
         | 
| 3 | 
            +
            require "graphql/define/assign_connection"
         | 
| 4 | 
            +
            require "graphql/define/assign_enum_value"
         | 
| 5 | 
            +
            require "graphql/define/assign_global_id_field"
         | 
| 6 | 
            +
            require "graphql/define/assign_mutation_function"
         | 
| 7 | 
            +
            require "graphql/define/assign_object_field"
         | 
| 8 | 
            +
            require "graphql/define/defined_object_proxy"
         | 
| 9 | 
            +
            require "graphql/define/instance_definable"
         | 
| 10 | 
            +
            require "graphql/define/no_definition_error"
         | 
| 11 | 
            +
            require "graphql/define/non_null_with_bang"
         | 
| 12 | 
            +
            require "graphql/define/type_definer"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            module GraphQL
         | 
| 15 | 
            +
              module Define
         | 
| 16 | 
            +
                # A helper for definitions that store their value in `#metadata`.
         | 
| 17 | 
            +
                #
         | 
| 18 | 
            +
                # @example Storing application classes with GraphQL types
         | 
| 19 | 
            +
                #   # Make a custom definition
         | 
| 20 | 
            +
                #   GraphQL::ObjectType.accepts_definitions(resolves_to_class_names: GraphQL::Define.assign_metadata_key(:resolves_to_class_names))
         | 
| 21 | 
            +
                #
         | 
| 22 | 
            +
                #   # After definition, read the key from metadata
         | 
| 23 | 
            +
                #   PostType.metadata[:resolves_to_class_names] # => [...]
         | 
| 24 | 
            +
                #
         | 
| 25 | 
            +
                # @param key [Object] the key to assign in metadata
         | 
| 26 | 
            +
                # @return [#call(defn, value)] an assignment for `.accepts_definitions` which writes `key` to `#metadata`
         | 
| 27 | 
            +
                def self.assign_metadata_key(key)
         | 
| 28 | 
            +
                  GraphQL::Define::InstanceDefinable::AssignMetadataKey.new(key)
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| @@ -0,0 +1,55 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            module GraphQL
         | 
| 3 | 
            +
              # There are two ways to apply the deprecated `!` DSL to class-style schema definitions:
         | 
| 4 | 
            +
              #
         | 
| 5 | 
            +
              # 1. Scoped by file (CRuby only), add to the top of the file:
         | 
| 6 | 
            +
              #
         | 
| 7 | 
            +
              #      using GraphQL::DeprecationDSL
         | 
| 8 | 
            +
              #
         | 
| 9 | 
            +
              #   (This is a "refinement", there are also other ways to scope it.)
         | 
| 10 | 
            +
              #
         | 
| 11 | 
            +
              # 2. Global application, add before schema definition:
         | 
| 12 | 
            +
              #
         | 
| 13 | 
            +
              #      GraphQL::DeprecationDSL.activate
         | 
| 14 | 
            +
              #
         | 
| 15 | 
            +
              module DeprecatedDSL
         | 
| 16 | 
            +
                TYPE_CLASSES = [
         | 
| 17 | 
            +
                  GraphQL::Schema::Scalar,
         | 
| 18 | 
            +
                  GraphQL::Schema::Enum,
         | 
| 19 | 
            +
                  GraphQL::Schema::InputObject,
         | 
| 20 | 
            +
                  GraphQL::Schema::Union,
         | 
| 21 | 
            +
                  GraphQL::Schema::Interface,
         | 
| 22 | 
            +
                  GraphQL::Schema::Object,
         | 
| 23 | 
            +
                ]
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def self.activate
         | 
| 26 | 
            +
                  deprecated_caller = caller(1, 1).first
         | 
| 27 | 
            +
                  GraphQL::Deprecation.warn "DeprecatedDSL will be removed from GraphQL-Ruby 2.0, use `.to_non_null_type` instead of `!` and remove `.activate` from #{deprecated_caller}"
         | 
| 28 | 
            +
                  TYPE_CLASSES.each { |c| c.extend(Methods) }
         | 
| 29 | 
            +
                  GraphQL::Schema::List.include(Methods)
         | 
| 30 | 
            +
                  GraphQL::Schema::NonNull.include(Methods)
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                module Methods
         | 
| 34 | 
            +
                  def !
         | 
| 35 | 
            +
                    deprecated_caller = caller(1, 1).first
         | 
| 36 | 
            +
                    GraphQL::Deprecation.warn "DeprecatedDSL will be removed from GraphQL-Ruby 2.0, use `.to_non_null_type` instead of `!` at #{deprecated_caller}"
         | 
| 37 | 
            +
                    to_non_null_type
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                if defined?(::Refinement) && Refinement.private_method_defined?(:import_methods)
         | 
| 42 | 
            +
                  TYPE_CLASSES.each do |type_class|
         | 
| 43 | 
            +
                    refine type_class.singleton_class do
         | 
| 44 | 
            +
                      import_methods Methods
         | 
| 45 | 
            +
                    end
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
                else
         | 
| 48 | 
            +
                  TYPE_CLASSES.each do |type_class|
         | 
| 49 | 
            +
                    refine type_class.singleton_class do
         | 
| 50 | 
            +
                      include Methods
         | 
| 51 | 
            +
                    end
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
            end
         | 
    
        data/lib/graphql/dig.rb
    ADDED
    
    | @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            module GraphQL
         | 
| 3 | 
            +
              module Dig
         | 
| 4 | 
            +
                # implemented using the old activesupport #dig instead of the ruby built-in
         | 
| 5 | 
            +
                # so we can use some of the magic in Schema::InputObject and Query::Arguments
         | 
| 6 | 
            +
                # to handle stringified/symbolized keys.
         | 
| 7 | 
            +
                #
         | 
| 8 | 
            +
                # @param args [Array<[String, Symbol>] Retrieves the value object corresponding to the each key objects repeatedly
         | 
| 9 | 
            +
                # @return [Object]
         | 
| 10 | 
            +
                def dig(own_key, *rest_keys)
         | 
| 11 | 
            +
                  val = self[own_key]
         | 
| 12 | 
            +
                  if val.nil? || rest_keys.empty?
         | 
| 13 | 
            +
                    val
         | 
| 14 | 
            +
                  else
         | 
| 15 | 
            +
                    val.dig(*rest_keys)
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,107 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            module GraphQL
         | 
| 3 | 
            +
              # Directives are server-defined hooks for modifying execution.
         | 
| 4 | 
            +
              #
         | 
| 5 | 
            +
              # Two directives are included out-of-the-box:
         | 
| 6 | 
            +
              # - `@skip(if: ...)` Skips the tagged field if the value of `if` is true
         | 
| 7 | 
            +
              # - `@include(if: ...)` Includes the tagged field _only_ if `if` is true
         | 
| 8 | 
            +
              #
         | 
| 9 | 
            +
              class Directive
         | 
| 10 | 
            +
                include GraphQL::Define::InstanceDefinable
         | 
| 11 | 
            +
                accepts_definitions :locations, :name, :description, :arguments, :default_directive, argument: GraphQL::Define::AssignArgument
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                attr_accessor :locations, :arguments, :name, :description, :arguments_class
         | 
| 14 | 
            +
                attr_accessor :ast_node
         | 
| 15 | 
            +
                # @api private
         | 
| 16 | 
            +
                attr_writer :default_directive
         | 
| 17 | 
            +
                ensure_defined(:locations, :arguments, :graphql_name, :name, :description, :default_directive?)
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                # Future-compatible alias
         | 
| 20 | 
            +
                # @see {GraphQL::SchemaMember}
         | 
| 21 | 
            +
                alias :graphql_name :name
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                # Future-compatible alias
         | 
| 24 | 
            +
                # @see {GraphQL::SchemaMember}
         | 
| 25 | 
            +
                alias :graphql_definition :itself
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                LOCATIONS = [
         | 
| 28 | 
            +
                  QUERY =                  :QUERY,
         | 
| 29 | 
            +
                  MUTATION =               :MUTATION,
         | 
| 30 | 
            +
                  SUBSCRIPTION =           :SUBSCRIPTION,
         | 
| 31 | 
            +
                  FIELD =                  :FIELD,
         | 
| 32 | 
            +
                  FRAGMENT_DEFINITION =    :FRAGMENT_DEFINITION,
         | 
| 33 | 
            +
                  FRAGMENT_SPREAD =        :FRAGMENT_SPREAD,
         | 
| 34 | 
            +
                  INLINE_FRAGMENT =        :INLINE_FRAGMENT,
         | 
| 35 | 
            +
                  SCHEMA =                 :SCHEMA,
         | 
| 36 | 
            +
                  SCALAR =                 :SCALAR,
         | 
| 37 | 
            +
                  OBJECT =                 :OBJECT,
         | 
| 38 | 
            +
                  FIELD_DEFINITION =       :FIELD_DEFINITION,
         | 
| 39 | 
            +
                  ARGUMENT_DEFINITION =    :ARGUMENT_DEFINITION,
         | 
| 40 | 
            +
                  INTERFACE =              :INTERFACE,
         | 
| 41 | 
            +
                  UNION =                  :UNION,
         | 
| 42 | 
            +
                  ENUM =                   :ENUM,
         | 
| 43 | 
            +
                  ENUM_VALUE =             :ENUM_VALUE,
         | 
| 44 | 
            +
                  INPUT_OBJECT =           :INPUT_OBJECT,
         | 
| 45 | 
            +
                  INPUT_FIELD_DEFINITION = :INPUT_FIELD_DEFINITION,
         | 
| 46 | 
            +
                ]
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                LOCATION_DESCRIPTIONS = {
         | 
| 49 | 
            +
                  QUERY:                    'Location adjacent to a query operation.',
         | 
| 50 | 
            +
                  MUTATION:                 'Location adjacent to a mutation operation.',
         | 
| 51 | 
            +
                  SUBSCRIPTION:             'Location adjacent to a subscription operation.',
         | 
| 52 | 
            +
                  FIELD:                    'Location adjacent to a field.',
         | 
| 53 | 
            +
                  FRAGMENT_DEFINITION:      'Location adjacent to a fragment definition.',
         | 
| 54 | 
            +
                  FRAGMENT_SPREAD:          'Location adjacent to a fragment spread.',
         | 
| 55 | 
            +
                  INLINE_FRAGMENT:          'Location adjacent to an inline fragment.',
         | 
| 56 | 
            +
                  SCHEMA:                   'Location adjacent to a schema definition.',
         | 
| 57 | 
            +
                  SCALAR:                   'Location adjacent to a scalar definition.',
         | 
| 58 | 
            +
                  OBJECT:                   'Location adjacent to an object type definition.',
         | 
| 59 | 
            +
                  FIELD_DEFINITION:         'Location adjacent to a field definition.',
         | 
| 60 | 
            +
                  ARGUMENT_DEFINITION:      'Location adjacent to an argument definition.',
         | 
| 61 | 
            +
                  INTERFACE:                'Location adjacent to an interface definition.',
         | 
| 62 | 
            +
                  UNION:                    'Location adjacent to a union definition.',
         | 
| 63 | 
            +
                  ENUM:                     'Location adjacent to an enum definition.',
         | 
| 64 | 
            +
                  ENUM_VALUE:               'Location adjacent to an enum value definition.',
         | 
| 65 | 
            +
                  INPUT_OBJECT:             'Location adjacent to an input object type definition.',
         | 
| 66 | 
            +
                  INPUT_FIELD_DEFINITION:   'Location adjacent to an input object field definition.',
         | 
| 67 | 
            +
                }
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                def initialize
         | 
| 70 | 
            +
                  @arguments = {}
         | 
| 71 | 
            +
                  @default_directive = false
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                def to_s
         | 
| 75 | 
            +
                  "<GraphQL::Directive #{name}>"
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                def on_field?
         | 
| 79 | 
            +
                  locations.include?(FIELD)
         | 
| 80 | 
            +
                end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                def on_fragment?
         | 
| 83 | 
            +
                  locations.include?(FRAGMENT_SPREAD) && locations.include?(INLINE_FRAGMENT)
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                def on_operation?
         | 
| 87 | 
            +
                  locations.include?(QUERY) && locations.include?(MUTATION) && locations.include?(SUBSCRIPTION)
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                # @return [Boolean] Is this directive supplied by default? (eg `@skip`)
         | 
| 91 | 
            +
                def default_directive?
         | 
| 92 | 
            +
                  @default_directive
         | 
| 93 | 
            +
                end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                def inspect
         | 
| 96 | 
            +
                  "#<GraphQL::Directive #{name}>"
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                def type_class
         | 
| 100 | 
            +
                  metadata[:type_class]
         | 
| 101 | 
            +
                end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                def get_argument(argument_name)
         | 
| 104 | 
            +
                  arguments[argument_name]
         | 
| 105 | 
            +
                end
         | 
| 106 | 
            +
              end
         | 
| 107 | 
            +
            end
         |