Skip to content

Commit 79ec655

Browse files
author
Carlos
authored
Setup CI (#32)
* Setup CI * Setup CI * Setup CI and prepare for release * Setup CI and implement string support for ENUM input * Setup CI * Setup CI * Setup CI * Setup CI * Setup CI * Setup CI * Setup CI * Setup CI * Setup CI * Setup CI * Setup CI * Setup CI
1 parent 7036aa3 commit 79ec655

File tree

14 files changed

+154
-68
lines changed

14 files changed

+154
-68
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: ci
2+
concurrency:
3+
group: "${{github.workflow}}-${{github.ref}}"
4+
cancel-in-progress: true
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- main
11+
- v*.*.x
12+
tags:
13+
- v*.*.*
14+
pull_request:
15+
types: [opened, synchronize]
16+
branches:
17+
- '*'
18+
19+
jobs:
20+
test:
21+
name: "Run tests (${{ matrix.ruby }})"
22+
runs-on: ubuntu-latest
23+
env:
24+
MYSQL_HOST: '127.0.0.1'
25+
services:
26+
mysql:
27+
image: mysql:8.0
28+
env:
29+
MYSQL_HOST: ${{ env.MYSQL_HOST }}
30+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
31+
MYSQL_ROOT_PASSWORD: ''
32+
ports:
33+
- "3306:3306"
34+
options: >-
35+
--health-cmd "mysqladmin ping"
36+
--health-interval 5s
37+
--health-timeout 2s
38+
--health-retries 3
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
ruby: [2.7, 3.0, 3.1, 3.2]
43+
steps:
44+
- uses: actions/checkout@v3
45+
- uses: ruby/setup-ruby@v1
46+
with:
47+
ruby-version: ${{ matrix.ruby }}
48+
bundler-cache: false
49+
- run: sudo apt-get install libsqlite3-dev -y
50+
name: Setup Sqlite
51+
- run: mysql -h 127.0.0.1 --port 3306 -u root -e 'CREATE DATABASE IF NOT EXISTS starwars;'
52+
name: Create MySQL Database
53+
- run: bundle install
54+
- run: bundle exec rake compile
55+
- run: bundle exec rake test
56+
env:
57+
GQL_MYSQL_HOST: ${{ env.MYSQL_HOST }}
58+
GQL_MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
59+
60+
mac_compile:
61+
name: "Compile for MacOS"
62+
runs-on: macos-13
63+
steps:
64+
- uses: actions/checkout@v3
65+
- uses: ruby/setup-ruby@v1
66+
with:
67+
ruby-version: '3.1'
68+
bundler-cache: false
69+
- run: gem install rake -v 13.0.6
70+
- run: gem install rake-compiler -v 1.1.0
71+
- run: gem install rake-compiler-dock -v 1.0.1
72+
- run: CI_COMPILE=true rake compile

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
### Unreleased
22

3+
### 1.0.0
4+
5+
* Allow ENUM inputs to receive string (needs to be enabled through config)
6+
* Setup project's CI
7+
38
### 1.0.0.rc2 - 2023-02-28
49

510
* Fixes for inputs
611
* Fixes for callbacks and field ownership
712
* Fixes for the inline type creator and sources
813
* Fixes to folder structure and constant management
914
* Provide a better URL for ISO 8601 specification
10-
* Make some constants privat
15+
* Make some constants private
1116

1217
### 1.0.0.rc1 - 2023-02-06
1318

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<img src="./docs/assets/images/github.png" alt="Rails GraphQL - GraphQL meets RoR with the most Ruby-like DSL" />
33
</a>
44

5-
![Gem Version](https://badge.fury.io/rb/rails-graphql.svg)
5+
[![Gem Version](https://badge.fury.io/rb/rails-graphql.svg)](https://rubygems.org/gems/rails-graphql)
6+
[![Tests](https://github.com/virtualshield/rails-graphql/actions/workflows/ci.yml/badge.svg)](https://github.com/virtualshield/rails-graphql/actions/workflows/ci.yml)
67
<!-- [![Code Climate](https://codeclimate.com/github/virtualshield/rails-graphql/badges/gpa.svg)](https://codeclimate.com/github/virtualshield/rails-graphql) -->
78
<!--([![Test Coverage](https://codeclimate.com/github/virtualshield/rails-graphql/badges/coverage.svg)](https://codeclimate.com/github/virtualshield/rails-graphql/coverage))-->
89
<!--([![Dependency Status](https://gemnasium.com/badges/github.com/virtualshield/rails-graphql.svg)](https://gemnasium.com/github.com/virtualshield/rails-graphql))-->
@@ -53,57 +54,24 @@ $ curl -d '{"query":"{ welcome }"}' \
5354

5455
# Features
5556

56-
[GraphQL Parser](https://rails-graphql.dev/guides/parser?utm_source=github)
57-
: Supporting the <a href="https://spec.graphql.org/October2021/" target="_blank" rel="external nofollow">October 2021</a> spec
58-
59-
[Schemas](https://rails-graphql.dev/guides/schemas?utm_source=github)
60-
: One or multiple under the same application or across multiple engines
61-
62-
[Queries](https://rails-graphql.dev/guides/queries?utm_source=github)
63-
: 3 different ways to defined your queries, besides sources
64-
65-
[Mutations](https://rails-graphql.dev/guides/mutations?utm_source=github)
66-
: 3 different ways to defined your mutations, besides sources
67-
68-
[Subscriptions](https://rails-graphql.dev/guides/subscriptions?utm_source=github)
69-
: 3 different ways to defined your subscriptions, besides sources
70-
71-
[Directives](https://rails-graphql.dev/guides/directives?utm_source=github)
72-
: 4 directives provided: `@deprecated`, `@skip`, `@include`, and `@specifiedBy`
73-
: Event-driven interface to facilitate new directives
74-
75-
[Scalars](https://rails-graphql.dev/guides/scalars?utm_source=github)
76-
: All the spec scalars plus: `any`, `bigint`, `binary`, `date`, `date_time`, `decimal`, `json`, and `time`
77-
78-
[Sources](https://rails-graphql.dev/guides/sources?utm_source=github)
79-
: A bridge between classes and GraphQL types and fields
80-
: Fully implemented for [ActiveRecord](https://rails-graphql.dev/guides/sources/active-record?utm_source=github) for `PostgreSQL`, `MySQL`, and `SQLite` databases.
81-
82-
[Generators](https://rails-graphql.dev/guides/generators?utm_source=github)
83-
: Rails generators for you to get start quickly
84-
85-
[Shortcuts](https://rails-graphql.dev/guides/architecture#shortcuts?utm_source=github)
86-
: Several shortcuts through `::GraphQL` module to access classes within the gem
87-
88-
[Type Map](https://rails-graphql.dev/guides/type-map?utm_source=github)
89-
: A centralized place where all the types are stored and can be resolved
90-
91-
[Global ID](https://rails-graphql.dev/guides/global-id?utm_source=github)
92-
: All objects defined supports `.to_global_id`, or simply `.to_gid`
93-
94-
[Subscriptions Provider](https://rails-graphql.dev/guides/subscriptions/providers?utm_source=github)
95-
: Current supporting only [ActionCable](https://rails-graphql.dev/guides/subscriptions/action-cable-provider?utm_source=github) provider and [Memory](https://rails-graphql.dev/guides/subscriptions/memory-store?utm_source=github) store
96-
97-
[Introspection](https://rails-graphql.dev/guides/introspection?utm_source=github)
98-
: All necessary types for introspection with proper descriptions
99-
: Plain text display of the schemas
100-
101-
[Testing](https://rails-graphql.dev/guides/testing?utm_source=github)
102-
: Support to validate GraphQL documents and stub values before requests
103-
104-
[Error Handling](https://rails-graphql.dev/guides/error-handling?utm_source=github)
105-
: Full support to `rescue_from` within schemas
106-
: A gracefully backtrace display
57+
| Link | Description |
58+
| --- | --- |
59+
| [GraphQL Parser](https://rails-graphql.dev/guides/parser?utm_source=github) | Supporting the <a href="https://spec.graphql.org/October2021/" target="_blank" rel="external nofollow">October 2021</a> spec |
60+
| [Schemas](https://rails-graphql.dev/guides/schemas?utm_source=github) | One or multiple under the same application or across multiple engines |
61+
| [Queries](https://rails-graphql.dev/guides/queries?utm_source=github) | 3 different ways to defined your queries, besides sources |
62+
| [Mutations](https://rails-graphql.dev/guides/mutations?utm_source=github) | 3 different ways to defined your mutations, besides sources |
63+
| [Subscriptions](https://rails-graphql.dev/guides/subscriptions?utm_source=github) | 3 different ways to defined your subscriptions, besides sources |
64+
| [Directives](https://rails-graphql.dev/guides/directives?utm_source=github) | 4 directives provided: `@deprecated`, `@skip`, `@include`, and `@specifiedBy`<br>Event-driven interface to facilitate new directives |
65+
| [Scalars](https://rails-graphql.dev/guides/scalars?utm_source=github) | All the spec scalars plus: `any`, `bigint`, `binary`, `date`, `date_time`, `decimal`, `json`, and `time` |
66+
| [Sources](https://rails-graphql.dev/guides/sources?utm_source=github) | A bridge between classes and GraphQL types and fields<br>Fully implemented for [ActiveRecord](https://rails-graphql.dev/guides/sources/active-record?utm_source=github) for `PostgreSQL`, `MySQL`, and `SQLite` databases |
67+
| [Generators](https://rails-graphql.dev/guides/generators?utm_source=github) | Rails generators for you to get start quickly |
68+
| [Shortcuts](https://rails-graphql.dev/guides/architecture#shortcuts?utm_source=github) | Several shortcuts through `::GraphQL` module to access classes within the gem |
69+
| [Type Map](https://rails-graphql.dev/guides/type-map?utm_source=github) | A centralized place where all the types are stored and can be resolved |
70+
| [Global ID](https://rails-graphql.dev/guides/global-id?utm_source=github) | All objects defined supports `.to_global_id`, or simply `.to_gid` |
71+
| [Subscriptions Provider](https://rails-graphql.dev/guides/subscriptions/providers?utm_source=github) | Current supporting only [ActionCable](https://rails-graphql.dev/guides/subscriptions/action-cable-provider?utm_source=github) provider and [Memory](https://rails-graphql.dev/guides/subscriptions/memory-store?utm_source=github) store |
72+
| [Introspection](https://rails-graphql.dev/guides/introspection?utm_source=github) | All necessary types for introspection with proper descriptions<br>Plain text display of the schemas |
73+
| [Testing](https://rails-graphql.dev/guides/testing?utm_source=github) | Support to validate GraphQL documents and stub values before requests |
74+
| [Error Handling](https://rails-graphql.dev/guides/error-handling?utm_source=github) | Full support to `rescue_from` within schemas<br>A gracefully backtrace display |
10775

10876
# How to contribute
10977

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Rake tasks for development purposes
33

44
begin
5-
require 'bundler/setup'
5+
require 'bundler/setup' unless ENV.key?('CI_COMPILE')
66
rescue LoadError
77
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
88
end

docs/_layouts/default.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424
</section>
2525
</section>
2626

27-
{% if page.url == "/" %}
28-
<section id="beta">
29-
We are now in the RC2 (v1.0.0.rc2)! It's not recommended to be used in production <b>YET!</b>
30-
</section>
31-
{% endif %}
32-
3327
<div id="search-results" class="search-results"></div>
3428
</header>
3529

docs/getting-started.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ title: Getting Started
66
description: The basics about this gem and what you will find
77
---
88

9-
{: .warning }
10-
> **Important**
11-
> We are now in the RC2 (v1.0.0.rc2)! It's not recommended to be used in production **YET!**
12-
139
## Installation
1410

1511
{% include installation.md %}

docs/handbook/settings.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ different suffix, change this value to it.
138138

139139
----------------------------------------------------------------
140140

141+
#### `allow_string_as_enum_input`
142+
143+
Set if the server should allow strings be used as input for ENUM inputs.
144+
It means that operations will support quotes for ENUM values embedded in
145+
the documents.
146+
147+
**Default:** `false`
148+
149+
----------------------------------------------------------------
150+
141151
#### `enable_introspection`
142152

143153
Introspection is enabled by default. It is recommended to only use

lib/rails/graphql/config.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ module GraphQL
6161
# different suffix, change this value to it.
6262
config.auto_suffix_input_objects = 'Input'
6363

64+
# Set if the server should allow strings be used as input for ENUM inputs.
65+
# It means that operations will support quotes for ENUM values embedded in
66+
# the documents (heredoc won't be accepted).
67+
config.allow_string_as_enum_input = false
68+
6469
# Introspection is enabled by default. It is recommended to only use
6570
# introspection during development and tests, never in production.
6671
# This can also be set per schema level.

lib/rails/graphql/type/enum.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ def indexed?
3939
# Check if a given value is a valid non-deserialized input
4040
def valid_input?(value)
4141
(valid_token?(value, :enum) && all_values.include?(value.to_s)) ||
42-
(value.is_a?(String) && all_values.include?(value))
42+
(value.is_a?(String) && all_values.include?(value)) ||
43+
(allow_string_input? && valid_token?(value, :string) &&
44+
all_values.include?(value.to_s[1..-2]))
4345
end
4446

4547
# Check if a given value is a valid non-serialized output
@@ -62,7 +64,13 @@ def as_json(value)
6264

6365
# Turn a user input of this given type into an ruby object
6466
def deserialize(value)
65-
new(value.is_a?(::GQLParser::Token) ? value.to_s : value) if valid_input?(value)
67+
if valid_token?(value, :enum)
68+
new(value.to_s)
69+
elsif allow_string_input? && valid_token?(value, :string)
70+
new(value[1..-2])
71+
elsif valid_input?(value)
72+
new(value)
73+
end
6674
end
6775

6876
# Use the instance as decorator
@@ -142,6 +150,12 @@ def inspect
142150
#{inspect_directives}
143151
INFO
144152
end
153+
154+
private
155+
156+
def allow_string_input?
157+
GraphQL.config.allow_string_as_enum_input
158+
end
145159
end
146160

147161
attr_reader :value

0 commit comments

Comments
 (0)