Module: GraphQL

Defined in:
lib/graphql.rb,
lib/graphql/field.rb,
lib/graphql/query.rb,
lib/graphql/define.rb,
lib/graphql/schema.rb,
lib/graphql/version.rb,
lib/graphql/argument.rb,
lib/graphql/base_type.rb,
lib/graphql/directive.rb,
lib/graphql/enum_type.rb,
lib/graphql/list_type.rb,
lib/graphql/relay/edge.rb,
lib/graphql/type_kinds.rb,
lib/graphql/union_type.rb,
lib/graphql/object_type.rb,
lib/graphql/scalar_type.rb,
lib/graphql/field/resolve.rb,
lib/graphql/introspection.rb,
lib/graphql/non_null_type.rb,
lib/graphql/query/context.rb,
lib/graphql/schema/loader.rb,
lib/graphql/analysis_error.rb,
lib/graphql/interface_type.rb,
lib/graphql/language/lexer.rb,
lib/graphql/language/nodes.rb,
lib/graphql/language/token.rb,
lib/graphql/query/executor.rb,
lib/graphql/relay/mutation.rb,
lib/graphql/schema/printer.rb,
lib/graphql/execution_error.rb,
lib/graphql/language/parser.rb,
lib/graphql/query/arguments.rb,
lib/graphql/query/variables.rb,
lib/graphql/relay/edge_type.rb,
lib/graphql/relay/page_info.rb,
lib/graphql/schema/type_map.rb,
lib/graphql/language/visitor.rb,
lib/graphql/input_object_type.rb,
lib/graphql/schema/validation.rb,
lib/graphql/execution/typecast.rb,
lib/graphql/invalid_null_error.rb,
lib/graphql/define/type_definer.rb,
lib/graphql/language/generation.rb,
lib/graphql/query/literal_input.rb,
lib/graphql/schema/reduce_types.rb,
lib/graphql/analysis/field_usage.rb,
lib/graphql/analysis/query_depth.rb,
lib/graphql/language/parser_tests.rb,
lib/graphql/relay/base_connection.rb,
lib/graphql/relay/connection_type.rb,
lib/graphql/schema/possible_types.rb,
lib/graphql/analysis/analyze_query.rb,
lib/graphql/define/assign_argument.rb,
lib/graphql/query/serial_execution.rb,
lib/graphql/relay/array_connection.rb,
lib/graphql/relay/connection_field.rb,
lib/graphql/schema/type_expression.rb,
lib/graphql/relay/global_id_resolve.rb,
lib/graphql/schema/middleware_chain.rb,
lib/graphql/analysis/max_query_depth.rb,
lib/graphql/define/assign_connection.rb,
lib/graphql/define/assign_enum_value.rb,
lib/graphql/relay/connection_resolve.rb,
lib/graphql/schema/rescue_middleware.rb,
lib/graphql/analysis/query_complexity.rb,
lib/graphql/define/instance_definable.rb,
lib/graphql/define/non_null_with_bang.rb,
lib/graphql/language/definition_slice.rb,
lib/graphql/relay/relation_connection.rb,
lib/graphql/schema/invalid_type_error.rb,
lib/graphql/schema/timeout_middleware.rb,
lib/graphql/static_validation/message.rb,
lib/graphql/define/assign_object_field.rb,
lib/graphql/execution/directive_checks.rb,
lib/graphql/introspection/schema_field.rb,
lib/graphql/schema/catchall_middleware.rb,
lib/graphql/define/defined_object_proxy.rb,
lib/graphql/static_validation/all_rules.rb,
lib/graphql/static_validation/validator.rb,
lib/graphql/internal_representation/node.rb,
lib/graphql/introspection/typename_field.rb,
lib/graphql/static_validation/type_stack.rb,
lib/graphql/analysis/max_query_complexity.rb,
lib/graphql/define/assign_global_id_field.rb,
lib/graphql/query/input_validation_result.rb,
lib/graphql/internal_representation/rewrite.rb,
lib/graphql/query/variable_validation_error.rb,
lib/graphql/introspection/type_by_name_field.rb,
lib/graphql/relay/global_node_identification.rb,
lib/graphql/static_validation/literal_validator.rb,
lib/graphql/static_validation/validation_context.rb,
lib/graphql/static_validation/arguments_validator.rb,
lib/graphql/query/serial_execution/field_resolution.rb,
lib/graphql/query/serial_execution/value_resolution.rb,
lib/graphql/query/serial_execution/execution_context.rb,
lib/graphql/static_validation/rules/fields_will_merge.rb,
lib/graphql/static_validation/rules/fragments_are_used.rb,
lib/graphql/query/serial_execution/operation_resolution.rb,
lib/graphql/query/serial_execution/selection_resolution.rb,
lib/graphql/static_validation/rules/fragments_are_named.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/static_validation/rules/arguments_are_defined.rb,
lib/graphql/static_validation/rules/directives_are_defined.rb,
lib/graphql/static_validation/rules/subscription_root_exists.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/variable_usages_are_allowed.rb,
lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb,
lib/graphql/static_validation/rules/required_arguments_are_present.rb,
lib/graphql/static_validation/rules/variables_are_used_and_defined.rb,
lib/graphql/static_validation/rules/argument_literals_are_compatible.rb,
lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb,
lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb,
lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb,
lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb

