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,156 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Types
|
5
|
+
module Relay
|
6
|
+
module ConnectionBehaviors
|
7
|
+
extend Forwardable
|
8
|
+
def_delegators :@object, :cursor_from_node, :parent
|
9
|
+
|
10
|
+
def self.included(child_class)
|
11
|
+
child_class.extend(ClassMethods)
|
12
|
+
child_class.extend(Relay::DefaultRelay)
|
13
|
+
child_class.default_relay(true)
|
14
|
+
child_class.has_nodes_field(true)
|
15
|
+
child_class.node_nullable(true)
|
16
|
+
child_class.edges_nullable(true)
|
17
|
+
child_class.edge_nullable(true)
|
18
|
+
add_page_info_field(child_class)
|
19
|
+
end
|
20
|
+
|
21
|
+
module ClassMethods
|
22
|
+
# @return [Class]
|
23
|
+
attr_reader :node_type
|
24
|
+
|
25
|
+
# @return [Class]
|
26
|
+
attr_reader :edge_class
|
27
|
+
|
28
|
+
# Configure this connection to return `edges` and `nodes` based on `edge_type_class`.
|
29
|
+
#
|
30
|
+
# This method will use the inputs to create:
|
31
|
+
# - `edges` field
|
32
|
+
# - `nodes` field
|
33
|
+
# - description
|
34
|
+
#
|
35
|
+
# It's called when you subclass this base connection, trying to use the
|
36
|
+
# class name to set defaults. You can call it again in the class definition
|
37
|
+
# to override the default (or provide a value, if the default lookup failed).
|
38
|
+
def edge_type(edge_type_class, edge_class: GraphQL::Relay::Edge, node_type: edge_type_class.node_type, nodes_field: self.has_nodes_field, node_nullable: self.node_nullable, edges_nullable: self.edges_nullable, edge_nullable: self.edge_nullable)
|
39
|
+
# Set this connection's graphql name
|
40
|
+
node_type_name = node_type.graphql_name
|
41
|
+
|
42
|
+
@node_type = node_type
|
43
|
+
@edge_type = edge_type_class
|
44
|
+
@edge_class = edge_class
|
45
|
+
|
46
|
+
field :edges, [edge_type_class, null: edge_nullable],
|
47
|
+
null: edges_nullable,
|
48
|
+
description: "A list of edges.",
|
49
|
+
legacy_edge_class: edge_class, # This is used by the old runtime only, for EdgesInstrumentation
|
50
|
+
connection: false
|
51
|
+
|
52
|
+
define_nodes_field(node_nullable) if nodes_field
|
53
|
+
|
54
|
+
description("The connection type for #{node_type_name}.")
|
55
|
+
end
|
56
|
+
|
57
|
+
# Filter this list according to the way its node type would scope them
|
58
|
+
def scope_items(items, context)
|
59
|
+
node_type.scope_items(items, context)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Add the shortcut `nodes` field to this connection and its subclasses
|
63
|
+
def nodes_field(node_nullable: self.node_nullable)
|
64
|
+
define_nodes_field(node_nullable)
|
65
|
+
end
|
66
|
+
|
67
|
+
def authorized?(obj, ctx)
|
68
|
+
true # Let nodes be filtered out
|
69
|
+
end
|
70
|
+
|
71
|
+
def accessible?(ctx)
|
72
|
+
node_type.accessible?(ctx)
|
73
|
+
end
|
74
|
+
|
75
|
+
def visible?(ctx)
|
76
|
+
node_type.visible?(ctx)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Set the default `node_nullable` for this class and its child classes. (Defaults to `true`.)
|
80
|
+
# Use `node_nullable(false)` in your base class to make non-null `node` and `nodes` fields.
|
81
|
+
def node_nullable(new_value = nil)
|
82
|
+
if new_value.nil?
|
83
|
+
defined?(@node_nullable) ? @node_nullable : superclass.node_nullable
|
84
|
+
else
|
85
|
+
@node_nullable = new_value
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Set the default `edges_nullable` for this class and its child classes. (Defaults to `true`.)
|
90
|
+
# Use `edges_nullable(false)` in your base class to make non-null `edges` fields.
|
91
|
+
def edges_nullable(new_value = nil)
|
92
|
+
if new_value.nil?
|
93
|
+
defined?(@edges_nullable) ? @edges_nullable : superclass.edges_nullable
|
94
|
+
else
|
95
|
+
@edges_nullable = new_value
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Set the default `edge_nullable` for this class and its child classes. (Defaults to `true`.)
|
100
|
+
# Use `edge_nullable(false)` in your base class to make non-null `edge` fields.
|
101
|
+
def edge_nullable(new_value = nil)
|
102
|
+
if new_value.nil?
|
103
|
+
defined?(@edge_nullable) ? @edge_nullable : superclass.edge_nullable
|
104
|
+
else
|
105
|
+
@edge_nullable = new_value
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Set the default `nodes_field` for this class and its child classes. (Defaults to `true`.)
|
110
|
+
# Use `nodes_field(false)` in your base class to prevent adding of a nodes field.
|
111
|
+
def has_nodes_field(new_value = nil)
|
112
|
+
if new_value.nil?
|
113
|
+
defined?(@nodes_field) ? @nodes_field : superclass.has_nodes_field
|
114
|
+
else
|
115
|
+
@nodes_field = new_value
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def define_nodes_field(nullable)
|
122
|
+
field :nodes, [@node_type, null: nullable],
|
123
|
+
null: nullable,
|
124
|
+
description: "A list of nodes.",
|
125
|
+
connection: false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
class << self
|
130
|
+
def add_page_info_field(obj_type)
|
131
|
+
obj_type.field :page_info, GraphQL::Types::Relay::PageInfo, null: false, description: "Information to aid in pagination."
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# By default this calls through to the ConnectionWrapper's edge nodes method,
|
136
|
+
# but sometimes you need to override it to support the `nodes` field
|
137
|
+
def nodes
|
138
|
+
@object.edge_nodes
|
139
|
+
end
|
140
|
+
|
141
|
+
def edges
|
142
|
+
if @object.is_a?(GraphQL::Pagination::Connection)
|
143
|
+
@object.edges
|
144
|
+
elsif context.interpreter?
|
145
|
+
context.schema.after_lazy(object.edge_nodes) do |nodes|
|
146
|
+
nodes.map { |n| self.class.edge_class.new(n, object) }
|
147
|
+
end
|
148
|
+
else
|
149
|
+
# This is done by edges_instrumentation
|
150
|
+
@object.edge_nodes
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Types
|
5
|
+
module Relay
|
6
|
+
module DefaultRelay
|
7
|
+
def self.extended(child_class)
|
8
|
+
child_class.default_relay(true)
|
9
|
+
end
|
10
|
+
|
11
|
+
def default_relay(new_value)
|
12
|
+
@default_relay = new_value
|
13
|
+
end
|
14
|
+
|
15
|
+
def default_relay?
|
16
|
+
!!@default_relay
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_graphql
|
20
|
+
type_defn = super
|
21
|
+
type_defn.default_relay = default_relay?
|
22
|
+
type_defn
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Types
|
5
|
+
module Relay
|
6
|
+
module EdgeBehaviors
|
7
|
+
def self.included(child_class)
|
8
|
+
child_class.description("An edge in a connection.")
|
9
|
+
child_class.field(:cursor, String, null: false, description: "A cursor for use in pagination.")
|
10
|
+
child_class.extend(ClassMethods)
|
11
|
+
child_class.node_nullable(true)
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
# Get or set the Object type that this edge wraps.
|
16
|
+
#
|
17
|
+
# @param node_type [Class] A `Schema::Object` subclass
|
18
|
+
# @param null [Boolean]
|
19
|
+
def node_type(node_type = nil, null: self.node_nullable)
|
20
|
+
if node_type
|
21
|
+
@node_type = node_type
|
22
|
+
# Add a default `node` field
|
23
|
+
field :node, node_type, null: null, description: "The item at the end of the edge.", connection: false
|
24
|
+
end
|
25
|
+
@node_type
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorized?(obj, ctx)
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
def accessible?(ctx)
|
33
|
+
node_type.accessible?(ctx)
|
34
|
+
end
|
35
|
+
|
36
|
+
def visible?(ctx)
|
37
|
+
node_type.visible?(ctx)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Set the default `node_nullable` for this class and its child classes. (Defaults to `true`.)
|
41
|
+
# Use `node_nullable(false)` in your base class to make non-null `node` field.
|
42
|
+
def node_nullable(new_value = nil)
|
43
|
+
if new_value.nil?
|
44
|
+
defined?(@node_nullable) ? @node_nullable : superclass.node_nullable
|
45
|
+
else
|
46
|
+
@node_nullable = new_value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Types
|
5
|
+
module Relay
|
6
|
+
# Include this module to your root Query type to get a Relay-compliant `node(id: ID!): Node` field that uses the schema's `object_from_id` hook.
|
7
|
+
module HasNodeField
|
8
|
+
def self.included(child_class)
|
9
|
+
child_class.field(**field_options, &field_block)
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def field_options
|
14
|
+
{
|
15
|
+
name: "node",
|
16
|
+
type: GraphQL::Types::Relay::Node,
|
17
|
+
null: true,
|
18
|
+
description: "Fetches an object given its ID.",
|
19
|
+
relay_node_field: true,
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def field_block
|
24
|
+
Proc.new {
|
25
|
+
argument :id, "ID!",
|
26
|
+
description: "ID of the object."
|
27
|
+
|
28
|
+
def resolve(obj, args, ctx)
|
29
|
+
ctx.schema.object_from_id(args[:id], ctx)
|
30
|
+
end
|
31
|
+
|
32
|
+
def resolve_field(obj, args, ctx)
|
33
|
+
resolve(obj, args, ctx)
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Types
|
5
|
+
module Relay
|
6
|
+
# Include this module to your root Query type to get a Relay-style `nodes(id: ID!): [Node]` field that uses the schema's `object_from_id` hook.
|
7
|
+
module HasNodesField
|
8
|
+
def self.included(child_class)
|
9
|
+
child_class.field(**field_options, &field_block)
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def field_options
|
14
|
+
{
|
15
|
+
name: "nodes",
|
16
|
+
type: [GraphQL::Types::Relay::Node, null: true],
|
17
|
+
null: false,
|
18
|
+
description: "Fetches a list of objects given a list of IDs.",
|
19
|
+
relay_nodes_field: true,
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def field_block
|
24
|
+
Proc.new {
|
25
|
+
argument :ids, "[ID!]!",
|
26
|
+
description: "IDs of the objects."
|
27
|
+
|
28
|
+
def resolve(obj, args, ctx)
|
29
|
+
args[:ids].map { |id| ctx.schema.object_from_id(id, ctx) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def resolve_field(obj, args, ctx)
|
33
|
+
resolve(obj, args, ctx)
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Types
|
5
|
+
module Relay
|
6
|
+
# This can be used for Relay's `Node` interface,
|
7
|
+
# or you can take it as inspiration for your own implementation
|
8
|
+
# of the `Node` interface.
|
9
|
+
module Node
|
10
|
+
include GraphQL::Schema::Interface
|
11
|
+
include Types::Relay::NodeBehaviors
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Types
|
5
|
+
module Relay
|
6
|
+
module NodeBehaviors
|
7
|
+
def self.included(child_module)
|
8
|
+
child_module.extend(DefaultRelay)
|
9
|
+
child_module.description("An object with an ID.")
|
10
|
+
child_module.field(:id, ID, null: false, description: "ID of the object.")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module Types
|
4
|
+
module Relay
|
5
|
+
# This can be used for implementing `Query.node(id: ...)`,
|
6
|
+
# or use it for inspiration for your own field definition.
|
7
|
+
#
|
8
|
+
# @example Adding this field directly
|
9
|
+
# include GraphQL::Types::Relay::HasNodeField
|
10
|
+
#
|
11
|
+
# @example Implementing a similar field in your own Query root
|
12
|
+
#
|
13
|
+
# field :node, GraphQL::Types::Relay::Node, null: true,
|
14
|
+
# description: "Fetches an object given its ID" do
|
15
|
+
# argument :id, ID, required: true
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# def node(id:)
|
19
|
+
# context.schema.object_from_id(id, context)
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
NodeField = GraphQL::Schema::Field.new(owner: nil, **HasNodeField.field_options, &HasNodeField.field_block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module Types
|
4
|
+
module Relay
|
5
|
+
# This can be used for implementing `Query.nodes(ids: ...)`,
|
6
|
+
# or use it for inspiration for your own field definition.
|
7
|
+
#
|
8
|
+
# @example Adding this field directly
|
9
|
+
# include GraphQL::Types::Relay::HasNodesField
|
10
|
+
#
|
11
|
+
# @example Implementing a similar field in your own Query root
|
12
|
+
#
|
13
|
+
# field :nodes, [GraphQL::Types::Relay::Node, null: true], null: false,
|
14
|
+
# description: Fetches a list of objects given a list of IDs." do
|
15
|
+
# argument :ids, [ID], required: true
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# def nodes(ids:)
|
19
|
+
# ids.map do |id|
|
20
|
+
# context.schema.object_from_id(context, id)
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
NodesField = GraphQL::Schema::Field.new(owner: nil, **HasNodesField.field_options, &HasNodesField.field_block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
module Types
|
4
|
+
module Relay
|
5
|
+
module PageInfoBehaviors
|
6
|
+
def self.included(child_class)
|
7
|
+
child_class.extend GraphQL::Types::Relay::DefaultRelay
|
8
|
+
|
9
|
+
child_class.description "Information about pagination in a connection."
|
10
|
+
child_class.field :has_next_page, Boolean, null: false,
|
11
|
+
description: "When paginating forwards, are there more items?"
|
12
|
+
|
13
|
+
child_class.field :has_previous_page, Boolean, null: false,
|
14
|
+
description: "When paginating backwards, are there more items?"
|
15
|
+
|
16
|
+
child_class.field :start_cursor, String, null: true,
|
17
|
+
description: "When paginating backwards, the cursor to continue."
|
18
|
+
|
19
|
+
child_class.field :end_cursor, String, null: true,
|
20
|
+
description: "When paginating forwards, the cursor to continue."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# behavior modules:
|
4
|
+
require "graphql/types/relay/default_relay"
|
5
|
+
require "graphql/types/relay/connection_behaviors"
|
6
|
+
require "graphql/types/relay/edge_behaviors"
|
7
|
+
require "graphql/types/relay/node_behaviors"
|
8
|
+
require "graphql/types/relay/page_info_behaviors"
|
9
|
+
require "graphql/types/relay/has_node_field"
|
10
|
+
require "graphql/types/relay/has_nodes_field"
|
11
|
+
|
12
|
+
# concrete classes based on the gem defaults:
|
13
|
+
require "graphql/types/relay/page_info"
|
14
|
+
require "graphql/types/relay/base_connection"
|
15
|
+
require "graphql/types/relay/base_edge"
|
16
|
+
require "graphql/types/relay/node"
|
17
|
+
require "graphql/types/relay/node_field"
|
18
|
+
require "graphql/types/relay/nodes_field"
|
19
|
+
|
20
|
+
module GraphQL
|
21
|
+
module Types
|
22
|
+
# This module contains some types and fields that could support Relay conventions in GraphQL.
|
23
|
+
#
|
24
|
+
# You can use these classes out of the box if you want, but if you want to use your _own_
|
25
|
+
# GraphQL extensions along with the features in this code, you could also
|
26
|
+
# open up the source files and copy the relevant methods and configuration into
|
27
|
+
# your own classes.
|
28
|
+
#
|
29
|
+
# For example, the provided object types extend {Types::Relay::BaseObject},
|
30
|
+
# but you might want to:
|
31
|
+
#
|
32
|
+
# 1. Migrate the extensions from {Types::Relay::BaseObject} into _your app's_ base object
|
33
|
+
# 2. Copy {Relay::BaseConnection}, {Relay::BaseEdge}, etc into _your app_, and
|
34
|
+
# change them to extend _your_ base object.
|
35
|
+
#
|
36
|
+
# Similarly, `BaseField`'s extensions could be migrated to your app
|
37
|
+
# and `Node` could be implemented to mix in your base interface module.
|
38
|
+
module Relay
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module Types
|
5
|
+
class String < GraphQL::Schema::Scalar
|
6
|
+
description "Represents textual data as UTF-8 character sequences. This type is most often used by GraphQL to represent free-form human-readable text."
|
7
|
+
|
8
|
+
def self.coerce_result(value, ctx)
|
9
|
+
str = value.to_s
|
10
|
+
if str.encoding == Encoding::UTF_8
|
11
|
+
str
|
12
|
+
elsif str.frozen?
|
13
|
+
str.encode(Encoding::UTF_8)
|
14
|
+
else
|
15
|
+
str.encode!(Encoding::UTF_8)
|
16
|
+
end
|
17
|
+
rescue EncodingError
|
18
|
+
err = GraphQL::StringEncodingError.new(str, context: ctx)
|
19
|
+
ctx.schema.type_error(err, ctx)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.coerce_input(value, _ctx)
|
23
|
+
value.is_a?(::String) ? value : nil
|
24
|
+
end
|
25
|
+
|
26
|
+
default_scalar true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "graphql/types/boolean"
|
3
|
+
require "graphql/types/big_int"
|
4
|
+
require "graphql/types/float"
|
5
|
+
require "graphql/types/id"
|
6
|
+
require "graphql/types/int"
|
7
|
+
require "graphql/types/iso_8601_date"
|
8
|
+
require "graphql/types/iso_8601_date_time"
|
9
|
+
require "graphql/types/json"
|
10
|
+
require "graphql/types/string"
|
11
|
+
require "graphql/types/relay"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
# When an `authorized?` hook returns false, this error is used to communicate the failure.
|
4
|
+
# It's passed to {Schema.unauthorized_object}.
|
5
|
+
#
|
6
|
+
# Alternatively, custom code in `authorized?` may raise this error. It will be routed the same way.
|
7
|
+
class UnauthorizedError < GraphQL::Error
|
8
|
+
# @return [Object] the application object that failed the authorization check
|
9
|
+
attr_reader :object
|
10
|
+
|
11
|
+
# @return [Class] the GraphQL object type whose `.authorized?` method was called (and returned false)
|
12
|
+
attr_reader :type
|
13
|
+
|
14
|
+
# @return [GraphQL::Query::Context] the context for the current query
|
15
|
+
attr_accessor :context
|
16
|
+
|
17
|
+
def initialize(message = nil, object: nil, type: nil, context: nil)
|
18
|
+
if message.nil? && object.nil? && type.nil?
|
19
|
+
raise ArgumentError, "#{self.class.name} requires either a message or keywords"
|
20
|
+
end
|
21
|
+
|
22
|
+
@object = object
|
23
|
+
@type = type
|
24
|
+
@context = context
|
25
|
+
message ||= "An instance of #{object.class} failed #{type.graphql_name}'s authorization check"
|
26
|
+
super(message)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
class UnauthorizedFieldError < GraphQL::UnauthorizedError
|
4
|
+
# @return [Field] the field that failed the authorization check
|
5
|
+
attr_accessor :field
|
6
|
+
|
7
|
+
def initialize(message = nil, object: nil, type: nil, context: nil, field: nil)
|
8
|
+
if message.nil? && [field, type].any?(&:nil?)
|
9
|
+
raise ArgumentError, "#{self.class.name} requires either a message or keywords"
|
10
|
+
end
|
11
|
+
|
12
|
+
@field = field
|
13
|
+
message ||= begin
|
14
|
+
if object
|
15
|
+
"An instance of #{object.class} failed #{type.name}'s authorization check on field #{field.name}"
|
16
|
+
else
|
17
|
+
"Failed #{type.name}'s authorization check on field #{field.name}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
super(message, object: object, type: type, context: context)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|