Module: GraphQL::Parser

Defined in:
lib/graphql/parser.rb,
ext/graphql_parser/graphql_ruby.c

Class Method Summary collapse

Class Method Details

.parse(text) ⇒ Object



695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
# File 'ext/graphql_parser/graphql_ruby.c', line 695

static VALUE parse(VALUE self, VALUE text) {
  char *input;
  struct GraphQLAstNode *n;
  const char *error;

  input = StringValueCStr(text);

  n = graphql_parse_string(input, &error);

  if (n == NULL) {
      VALUE exc = rb_exc_new_cstr(parse_error, error);
      graphql_error_free(error);
      rb_exc_raise(exc);
      return Qnil;
  }

  return TypedData_Wrap_Struct(ast_class, &ast_type, n);
}