Module: GraphQL

Extended by:
Autoload
Defined in:
lib/graphql.rb,
lib/graphql/dig.rb,
lib/graphql/query.rb,
lib/graphql/types.rb,
lib/graphql/schema.rb,
lib/graphql/current.rb,
lib/graphql/railtie.rb,
lib/graphql/tracing.rb,
lib/graphql/version.rb,
lib/graphql/analysis.rb,
lib/graphql/autoload.rb,
lib/graphql/language.rb,
lib/graphql/types/id.rb,
lib/graphql/backtrace.rb,
lib/graphql/execution.rb,
lib/graphql/rake_task.rb,
lib/graphql/types/int.rb,
lib/graphql/dataloader.rb,
lib/graphql/type_kinds.rb,
lib/graphql/types/json.rb,
lib/graphql/parse_error.rb,
lib/graphql/schema/enum.rb,
lib/graphql/schema/list.rb,
lib/graphql/types/float.rb,
lib/graphql/types/relay.rb,
lib/graphql/query/result.rb,
lib/graphql/schema/field.rb,
lib/graphql/schema/union.rb,
lib/graphql/types/string.rb,
lib/graphql/introspection.rb,
lib/graphql/query/context.rb,
lib/graphql/schema/finder.rb,
lib/graphql/schema/loader.rb,
lib/graphql/schema/member.rb,
lib/graphql/schema/object.rb,
lib/graphql/schema/scalar.rb,
lib/graphql/schema/warden.rb,
lib/graphql/subscriptions.rb,
lib/graphql/tracing/trace.rb,
lib/graphql/types/big_int.rb,
lib/graphql/types/boolean.rb,
lib/graphql/analysis_error.rb,
lib/graphql/coercion_error.rb,
lib/graphql/execution/lazy.rb,
lib/graphql/language/cache.rb,
lib/graphql/language/lexer.rb,
lib/graphql/language/nodes.rb,
lib/graphql/name_validator.rb,
lib/graphql/schema/printer.rb,
lib/graphql/schema/timeout.rb,
lib/graphql/schema/wrapper.rb,
lib/graphql/backtrace/table.rb,
lib/graphql/backtrace/trace.rb,
lib/graphql/execution_error.rb,
lib/graphql/language/parser.rb,
lib/graphql/query/variables.rb,
lib/graphql/relay/range_add.rb,
lib/graphql/schema/addition.rb,
lib/graphql/schema/argument.rb,
lib/graphql/schema/mutation.rb,
lib/graphql/schema/non_null.rb,
lib/graphql/schema/resolver.rb,
lib/graphql/testing/helpers.rb,
lib/graphql/analysis/visitor.rb,
lib/graphql/backtrace/tracer.rb,
lib/graphql/execution/errors.rb,
lib/graphql/language/comment.rb,
lib/graphql/language/printer.rb,
lib/graphql/language/visitor.rb,
lib/graphql/schema/directive.rb,
lib/graphql/schema/interface.rb,
lib/graphql/schema/null_mask.rb,
lib/graphql/schema/validator.rb,
lib/graphql/types/relay/node.rb,
lib/graphql/analysis/analyzer.rb,
lib/graphql/dataloader/source.rb,
lib/graphql/query/fingerprint.rb,
lib/graphql/schema/enum_value.rb,
lib/graphql/schema/visibility.rb,
lib/graphql/dataloader/request.rb,
lib/graphql/invalid_name_error.rb,
lib/graphql/invalid_null_error.rb,
lib/graphql/query/null_context.rb,
lib/graphql/rake_task/validate.rb,
lib/graphql/runtime_type_error.rb,
lib/graphql/unauthorized_error.rb,
lib/graphql/date_encoding_error.rb,
lib/graphql/execution/lookahead.rb,
lib/graphql/execution/multiplex.rb,
lib/graphql/language/generation.rb,
lib/graphql/schema/input_object.rb,
lib/graphql/schema/subscription.rb,
lib/graphql/subscriptions/event.rb,
lib/graphql/tracing/scout_trace.rb,
lib/graphql/types/iso_8601_date.rb,
lib/graphql/analysis/field_usage.rb,
lib/graphql/analysis/query_depth.rb,
lib/graphql/schema/member/scoped.rb,
lib/graphql/tracing/legacy_trace.rb,
lib/graphql/tracing/sentry_trace.rb,
lib/graphql/tracing/statsd_trace.rb,
lib/graphql/execution/interpreter.rb,
lib/graphql/language/block_string.rb,
lib/graphql/pagination/connection.rb,
lib/graphql/schema/always_visible.rb,
lib/graphql/schema/built_in_types.rb,
lib/graphql/schema/directive/skip.rb,
lib/graphql/string_encoding_error.rb,
lib/graphql/tracing/scout_tracing.rb,
lib/graphql/types/relay/base_edge.rb,
lib/graphql/types/relay/page_info.rb,
lib/graphql/unresolved_type_error.rb,
lib/graphql/backtrace/traced_error.rb,
lib/graphql/dataloader/request_all.rb,
lib/graphql/integer_decoding_error.rb,
lib/graphql/integer_encoding_error.rb,
lib/graphql/pagination/connections.rb,
lib/graphql/schema/base_64_encoder.rb,
lib/graphql/schema/field_extension.rb,
lib/graphql/schema/late_bound_type.rb,
lib/graphql/schema/member/has_path.rb,
lib/graphql/schema/type_expression.rb,
lib/graphql/schema/type_membership.rb,
lib/graphql/tracing/data_dog_trace.rb,
lib/graphql/tracing/platform_trace.rb,
lib/graphql/tracing/statsd_tracing.rb,
lib/graphql/duration_encoding_error.rb,
lib/graphql/introspection/type_type.rb,
lib/graphql/language/static_visitor.rb,
lib/graphql/schema/directive/one_of.rb,
lib/graphql/schema/visibility/visit.rb,
lib/graphql/static_validation/error.rb,
lib/graphql/subscriptions/serialize.rb,
lib/graphql/tracing/appoptics_trace.rb,
lib/graphql/tracing/appsignal_trace.rb,
lib/graphql/tracing/new_relic_trace.rb,
lib/graphql/types/iso_8601_duration.rb,
lib/graphql/analysis/max_query_depth.rb,
lib/graphql/backtrace/inspect_result.rb,
lib/graphql/introspection/field_type.rb,
lib/graphql/rubocop/graphql/base_cop.rb,
lib/graphql/schema/directive/feature.rb,
lib/graphql/schema/directive/flagged.rb,
lib/graphql/schema/directive/include.rb,
lib/graphql/schema/member/build_type.rb,
lib/graphql/schema/member/has_fields.rb,
lib/graphql/tracing/data_dog_tracing.rb,
lib/graphql/tracing/platform_tracing.rb,
lib/graphql/tracing/prometheus_trace.rb,
lib/graphql/types/iso_8601_date_time.rb,
lib/graphql/unauthorized_field_error.rb,
lib/graphql/analysis/query_complexity.rb,
lib/graphql/introspection/base_object.rb,
lib/graphql/introspection/schema_type.rb,
lib/graphql/language/definition_slice.rb,
lib/graphql/query/validation_pipeline.rb,
lib/graphql/schema/unique_within_type.rb,
lib/graphql/schema/visibility/profile.rb,
lib/graphql/tracing/appoptics_tracing.rb,
lib/graphql/tracing/appsignal_tracing.rb,
lib/graphql/tracing/new_relic_tracing.rb,
lib/graphql/dataloader/null_dataloader.rb,
lib/graphql/execution/directive_checks.rb,
lib/graphql/introspection/entry_points.rb,
lib/graphql/language/sanitized_printer.rb,
lib/graphql/schema/directive/transform.rb,
lib/graphql/schema/member/has_ast_node.rb,
lib/graphql/tracing/legacy_hooks_trace.rb,
lib/graphql/tracing/prometheus_tracing.rb,
lib/graphql/types/relay/edge_behaviors.rb,
lib/graphql/types/relay/has_node_field.rb,
lib/graphql/types/relay/node_behaviors.rb,
lib/graphql/dataloader/async_dataloader.rb,
lib/graphql/pagination/array_connection.rb,
lib/graphql/schema/directive/deprecated.rb,
lib/graphql/schema/find_inherited_value.rb,
lib/graphql/schema/introspection_system.rb,
lib/graphql/schema/member/has_arguments.rb,
lib/graphql/schema/visibility/migration.rb,
lib/graphql/static_validation/all_rules.rb,
lib/graphql/static_validation/validator.rb,
lib/graphql/tracing/notifications_trace.rb,
lib/graphql/types/relay/base_connection.rb,
lib/graphql/types/relay/has_nodes_field.rb,
lib/graphql/introspection/directive_type.rb,
lib/graphql/introspection/dynamic_fields.rb,
lib/graphql/introspection/type_kind_enum.rb,
lib/graphql/query/context/scoped_context.rb,
lib/graphql/schema/build_from_definition.rb,
lib/graphql/schema/field/scope_extension.rb,
lib/graphql/schema/member/has_directives.rb,
lib/graphql/schema/member/has_interfaces.rb,
lib/graphql/schema/member/has_validators.rb,
lib/graphql/analysis/max_query_complexity.rb,
lib/graphql/execution/interpreter/resolve.rb,
lib/graphql/execution/interpreter/runtime.rb,
lib/graphql/introspection/enum_value_type.rb,
lib/graphql/query/input_validation_result.rb,
lib/graphql/schema/directive/specified_by.rb,
lib/graphql/schema/member/relay_shortcuts.rb,
lib/graphql/schema/member/validates_input.rb,
lib/graphql/schema/relay_classic_mutation.rb,
lib/graphql/tracing/notifications_tracing.rb,
lib/graphql/unauthorized_enum_value_error.rb,
lib/graphql/execution/lazy/lazy_method_map.rb,
lib/graphql/introspection/input_value_type.rb,
lib/graphql/pagination/relation_connection.rb,
lib/graphql/schema/member/base_dsl_methods.rb,
lib/graphql/schema/validator/all_validator.rb,
lib/graphql/static_validation/base_visitor.rb,
lib/graphql/execution/interpreter/arguments.rb,
lib/graphql/query/variable_validation_error.rb,
lib/graphql/types/relay/page_info_behaviors.rb,
lib/graphql/schema/has_single_input_argument.rb,
lib/graphql/schema/member/graphql_type_names.rb,
lib/graphql/schema/resolver/has_payload_type.rb,
lib/graphql/subscriptions/broadcast_analyzer.rb,
lib/graphql/types/relay/connection_behaviors.rb,
lib/graphql/rubocop/graphql/default_null_true.rb,
lib/graphql/schema/field/connection_extension.rb,
lib/graphql/schema/member/type_system_helpers.rb,
lib/graphql/schema/validator/format_validator.rb,
lib/graphql/schema/validator/length_validator.rb,
lib/graphql/rubocop/graphql/field_type_in_block.rb,
lib/graphql/rubocop/graphql/root_types_in_block.rb,
lib/graphql/schema/validator/required_validator.rb,
lib/graphql/static_validation/literal_validator.rb,
lib/graphql/execution/interpreter/argument_value.rb,
lib/graphql/load_application_object_failed_error.rb,
lib/graphql/pagination/sequel_dataset_connection.rb,
lib/graphql/schema/member/has_deprecation_reason.rb,
lib/graphql/schema/validator/exclusion_validator.rb,
lib/graphql/schema/validator/inclusion_validator.rb,
lib/graphql/static_validation/validation_context.rb,
lib/graphql/execution/interpreter/arguments_cache.rb,
lib/graphql/introspection/directive_location_enum.rb,
lib/graphql/rubocop/graphql/default_required_true.rb,
lib/graphql/schema/validator/allow_null_validator.rb,
lib/graphql/static_validation/interpreter_visitor.rb,
lib/graphql/execution/interpreter/execution_errors.rb,
lib/graphql/pagination/mongoid_relation_connection.rb,
lib/graphql/schema/validator/allow_blank_validator.rb,
lib/graphql/execution/interpreter/handles_raw_value.rb,
lib/graphql/schema/member/has_unresolved_type_error.rb,
lib/graphql/schema/validator/numericality_validator.rb,
lib/graphql/language/document_from_schema_definition.rb,
lib/graphql/schema/build_from_definition/resolve_map.rb,
lib/graphql/subscriptions/action_cable_subscriptions.rb,
lib/graphql/static_validation/definition_dependencies.rb,
lib/graphql/static_validation/rules/fields_will_merge.rb,
lib/graphql/static_validation/rules/query_root_exists.rb,
lib/graphql/static_validation/rules/fragments_are_used.rb,
lib/graphql/static_validation/validation_timeout_error.rb,
lib/graphql/tracing/active_support_notifications_trace.rb,
lib/graphql/tracing/prometheus_trace/graphql_collector.rb,
lib/graphql/static_validation/rules/fragments_are_named.rb,
lib/graphql/execution/interpreter/runtime/graphql_result.rb,
lib/graphql/pagination/active_record_relation_connection.rb,
lib/graphql/static_validation/rules/fragment_types_exist.rb,
lib/graphql/static_validation/rules/fragments_are_finite.rb,
lib/graphql/static_validation/rules/mutation_root_exists.rb,
lib/graphql/tracing/active_support_notifications_tracing.rb,
lib/graphql/static_validation/rules/arguments_are_defined.rb,
lib/graphql/static_validation/rules/directives_are_defined.rb,
lib/graphql/static_validation/rules/fields_will_merge_error.rb,
lib/graphql/static_validation/rules/query_root_exists_error.rb,
lib/graphql/static_validation/rules/fragments_are_used_error.rb,
lib/graphql/static_validation/rules/subscription_root_exists.rb,
lib/graphql/static_validation/rules/argument_names_are_unique.rb,
lib/graphql/static_validation/rules/fragment_names_are_unique.rb,
lib/graphql/static_validation/rules/fragments_are_named_error.rb,
lib/graphql/static_validation/rules/operation_names_are_valid.rb,
lib/graphql/static_validation/rules/variable_names_are_unique.rb,
lib/graphql/static_validation/rules/variables_are_input_types.rb,
lib/graphql/static_validation/rules/fields_are_defined_on_type.rb,
lib/graphql/static_validation/rules/fragment_types_exist_error.rb,
lib/graphql/static_validation/rules/fragments_are_finite_error.rb,
lib/graphql/static_validation/rules/mutation_root_exists_error.rb,
lib/graphql/static_validation/rules/no_definitions_are_present.rb,
lib/graphql/static_validation/rules/arguments_are_defined_error.rb,
lib/graphql/static_validation/rules/variable_usages_are_allowed.rb,
lib/graphql/static_validation/rules/directives_are_defined_error.rb,
lib/graphql/subscriptions/default_subscription_resolve_extension.rb,
lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb,
lib/graphql/static_validation/rules/input_object_names_are_unique.rb,
lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb,
lib/graphql/static_validation/rules/required_arguments_are_present.rb,
lib/graphql/static_validation/rules/subscription_root_exists_error.rb,
lib/graphql/static_validation/rules/unique_directives_per_location.rb,
lib/graphql/static_validation/rules/variables_are_used_and_defined.rb,
lib/graphql/static_validation/rules/argument_names_are_unique_error.rb,
lib/graphql/static_validation/rules/fragment_names_are_unique_error.rb,
lib/graphql/static_validation/rules/operation_names_are_valid_error.rb,
lib/graphql/static_validation/rules/variable_names_are_unique_error.rb,
lib/graphql/static_validation/rules/variables_are_input_types_error.rb,
lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb,
lib/graphql/static_validation/rules/argument_literals_are_compatible.rb,
lib/graphql/static_validation/rules/fields_are_defined_on_type_error.rb,
lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb,
lib/graphql/static_validation/rules/no_definitions_are_present_error.rb,
lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb,
lib/graphql/static_validation/rules/variable_usages_are_allowed_error.rb,
lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb,
lib/graphql/static_validation/rules/fragment_spreads_are_possible_error.rb,
lib/graphql/static_validation/rules/input_object_names_are_unique_error.rb,
lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb,
lib/graphql/static_validation/rules/required_arguments_are_present_error.rb,
lib/graphql/static_validation/rules/unique_directives_per_location_error.rb,
lib/graphql/static_validation/rules/variables_are_used_and_defined_error.rb,
lib/graphql/static_validation/rules/argument_literals_are_compatible_error.rb,
lib/graphql/static_validation/rules/fragments_are_on_composite_types_error.rb,
lib/graphql/static_validation/rules/directives_are_in_valid_locations_error.rb,
lib/graphql/static_validation/rules/fields_have_appropriate_selections_error.rb,
lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb,
lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb,
lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed_error.rb,
lib/graphql/static_validation/rules/required_input_object_attributes_are_present_error.rb

