graphql-libgraphqlparser 1.1.0 → 1.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/graphql/libgraphqlparser.rb +26 -24
- data/lib/graphql/libgraphqlparser/version.rb +1 -1
- data/test/graphql/libgraphqlparser_test.rb +18 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c6c3d2f3e3f782d3c576ed544599fb743e8cf12
|
4
|
+
data.tar.gz: dc13fc9f17377d35a9b9fdec26ab00064d4e47da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4bff9e47683edfad5bf7ea6005ccf4ce694c6bf53b36ef3ac821b398cf5714851967eb56b400d463329f70f6eda4bd81c8e94ba2572ccb8bf559377101700a3
|
7
|
+
data.tar.gz: bda7eb33bb87c80152fc9f195359de73ec106866948264bbe960d183e1771200c0e6be6fea157be5dde5b85d21a0627ab8cf397b665d38f20f027dd74b0d2ee3
|
data/CHANGELOG.md
CHANGED
@@ -6,40 +6,42 @@ require_relative '../graphql_libgraphqlparser_ext'
|
|
6
6
|
|
7
7
|
module GraphQL
|
8
8
|
module Libgraphqlparser
|
9
|
-
def self.parse(string)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
9
|
+
def self.parse(string, tracer: GraphQL::Tracing::NullTracer)
|
10
|
+
tracer.trace("parse", { query_string: string }) do
|
11
|
+
begin
|
12
|
+
builder = builder_parse(string)
|
13
|
+
builder.document
|
14
|
+
rescue ArgumentError
|
15
|
+
if index = string.index("\x00")
|
16
|
+
string_before_null = string.slice(0, index)
|
17
|
+
line = string_before_null.count("\n") + 1
|
18
|
+
col = index - (string_before_null.rindex("\n") || 0)
|
19
|
+
raise GraphQL::ParseError.new("Invalid null byte in query", line, col, string)
|
20
|
+
end
|
21
|
+
raise
|
22
|
+
rescue ParseError => e
|
23
|
+
error_message = e.message.match(/(\d+)\.(\d+): (.*)/)
|
24
|
+
if error_message
|
25
|
+
line = error_message[1].to_i
|
26
|
+
col = error_message[2].to_i
|
27
|
+
raise GraphQL::ParseError.new(error_message[3], line, col, string)
|
28
|
+
else
|
29
|
+
raise GraphQL::ParseError.new(e.message, nil, nil, string)
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
34
36
|
class << self
|
35
|
-
def parse_with_libgraphqlparser(
|
36
|
-
Libgraphqlparser.parse(
|
37
|
+
def parse_with_libgraphqlparser(*args)
|
38
|
+
Libgraphqlparser.parse(*args)
|
37
39
|
end
|
38
40
|
|
39
41
|
alias :parse_without_libgraphqlparser :parse
|
40
42
|
|
41
|
-
def parse(
|
42
|
-
parse_with_libgraphqlparser(
|
43
|
+
def parse(*args)
|
44
|
+
parse_with_libgraphqlparser(*args)
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
@@ -159,7 +159,7 @@ describe GraphQL::Libgraphqlparser do
|
|
159
159
|
let(:query_string) { 'query { ... @skip(if: false) { field } }' }
|
160
160
|
let(:inline_fragment) { query.selections[0] }
|
161
161
|
it "gets directives and nil type" do
|
162
|
-
|
162
|
+
assert_nil inline_fragment.type
|
163
163
|
assert_equal 1, inline_fragment.directives.length
|
164
164
|
end
|
165
165
|
end
|
@@ -227,7 +227,7 @@ describe GraphQL::Libgraphqlparser do
|
|
227
227
|
it "parses unnamed queries" do
|
228
228
|
assert_equal 1, document.definitions.length
|
229
229
|
assert_equal "query", operation.operation_type
|
230
|
-
|
230
|
+
assert_nil operation.name
|
231
231
|
assert_equal 3, operation.selections.length
|
232
232
|
end
|
233
233
|
end
|
@@ -264,4 +264,20 @@ describe GraphQL::Libgraphqlparser do
|
|
264
264
|
assert_equal 28, err.col
|
265
265
|
end
|
266
266
|
end
|
267
|
+
|
268
|
+
describe "Compatibility" do
|
269
|
+
TestQuery = GraphQL::ObjectType.define do
|
270
|
+
name "Query"
|
271
|
+
field :int, !types.Int, resolve: ->(*a) { 1 }
|
272
|
+
end
|
273
|
+
|
274
|
+
TestSchema = GraphQL::Schema.define do
|
275
|
+
query(TestQuery)
|
276
|
+
end
|
277
|
+
|
278
|
+
it "works with a schema" do
|
279
|
+
res = TestSchema.execute("{ int }")
|
280
|
+
assert_equal 1, res["data"]["int"]
|
281
|
+
end
|
282
|
+
end
|
267
283
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-libgraphqlparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.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:
|
11
|
+
date: 2018-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
213
|
version: '0'
|
214
214
|
requirements: []
|
215
215
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.
|
216
|
+
rubygems_version: 2.6.13
|
217
217
|
signing_key:
|
218
218
|
specification_version: 4
|
219
219
|
summary: Use Libgraphqlparser to parse queries for the GraphQL gem
|