Module: GraphQL

Defined in:
lib/graphql.rb,
lib/graphql/dig.rb,
lib/graphql/query.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/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/subset.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/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/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/schema/types_migration.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/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/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/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, 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.3.14"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_parserObject



28
29
30
# File 'lib/graphql.rb', line 28

def default_parser
  @default_parser ||= GraphQL::Language::Parser
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)



73
74
75
# File 'lib/graphql.rb', line 73

def reject_numbers_followed_by_names
  @reject_numbers_followed_by_names
end

Class Method Details

.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:



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

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:



45
46
47
48
# File 'lib/graphql.rb', line 45

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



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

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>)


51
52
53
# File 'lib/graphql.rb', line 51

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

.scan_with_ruby(graphql_string) ⇒ Object



60
61
62
# File 'lib/graphql.rb', line 60

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