Defined Under Namespace

Modules: Analysis, Autoload, Current, Dig, EmptyObjects, Execution, Introspection, Language, Pagination, Relay, Rubocop, StaticValidation, Testing, Tracing, TypeKinds, Types Classes: AnalysisError, Backtrace, CoercionError, Dataloader, DateEncodingError, DurationEncodingError, Error, ExecutionError, IntegerDecodingError, IntegerEncodingError, InvalidNameError, InvalidNullError, InvariantError, LoadApplicationObjectFailedError, NameValidator, ParseError, Query, Railtie, RakeTask, RequiredImplementationMissingError, RuntimeTypeError, Schema, StringEncodingError, Subscriptions, UnauthorizedEnumValueError, UnauthorizedError, UnauthorizedFieldError, UnresolvedTypeError

Constant Summary collapse

VERSION =
"2.4.6"

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Autoload

autoload, eager_load!

Class Attribute Details

.default_parserObject



39
40
41
# File 'lib/graphql.rb', line 39

def default_parser
  @default_parser ||= GraphQL::Language::Parser
end

.envObject

Returns the value of attribute env.



101
102
103
# File 'lib/graphql.rb', line 101

def env
  @env
end

.reject_numbers_followed_by_namesObject

If true, the parser should raise when an integer or float is followed immediately by an identifier (instead of a space or punctuation)



