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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdebda4eb82e44a457ec65e9384f1a338311ef74516511f73ec20b4d2cd2e1cc
4
- data.tar.gz: 9796606bbf638c223082b7dcb10179cca31f30c19d0e3ffd028ebda1c1250903
3
+ metadata.gz: 76149c7ab8519445709b2027520c1d0032e0ac1785a6e61197cfd20fd0d95e7a
4
+ data.tar.gz: fe99a42781b73c409b52197c7d889689c957a7b46fb14ff8a3eb4088f7321276
5
5
  SHA512:
6
- metadata.gz: f0de4ae0c8ad47fd05fb75243b95e64e8f8481ff506154d28003e4d2e701428f7151364f768cb6198f2f4a91755b3f11cbcc04ce71937eed2baffe544c2516b7
7
- data.tar.gz: fa0ecb913081ac8e642eb83aeb4b6b5ec14baf8c0af8052a74e427407d1970d4056b4fea3f9a50caca9c67b853d40d70e3a7c030a7ec66599be3715b2d8d9216
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
 
@@ -28,11 +28,6 @@ module GraphQL
28
28
  )
29
29
  fields.each do |f|
30
30
  q = f.to_query
31
- q = <<~GRAPHQL
32
- {
33
- #{q.indent(2)}
34
- }
35
- GRAPHQL
36
31
 
37
32
  result = if dry_run
38
33
  {}
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Autotest
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-autotest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masataka Pocke Kuwabara