Module: GraphQL
- Defined in:
- lib/graphql.rb,
lib/graphql/version.rb,
lib/graphql/language.rb,
lib/graphql/base_type.rb,
lib/graphql/scalar_type.rb,
lib/graphql/introspection.rb,
lib/graphql/query/context.rb,
lib/graphql/language/nodes.rb,
lib/graphql/query/executor.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/schema/type_map.rb,
lib/graphql/language/visitor.rb,
lib/graphql/invalid_null_error.rb,
lib/graphql/language/transform.rb,
lib/graphql/query/literal_input.rb,
lib/graphql/query/serial_execution.rb,
lib/graphql/schema/type_expression.rb,
lib/graphql/schema/middleware_chain.rb,
lib/graphql/schema/rescue_middleware.rb,
lib/graphql/definition_helpers/type_definer.rb,
lib/graphql/definition_helpers/defined_by_config.rb,
lib/graphql/definition_helpers/string_named_hash.rb,
lib/graphql/static_validation/validation_context.rb,
lib/graphql/definition_helpers/non_null_with_bang.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/query/serial_execution/operation_resolution.rb,
lib/graphql/query/serial_execution/selection_resolution.rb,
lib/graphql/static_validation/rules/document_does_not_exceed_max_depth.rb
Defined Under Namespace
Modules: DefinitionHelpers, Introspection, Language, StaticValidation, TypeKinds Classes: Argument, BaseType, Directive, EnumType, ExecutionError, Field, InputObjectType, InterfaceType, InvalidNullError, ListType, NonNullType, ObjectType, ParseError, Query, Repl, ScalarType, Schema, UnionType
Constant Summary collapse
- ID_TYPE =
GraphQL::ScalarType.define do name "ID" coerce -> (value) { value.to_s } end
- VERSION =
"0.11.1"- INT_TYPE =
GraphQL::ScalarType.define do name "Int" coerce -> (value) { value.is_a?(Numeric) ? value.to_i : nil } end
- TRANSFORM =
GraphQL::Language::Transform.new
- PARSER =
GraphQL::Language::Parser.new
- FLOAT_TYPE =
GraphQL::ScalarType.define do name "Float" coerce -> (value) do value.is_a?(Numeric) ? value.to_f : nil end end
- STRING_TYPE =
GraphQL::ScalarType.define do name "String" coerce -> (value) { value.to_s } end
- BOOLEAN_TYPE =
GraphQL::ScalarType.define do name "Boolean" coerce -> (value) { !!value } end
Class Method Summary collapse
-
.parse(query_string) ⇒ GraphQL::Language::Nodes::Document
Turn a query string into an AST.
- .parse_with_parslet(string) ⇒ Object
Class Method Details
.parse(query_string) ⇒ GraphQL::Language::Nodes::Document
Turn a query string into an AST
21 22 23 |
# File 'lib/graphql.rb', line 21 def self.parse(query_string) parse_with_parslet(query_string) end |
.parse_with_parslet(string) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/graphql.rb', line 25 def self.parse_with_parslet(string) tree = GraphQL::PARSER.parse(string) document = GraphQL::TRANSFORM.apply(tree) if !document.is_a?(GraphQL::Language::Nodes::Document) raise("Parse failed! Sorry, somehow we failed to turn this string into a document. Please report this bug!") end document rescue Parslet::ParseFailed => error line, col = error.cause.source.line_and_column(error.cause.pos) raise GraphQL::ParseError.new(error., line, col, string) end |