84
85
86
# File 'lib/graphql.rb', line 84

def reject_numbers_followed_by_names
  @reject_numbers_followed_by_names
end

Class Method Details

.eager_load!Object

Load all autoload-configured classes, and also eager-load dependents who have autoloads of their own.



14
15
16
17
18
19
# File 'lib/graphql.rb', line 14

def self.eager_load!
  super
  Query.eager_load!
  Types.eager_load!
  Schema.eager_load!
end

.ensure_eager_load!void

This method returns an undefined value.

If production? is detected but eager_load! wasn’t called, emit a warning.



88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/graphql.rb', line 88

def ensure_eager_load!
  if production? && !eager_loading?
    warn <<~WARNING
      GraphQL-Ruby thinks this is a production deployment but didn't eager-load its constants. Address this by:

        - Calling `GraphQL.eager_load!` in a production-only initializer or setup hook
        - Assign `GraphQL.env = "..."` to something _other_ than `"production"` (for example, `GraphQL.env = "development"`)

      More details: https://graphql-ruby.org/schema/definition#production-considerations
    WARNING
  end
end

.parse(graphql_string, trace: GraphQL::Tracing::NullTrace, filename: nil, max_tokens: nil) ⇒ GraphQL::Language::Nodes::Document

Turn a query string or schema definition into an AST

