graphql-autotest 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +12 -1
- data/lib/graphql/autotest/field.rb +14 -2
- data/lib/graphql/autotest/runner.rb +0 -5
- data/lib/graphql/autotest/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76149c7ab8519445709b2027520c1d0032e0ac1785a6e61197cfd20fd0d95e7a
|
4
|
+
data.tar.gz: fe99a42781b73c409b52197c7d889689c957a7b46fb14ff8a3eb4088f7321276
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b32ee7c20c44219a25192855275479b1b144242acc40d876ac52924e2949bd34957676fc437c765fa858b82bd92b1bc6dd4c335aac2f7236b431722b4c85c86f
|
7
|
+
data.tar.gz: 923bcca30afa2e9e4d6f4c1d266a731ef7f458dbd2e7ca33a585e855801da429e447c070d3d6ae7e749a765059217a177c97a1bd4ff4790293934cbbf6f6eeb6
|
data/Rakefile
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require 'rake/testtask'
|
3
|
-
task :default => :test
|
3
|
+
task :default => [:test, :smoke]
|
4
4
|
|
5
5
|
Rake::TestTask.new do |test|
|
6
6
|
test.libs << 'test'
|
7
7
|
test.test_files = Dir['test/**/*_test.rb']
|
8
8
|
test.verbose = true
|
9
9
|
end
|
10
|
+
|
11
|
+
task :smoke do
|
12
|
+
require 'graphql/autotest'
|
13
|
+
definition = `curl https://raw.githubusercontent.com/kibela/kibela-api-v1-document/master/schema.graphql`
|
14
|
+
fields = GraphQL::Autotest::QueryGenerator.from_file(content: definition, max_depth: 6)
|
15
|
+
fields.each do |f|
|
16
|
+
GraphQL.parse(f.to_query)
|
17
|
+
end
|
18
|
+
|
19
|
+
puts "#{fields.size} fields are successfully generated🎉"
|
20
|
+
end
|
@@ -3,7 +3,19 @@ module GraphQL
|
|
3
3
|
class Field < Struct.new(:name, :children, :arguments, keyword_init: true)
|
4
4
|
TYPE_NAME = Field.new(name: '__typename', children: nil)
|
5
5
|
|
6
|
-
def to_query
|
6
|
+
def to_query(root: true)
|
7
|
+
q = _to_query
|
8
|
+
if root
|
9
|
+
q = <<~GRAPHQL
|
10
|
+
{
|
11
|
+
#{indent(q, 2)}
|
12
|
+
}
|
13
|
+
GRAPHQL
|
14
|
+
end
|
15
|
+
q
|
16
|
+
end
|
17
|
+
|
18
|
+
private def _to_query
|
7
19
|
return name unless children
|
8
20
|
|
9
21
|
<<~GRAPHQL
|
@@ -15,7 +27,7 @@ module GraphQL
|
|
15
27
|
|
16
28
|
private def children_to_query
|
17
29
|
sorted_children.map do |child|
|
18
|
-
child.to_query
|
30
|
+
child.to_query(root: false)
|
19
31
|
end.join("\n")
|
20
32
|
end
|
21
33
|
|