Skip to content

Commit

Permalink
Merge pull request #19 from Shopify/centralize_ruby_version
Browse files Browse the repository at this point in the history
Centralize Ruby Version to `.ruby-version`
  • Loading branch information
george-ma authored May 21, 2024
2 parents cc8d665 + 16fa764 commit f1af618
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 109 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
strategy:
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2", "3.3"]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
bundler: latest
- name: Ruby Tests
run: bundle exec rake test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.1
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

25 changes: 25 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
PATH
remote: .
specs:
graphql_schema (0.1.8)

GEM
remote: https://rubygems.org/
specs:
base64 (0.2.0)
graphql (2.3.4)
base64
minitest (5.22.3)
rake (13.2.1)

PLATFORMS
ruby

DEPENDENCIES
graphql (>= 2.0)
graphql_schema!
minitest (~> 5.0)
rake (~> 13.0)

BUNDLED WITH
2.4.22
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Rake::TestTask.new(:test) do |t|
t.test_files = FileList['test/**/*_test.rb']
end

task :default => :test
task default: :test
12 changes: 5 additions & 7 deletions graphql_schema.gemspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'graphql_schema/version'
require_relative 'lib/graphql_schema/version'

Gem::Specification.new do |spec|
spec.name = "graphql_schema"
spec.version = GraphQLSchema::VERSION
spec.authors = ["Dylan Thacker-Smith"]
spec.email = ["[email protected]"]

spec.required_ruby_version = ">= 2.7"

spec.summary = "Classes for convenient use of GraphQL introspection result"
spec.homepage = "https://github.com/Shopify/graphql_schema"
spec.license = "MIT"
Expand All @@ -21,8 +20,7 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]
spec.metadata['allowed_push_host'] = "https://rubygems.org"

spec.add_development_dependency "graphql", "~> 1.2"
spec.add_development_dependency "byebug", '~> 9.0' if RUBY_ENGINE == 'ruby'
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "graphql", ">= 2.0"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "minitest", "~> 5.0"
end
2 changes: 1 addition & 1 deletion lib/graphql_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class Directive
include NamedHash
include WithArgs

BUILTIN = %w(skip include deprecated).to_set
BUILTIN = %w(skip include deprecated oneOf specifiedBy).to_set

def initialize(directive)
@hash = directive
Expand Down
40 changes: 22 additions & 18 deletions test/graphql_schema_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

class GraphQLSchemaTest < Minitest::Test
def setup
@schema = GraphQLSchema.new(Support::Schema.introspection_result)
@schema = GraphQLSchema.new(Support::Schema::ExampleSchema.as_json)
end

def test_that_it_has_a_version_number
refute_nil ::GraphQLSchema::VERSION
end

def test_application_types
expect = %w(QueryRoot Mutation Entry IntegerEntry StringEntry Time KeyType SetIntegerInput).sort
expect = %w(QueryRoot MutationRoot Entry IntegerEntry StringEntry Time Key SetIntegerInput).sort
assert_equal expect, @schema.types.reject(&:builtin?).map(&:name)
end

def test_roots
assert_equal 'QueryRoot', @schema.query_root_name
assert_equal 'Mutation', @schema.mutation_root_name
assert_equal ['Mutation', 'QueryRoot'], @schema.types.select { |type| @schema.root_name?(type.name) }.map(&:name)
assert_equal 'MutationRoot', @schema.mutation_root_name
assert_equal ['MutationRoot', 'QueryRoot'], @schema.types.select { |type| @schema.root_name?(type.name) }.map(&:name)
end

def test_no_mutation_root
schema = GraphQLSchema.new(Support::Schema.introspection_result(Support::Schema::NoMutationSchema))
schema = GraphQLSchema.new(Support::Schema::NoMutationSchema.as_json)
assert_nil schema.mutation_root_name
end

Expand All @@ -44,7 +44,7 @@ def test_upcase_name
end

def test_nil_fields
assert_nil type('KeyType').fields
assert_nil type('Key').fields
end

def test_deprecated_fields
Expand All @@ -54,7 +54,7 @@ def test_deprecated_fields
end

def test_deprecated_enum_values
deprecated = type('KeyType').enum_values(include_deprecated: true) - type('KeyType').enum_values
deprecated = type('Key').enum_values(include_deprecated: true) - type('Key').enum_values
assert_equal %w(NOT_FOUND), deprecated.map(&:name)
assert_equal "GraphQL null now used instead", deprecated.first.deprecation_reason
end
Expand Down Expand Up @@ -120,8 +120,8 @@ def test_optional_args
end

def test_default_args
assert_equal "\"I am default\"", arg('Mutation', 'set_string_with_default', 'value').default_value
assert_nil arg('Mutation', 'set_string_with_default', 'key').default_value
assert_equal "\"I am default\"", arg('MutationRoot', 'setStringWithDefault', 'value').default_value
assert_nil arg('MutationRoot', 'setStringWithDefault', 'key').default_value
end

def test_possible_types
Expand All @@ -144,9 +144,9 @@ def test_enum?
end

def test_fields_by_name
assert_equal get_string_field, type('QueryRoot').fields_by_name['get_string']
assert_equal get_string_field, type('QueryRoot').fields_by_name['getString']
assert_equal get_field, type('QueryRoot').fields_by_name['get']
assert_nil type('QueryRoot').fields_by_name['does_not_exist']
assert_nil type('QueryRoot').fields_by_name['doesNotExist']
end

def test_type_by_name
Expand All @@ -157,9 +157,9 @@ def test_type_by_name
def test_description
assert_equal 'Time since epoch in seconds', type('Time').description
assert_nil type('StringEntry').description
assert_nil type('KeyType').enum_values.first.description
assert_nil type('Key').enum_values.first.description
assert_nil input_field('SetIntegerInput', 'negate').description
assert_equal 'Get an entry of any type with the given key', field('QueryRoot', 'get_entry').description
assert_equal 'Get an entry of any type with the given key', field('QueryRoot', 'getEntry').description
end

def test_directives
Expand All @@ -173,7 +173,9 @@ def test_directives
assert directive("skip").builtin?
assert directive("include").builtin?
assert directive("deprecated").builtin?
assert_equal 4, @schema.directives.length
assert directive("oneOf").builtin?
assert directive("specifiedBy").builtin?
assert_equal 6, @schema.directives.length
end

def test_to_h
Expand All @@ -192,15 +194,17 @@ def test_to_h
'name' => 'negate',
'description' => nil,
'type' => {'kind' => 'SCALAR', 'name' => 'Boolean', 'ofType' => nil },
'defaultValue' => 'false'
'defaultValue' => 'false',
"isDeprecated" => false,
"deprecationReason" => nil
}, input_field('SetIntegerInput', 'negate').to_h)

assert_equal({
'name' => 'INTEGER',
'description' => nil,
'isDeprecated' => false,
'deprecationReason' => nil
}, type('KeyType').enum_values.first.to_h)
}, type('Key').enum_values.first.to_h)
end

private
Expand Down Expand Up @@ -240,14 +244,14 @@ def get_field
end

def get_string_field
field('QueryRoot', 'get_string')
field('QueryRoot', 'getString')
end

def keys_field
field('QueryRoot', 'keys')
end

def not_found_value
enum_value('KeyType', 'NOT_FOUND')
enum_value('Key', 'NOT_FOUND')
end
end
Loading

0 comments on commit f1af618

Please sign in to comment.