Skip to content

Commit

Permalink
Merge pull request #65 from gjtorikian/support-quote-style-comment
Browse files Browse the repository at this point in the history
Support quote style comment
  • Loading branch information
gjtorikian authored Jan 4, 2019
2 parents aa01e8f + 2376655 commit 8ac6d63
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 29 deletions.
24 changes: 9 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
sudo: false
language: ruby
cache: bundler

rvm:
- 2.3.6
- 2.4.3
- 2.5.0
- 2.6.0

git:
depth: 10

env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true

sudo: false
cache: bundler

addons:
apt:
sources:
- kalakris-cmake
packages:
- cmake
before_install:
- gem update --system
- gem install bundler

matrix:
include:
- script: bundle exec rake rubocop
rvm: 2.5.0
rvm: 2.6.0
- script: bundle exec rake html_proofer
rvm: 2.5.0
rvm: 2.6.0
3 changes: 1 addition & 2 deletions graphql-docs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'graphql', '~> 1.6'
spec.add_dependency 'graphql', '~> 1.8'

# rendering
spec.add_dependency 'commonmarker', '~> 0.16'
Expand All @@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
spec.add_dependency 'sass', '~> 3.4'

spec.add_development_dependency 'awesome_print'
spec.add_development_dependency 'bundler', '~> 1.14'
spec.add_development_dependency 'html-proofer', '~> 3.4'
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'minitest-focus', '~> 1.1'
Expand Down
54 changes: 42 additions & 12 deletions test/graphql-docs/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class ParserTest < Minitest::Test
def setup
@ghapi = File.read(File.join(fixtures_dir, 'gh-schema.graphql'))
@swapi = File.read(File.join(fixtures_dir, 'sw-schema.graphql'))
@parser = GraphQLDocs::Parser.new(@ghapi, {})
@results = @parser.parse
@gh_parser = GraphQLDocs::Parser.new(@ghapi, {})
@gh_results = @gh_parser.parse
end

def test_it_accepts_schema_class
Expand Down Expand Up @@ -34,28 +34,28 @@ def test_it_accepts_schema_class
end

def test_types_are_sorted
names = @results[:object_types].map { |t| t[:name] }
names = @gh_results[:object_types].map { |t| t[:name] }
assert_equal names.sort, names
end

def test_connections_are_plucked
issue = @results[:object_types].find { |t| t[:name] == 'Issue' }
issue = @gh_results[:object_types].find { |t| t[:name] == 'Issue' }
refute issue[:connections].empty?
end

def test_knows_implementers_for_interfaces
comment = @results[:interface_types].find { |t| t[:name] == 'Comment' }
comment = @gh_results[:interface_types].find { |t| t[:name] == 'Comment' }
refute comment[:implemented_by].empty?
end

def test_groups_items_by_type
assert @results[:input_object_types]
assert @results[:object_types]
assert @results[:scalar_types]
assert @results[:interface_types]
assert @results[:enum_types]
assert @results[:union_types]
assert @results[:mutation_types]
assert @gh_results[:input_object_types]
assert @gh_results[:object_types]
assert @gh_results[:scalar_types]
assert @gh_results[:interface_types]
assert @gh_results[:enum_types]
assert @gh_results[:union_types]
assert @gh_results[:mutation_types]
end

def test_mutationless_schemas_do_not_explode
Expand Down Expand Up @@ -84,4 +84,34 @@ def test_scalar_inputs_for_mutations_are_supported

assert results[:mutation_types]
end

def test_schemas_with_quote_style_comments_works
schema = <<-SCHEMA
type Query {
profile: User
}
"""
A user
"""
type User {
"""
The id of the user
"""
id: String!
"""
The email of user
"""
email: String
}
SCHEMA

parser = GraphQLDocs::Parser.new(schema, {})

results = parser.parse
assert results[:object_types]
user = results[:object_types].first
assert_equal 'The id of the user', user[:fields].first[:description]
end
end

0 comments on commit 8ac6d63

Please sign in to comment.