Defined Under Namespace

Modules: Analysis, Define, Execution, InternalRepresentation, Introspection, Language, Relay, StaticValidation, TypeKinds Classes: AnalysisError, Argument, BaseType, Directive, EnumType, Error, ExecutionError, Field, InputObjectType, InterfaceType, InvalidNullError, ListType, NonNullType, ObjectType, ParseError, Query, ScalarType, Schema, UnionType

Constant Summary collapse

ID_TYPE =
GraphQL::ScalarType.define do
  name "ID"
  description "Represents a unique identifier that is Base64 obfuscated. It is often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"VXNlci0xMA==\"`) or integer (such as `4`) input value will be accepted as an ID."

  coerce_result -> (value) { value.to_s }
  coerce_input -> (value) {
    case value
    when String, Fixnum, Bignum
      value.to_s
    else
      nil
    end
  }
end
VERSION =
"0.18.12"
INT_TYPE =
GraphQL::ScalarType.define do
  name "Int"
  description "Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1."

  coerce_input -> (value) { value.is_a?(Numeric) ? value.to_i : nil }
  coerce_result -> (value) { value.to_i }
end
FLOAT_TYPE =
GraphQL::ScalarType.define do
  name "Float"
  description "Represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point)."

  coerce_input -> (value) { value.is_a?(Numeric) ? value.to_f : nil }
  coerce_result -> (value) { value.to_f }
end
STRING_TYPE =
GraphQL::ScalarType.define do
  name "String"
  description "Represents textual data as UTF-8 character sequences. This type is most often used by GraphQL to represent free-form human-readable text."

  coerce_result -> (value) { value.to_s }
  coerce_input -> (value) { value.is_a?(String) ? value : nil }
end
BOOLEAN_TYPE =
GraphQL::ScalarType.define do
  name "Boolean"
  description "Represents `true` or `false` values."

  coerce_input -> (value) { (value == true || value == false) ? value : nil }
  coerce_result -> (value) { !!value }
end

Class Method Summary collapse

Class Method Details

.parse(query_string) ⇒ GraphQL::Language::Nodes::Document

Turn a query string into an AST

Parameters:

  • query_string (String)

    a GraphQL query string

Returns:



23
24
25
# File 'lib/graphql.rb', line 23

def self.parse(query_string)
  parse_with_racc(query_string)
end

.parse_with_racc(string) ⇒ Object



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

def self.parse_with_racc(string)
  GraphQL::Language::Parser.parse(string)
end