Module: GraphQL

Defined in:
lib/graphql.rb,
lib/graphql/dig.rb,
lib/graphql/query.rb,
lib/graphql/filter.rb,
lib/graphql/schema.rb,
lib/graphql/railtie.rb,
lib/graphql/tracing.rb,
lib/graphql/version.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/deprecation.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/analysis/ast.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/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/language/token.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/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/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/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/types/iso_8601_date.rb,
lib/graphql/analysis/ast/visitor.rb,
lib/graphql/schema/member/scoped.rb,
lib/graphql/analysis/ast/analyzer.rb,
lib/graphql/execution/interpreter.rb,
lib/graphql/language/block_string.rb,
lib/graphql/pagination/connection.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/statsd_tracing.rb,
lib/graphql/introspection/type_type.rb,
lib/graphql/static_validation/error.rb,
lib/graphql/subscriptions/serialize.rb,
lib/graphql/analysis/ast/field_usage.rb,
lib/graphql/analysis/ast/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/types/iso_8601_date_time.rb,
lib/graphql/unauthorized_field_error.rb,
lib/graphql/execution/instrumentation.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/invalid_type_error.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/types/relay/default_relay.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/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/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/types/relay/base_connection.rb,
lib/graphql/types/relay/has_nodes_field.rb,
lib/graphql/analysis/ast/max_query_depth.rb,
lib/graphql/introspection/directive_type.rb,
lib/graphql/introspection/dynamic_fields.rb,
lib/graphql/introspection/type_kind_enum.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/static_validation/type_stack.rb,
lib/graphql/analysis/ast/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/member/relay_shortcuts.rb,
lib/graphql/schema/member/validates_input.rb,
lib/graphql/schema/relay_classic_mutation.rb,
lib/graphql/subscriptions/instrumentation.rb,
lib/graphql/tracing/notifications_tracing.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/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/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/analysis/ast/max_query_complexity.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/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/static_validation/rules/fragments_are_named.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/tracing/prometheus_tracing/graphql_collector.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/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/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, Deprecation, Dig, Execution, Introspection, Language, Pagination, Relay, Rubocop, Ruby2Keywords, StaticValidation, Tracing, TypeKinds, Types Classes: AnalysisError, Backtrace, CoercionError, Dataloader, DateEncodingError, Error, ExecutionError, Filter, IntegerDecodingError, IntegerEncodingError, InvalidNameError, InvalidNullError, InvariantError, LoadApplicationObjectFailedError, NameValidator, ParseError, Query, Railtie, RakeTask, RequiredImplementationMissingError, RuntimeTypeError, Schema, StringEncodingError, Subscriptions, UnauthorizedError, UnauthorizedFieldError, UnresolvedTypeError

Constant Summary collapse

VERSION =
"2.0.7"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_parserObject



35
36
37
# File 'lib/graphql.rb', line 35

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

Class Method Details

.parse(graphql_string, tracer: GraphQL::Tracing::NullTracer) ⇒ 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:



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

def self.parse(graphql_string, tracer: GraphQL::Tracing::NullTracer)
  parse_with_racc(graphql_string, tracer: tracer)
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:



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

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

.parse_with_racc(string, filename: nil, tracer: GraphQL::Tracing::NullTracer) ⇒ Object



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

def self.parse_with_racc(string, filename: nil, tracer: GraphQL::Tracing::NullTracer)
  GraphQL::Language::Parser.parse(string, filename: filename, tracer: tracer)
end

.scan(graphql_string) ⇒ Array<GraphQL::Language::Token>

Returns:



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

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

.scan_with_ragel(graphql_string) ⇒ Object



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

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