Skip to content

Commit 14bcb5e

Browse files
committed
Merge branch 'master' into field-extension-overhead-fix
2 parents e57fd83 + 93ecc6d commit 14bcb5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+5793
-967
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
- run: echo BUNDLE_GEMFILE='gemfiles/rails_6.1_postgresql.gemfile' > $GITHUB_ENV
100100
- run: echo DATABASE='POSTGRESQL' > $GITHUB_ENV
101101
- run: echo PGPASSWORD='postgres' > $GITHUB_ENV
102-
- run: echo GRAPHQL_CLEXER=1 > $GITHUB_ENV
102+
- run: echo GRAPHQL_CPARSER=1 > $GITHUB_ENV
103103
- uses: actions/checkout@v3
104104
- uses: ruby/setup-ruby@v1
105105
with:

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010

1111
### Bug fixes
1212

13+
# 2.0.20 (30 March 2023)
14+
15+
### Bug fixes
16+
17+
- `.resolve_type`: fix returning `[Type, false]` from resolve_type #4412
18+
- Parsing: improve usage of `GraphQL.default_parser` #4411
19+
- AppsignalTrace: implement missing methods #4390
20+
- Runtime: Fix `current_depth` method in some lazy lists #4386
21+
- Performance: improve `Object` object shape #4365
22+
- Tracing: return execution errors raised from field resolution to `execute_field` hooks #4398
1323

1424
# 2.0.19 (14 March 2023)
1525

@@ -42,6 +52,19 @@
4252
- Performance: add `GraphQL::Tracing::Trace` as a lower-overhead tracing API #4344
4353
- Connections: fix `hasNextPage` for already-loaded ActiveRecord Relations #4349
4454

55+
56+
# 2.0.17.2 (29 March 2023)
57+
58+
### Bug fixes
59+
60+
- Unions and Interfaces: support returning `[type_module, false]` from `resolve_type` #4413
61+
62+
# 2.0.17.1 (27 March 2023)
63+
64+
### Bug fixes
65+
66+
- Tracing: restore behavior returning execution errors raised during field resolution #4402
67+
4568
# 2.0.17 (14 February 2023)
4669

4770
### Breaking changes

Rakefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
2-
require "bundler/setup"
2+
require "bundler/gem_helper"
33
Bundler::GemHelper.install_tasks
44

55
require "rake/testtask"
@@ -201,5 +201,15 @@ Rake::ExtensionTask.new("graphql_c_parser_ext") do |t|
201201
t.lib_dir = "graphql-c_parser/lib/graphql"
202202
end
203203

204+
task :build_yacc_parser do
205+
assert_dependency_version("Bison", "3.8", "yacc --version")
206+
`yacc graphql-c_parser/ext/graphql_c_parser_ext/parser.y -o graphql-c_parser/ext/graphql_c_parser_ext/parser.c -Wyacc`
207+
end
208+
209+
task :move_binary do
210+
# For some reason my local env doesn't respect the `lib_dir` configured above
211+
`mv graphql-c_parser/lib/*.bundle graphql-c_parser/lib/graphql`
212+
end
213+
204214
desc "Build the C Extension"
205-
task build_ext: [:build_c_lexer, "compile:graphql_c_parser_ext"]
215+
task build_ext: [:build_c_lexer, :build_yacc_parser, "compile:graphql_c_parser_ext", :move_binary]

