graphql-c_parser 1.0.7 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module CParser
5
- VERSION = "1.0.7"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
@@ -7,8 +7,7 @@ require "graphql/graphql_c_parser_ext"
7
7
  module GraphQL
8
8
  module CParser
9
9
  def self.parse(query_str, filename: nil, trace: GraphQL::Tracing::NullTrace)
10
- parser = Parser.new(query_str, filename, trace)
11
- parser.result
10
+ Parser.parse(query_str, filename: filename, trace: trace)
12
11
  end
13
12
 
14
13
  def self.parse_file(filename)
@@ -16,6 +15,10 @@ module GraphQL
16
15
  parse(contents, filename: filename)
17
16
  end
18
17
 
18
+ def self.tokenize_with_c(str)
19
+ tokenize_with_c_internal(str, false)
20
+ end
21
+
19
22
  def self.prepare_parse_error(message, parser)
20
23
  if message.start_with?("memory exhausted")
21
24
  return GraphQL::ParseError.new("This query is too large to execute.", nil, nil, parser.query_string, filename: parser.filename)
@@ -54,7 +57,7 @@ module GraphQL
54
57
  end
55
58
 
56
59
  module Lexer
57
- def self.tokenize(graphql_string)
60
+ def self.tokenize(graphql_string, intern_identifiers: false)
58
61
  if !(graphql_string.encoding == Encoding::UTF_8 || graphql_string.ascii_only?)
59
62
  graphql_string = graphql_string.dup.force_encoding(Encoding::UTF_8)
60
63
  end
@@ -70,11 +73,20 @@ module GraphQL
70
73
  ]
71
74
  ]
72
75
  end
73
- tokenize_with_c(graphql_string)
76
+ tokenize_with_c_internal(graphql_string, intern_identifiers)
74
77
  end
75
78
  end
76
79
 
77
80
  class Parser
81
+ def self.parse(query_str, filename: nil, trace: GraphQL::Tracing::NullTrace)
82
+ self.new(query_str, filename, trace).result
83
+ end
84
+
85
+ def self.parse_file(filename)
86
+ contents = File.read(filename)
87
+ parse(contents, filename: filename)
88
+ end
89
+
78
90
  def initialize(query_string, filename, trace)
79
91
  if query_string.nil?
80
92
  raise GraphQL::ParseError.new("No query string was present", nil, nil, query_string)
@@ -85,12 +97,13 @@ module GraphQL
85
97
  @next_token_index = 0
86
98
  @result = nil
87
99
  @trace = trace
100
+ @intern_identifiers = false
88
101
  end
89
102
 
90
103
  def result
91
104
  if @result.nil?
92
105
  @tokens = @trace.lex(query_string: @query_string) do
93
- GraphQL::CParser::Lexer.tokenize(@query_string)
106
+ GraphQL::CParser::Lexer.tokenize(@query_string, intern_identifiers: @intern_identifiers)
94
107
  end
95
108
  @trace.parse(query_string: @query_string) do
96
109
  c_parse
@@ -102,6 +115,13 @@ module GraphQL
102
115
 
103
116
  attr_reader :tokens, :next_token_index, :query_string, :filename
104
117
  end
118
+
119
+ class SchemaParser < Parser
120
+ def initialize(*args)
121
+ super
122
+ @intern_identifiers = true
123
+ end
124
+ end
105
125
  end
106
126
 
107
127
  def self.scan_with_c(graphql_string)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-c_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-20 00:00:00.000000000 Z
11
+ date: 2024-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.2.10
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 2.2.10
27
27
  description:
28
28
  email:
29
29
  - rdmosolgo@gmail.com
@@ -50,7 +50,7 @@ metadata:
50
50
  changelog_uri: https://github.com/rmosolgo/graphql-ruby/blob/master/graphql-c_parser/CHANGELOG.md
51
51
  source_code_uri: https://github.com/rmosolgo/graphql-ruby
52
52
  bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
53
- mailing_list_uri: https://tinyletter.com/graphql-ruby
53
+ mailing_list_uri: https://buttondown.email/graphql-ruby
54
54
  post_install_message:
55
55
  rdoc_options: []
56
56
  require_paths:
@@ -59,14 +59,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 2.4.0
62
+ version: 3.0.0
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubygems_version: 3.4.10
69
+ rubygems_version: 3.5.3
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: A parser for GraphQL, implemented as a C extension