Parameters:

  • graphql_string (String)

    a GraphQL query string or schema definition

Returns:



49
50
51
# File 'lib/graphql.rb', line 49

def self.parse(graphql_string, trace: GraphQL::Tracing::NullTrace, filename: nil, max_tokens: nil)
  default_parser.parse(graphql_string, trace: trace, filename: filename, max_tokens: max_tokens)
end

.parse_file(filename) ⇒ GraphQL::Language::Nodes::Document

Read the contents of filename and parse them as GraphQL

Parameters:

  • filename (String)

    Path to a .graphql file containing IDL or query

Returns:



56
57
58
59
# File 'lib/graphql.rb', line 56

def self.parse_file(filename)
  content = File.read(filename)
  default_parser.parse(content, filename: filename)
end

.parse_with_racc(string, filename: nil, trace: GraphQL::Tracing::NullTrace) ⇒ Object



66
67
68
69
# File 'lib/graphql.rb', line 66

def self.parse_with_racc(string, filename: nil, trace: GraphQL::Tracing::NullTrace)
  warn "`GraphQL.parse_with_racc` is deprecated; GraphQL-Ruby no longer uses racc for parsing. Call `GraphQL.parse` or `GraphQL::Language::Parser.parse` instead."
  GraphQL::Language::Parser.parse(string, filename: filename, trace: trace)
end

.scan(graphql_string) ⇒ Array<Array>

Returns:

  • (Array<Array>)


62
63
64
# File 'lib/graphql.rb', line 62

def self.scan(graphql_string)
  default_parser.scan(graphql_string)
end

.scan_with_ruby(graphql_string) ⇒ Object



71
72
73
# File 'lib/graphql.rb', line 71

def self.scan_with_ruby(graphql_string)
  GraphQL::Language::Lexer.tokenize(graphql_string)
end