benchmark/run.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ def self.run(task)
3737
x.report("validate - big query") { BIG_SCHEMA.validate(BIG_QUERY) }
3838
x.report("validate - fields will merge") { FIELDS_WILL_MERGE_SCHEMA.validate(FIELDS_WILL_MERGE_QUERY) }
3939
when "scan"
40-
x.report("scan c - introspection") { GraphQL::Language::CLexer.tokenize(QUERY_STRING) }
41-
x.report("scan - introspection") { GraphQL.scan(QUERY_STRING) }
42-
x.report("scan c - fragments") { GraphQL::Language::CLexer.tokenize(ABSTRACT_FRAGMENTS_2_QUERY_STRING) }
43-
x.report("scan - fragments") { GraphQL.scan(ABSTRACT_FRAGMENTS_2_QUERY_STRING) }
44-
x.report("scan c - big query") { GraphQL::Language::CLexer.tokenize(BIG_QUERY_STRING) }
45-
x.report("scan - big query") { GraphQL.scan(BIG_QUERY_STRING) }
40+
require "graphql/c_parser"
41+
x.report("scan c - introspection") { GraphQL.scan_with_c(QUERY_STRING) }
42+
x.report("scan - introspection") { GraphQL.scan_with_ruby(QUERY_STRING) }
43+
x.report("scan c - fragments") { GraphQL.scan_with_c(ABSTRACT_FRAGMENTS_2_QUERY_STRING) }
44+
x.report("scan - fragments") { GraphQL.scan_with_ruby(ABSTRACT_FRAGMENTS_2_QUERY_STRING) }
45+
x.report("scan c - big query") { GraphQL.scan_with_c(BIG_QUERY_STRING) }
46+
x.report("scan - big query") { GraphQL.scan_with_ruby(BIG_QUERY_STRING) }
4647
when "parse"
48+
# Uncomment this to use the C parser:
49+
# require "graphql/c_parser"
4750
x.report("parse - introspection") { GraphQL.parse(QUERY_STRING) }
4851
x.report("parse - fragments") { GraphQL.parse(ABSTRACT_FRAGMENTS_2_QUERY_STRING) }
4952
x.report("parse - big query") { GraphQL.parse(BIG_QUERY_STRING) }
@@ -54,11 +57,8 @@ def self.run(task)
5457
end
5558

5659
def self.profile_parse
57-
GraphQL.module_eval do
58-
def self.scan(str)
59-
GraphQL::Clexer.tokenize(str)
60-
end
61-
end
60+
# To profile the C parser instead:
61+
# require "graphql/c_parser"
6262

6363
report = MemoryProfiler.report do
6464
GraphQL.parse(BIG_QUERY_STRING)
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
#include "graphql_c_parser_ext.h"
22

3-
VALUE GraphQL_Language_CLexer_tokenize(VALUE self, VALUE query_string) {
4-
VALUE tokens = tokenize(query_string);
5-
return tokens;
3+
VALUE GraphQL_CParser_Lexer_tokenize(VALUE self, VALUE query_string) {
4+
return tokenize(query_string);
5+
}
6+
7+
VALUE GraphQL_CParser_Parser_c_parse(VALUE self) {
8+
yyparse(self, rb_ivar_get(self, rb_intern("@filename")));
9+
return Qnil;
610
}
711

812
void Init_graphql_c_parser_ext() {
913
VALUE GraphQL = rb_define_module("GraphQL");
10-
VALUE Language = rb_define_module_under(GraphQL, "Language");
11-
VALUE CLexer = rb_define_module_under(Language, "CLexer");
12-
rb_define_singleton_method(CLexer, "tokenize", GraphQL_Language_CLexer_tokenize, 1);
14+
VALUE CParser = rb_define_module_under(GraphQL, "CParser");
15+
VALUE Lexer = rb_define_module_under(CParser, "Lexer");
16+
rb_define_singleton_method(Lexer, "tokenize", GraphQL_CParser_Lexer_tokenize, 1);
1317
setup_static_token_variables();
18+
19+
VALUE Parser = rb_define_class_under(CParser, "Parser", rb_cObject);
20+
rb_define_method(Parser, "c_parse", GraphQL_CParser_Parser_c_parse, 0);
21+
initialize_node_class_variables();
1422
}

graphql-c_parser/ext/graphql_c_parser_ext/graphql_c_parser_ext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
#define Graphql_ext_h
33
#include <ruby.h>
44
#include "lexer.h"
5+
#include "parser.h"
56
void Init_graphql_c_parser_ext();
67
#endif

0 commit comments

Comments
 (0)