Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI & CD #1

Merged
merged 4 commits into from Jul 5, 2019
Merged

CI & CD #1

Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -0,0 +1,15 @@
version: 2.1

orbs:
serverless-ruby: codegram/serverless-ruby@0.0.3

workflows:
main:
jobs:
- serverless-ruby/test
- serverless-ruby/deploy:
requires:
- serverless-ruby/test
filters:
branches:
only: master
1 .rspec
@@ -0,0 +1 @@
--require spec_helper
@@ -0,0 +1 @@
2.5.5
11 Gemfile
@@ -1,5 +1,12 @@
# frozen_string_literal: true

source "https://rubygems.org"
source 'https://rubygems.org'

gem "graphql"
ruby RUBY_VERSION

gem 'graphql'

group :test do
gem 'rspec'
gem 'rspec_junit_formatter'
end
@@ -1,13 +1,34 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.3)
graphql (1.8.11)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.2)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)

PLATFORMS
ruby

DEPENDENCIES
graphql
rspec
rspec_junit_formatter

RUBY VERSION
ruby 2.5.5p157

BUNDLED WITH
1.17.1
2.0.2
@@ -4,16 +4,26 @@ An example of how to build a GraphQL API with Ruby on AWS Lambda without Sinatra

## Installation

You need to these dependencies installed:

1. Ruby 2.5.5
1. bundler >= 2.0.2
1. Node 12.5
1. npm >= 6.9.2
1. Docker (if you want to deploy locally)

Clone this repo:

$ git clone https://github.com/oriolgual/serverless-ruby-graphql.git
$ cd serverless-ruby-graphql
$ bundle
$ npm install -g serverless
$ npm install

## Deploy

$ sls deploy
Deploying to production is handled by CircleCI (make sure to add your repo to CircleCi and add AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY). If you need to deploy a development environment run:

$ npm run deploy:dev

## Usage

8 app.rb
@@ -1,10 +1,12 @@
# frozen_string_literal: true

require 'json'
require_relative "app/graphql/schema"
require_relative 'app/graphql/schema'

def request(event:, context:)
puts "Received Request: #{event}"

body = Schema.execute(event["body"]).to_json
body = Schema.execute(event['body']).to_json

{
statusCode: 200,
@@ -16,6 +18,6 @@ def request(event:, context:)

{
statusCode: 400,
body: JSON.generate("Bad request, please POST a request body!")
body: JSON.generate('Bad request, please POST a request body!')
}
end
@@ -1,5 +1,7 @@
# frozen_string_literal: true

class PostType < GraphQL::Schema::Object
description "A blog post"
description 'A blog post'
field :id, ID, null: false
field :title, String, null: false
end
@@ -1,12 +1,14 @@
require_relative "post_type"
require_relative "../models/post"
# frozen_string_literal: true

require_relative 'post_type'
require_relative '../models/post'

class QueryType < GraphQL::Schema::Object
description "The query root of this schema"
description 'The query root of this schema'

# First describe the field signature:
field :post, PostType, null: true do
description "Find a post by ID"
description 'Find a post by ID'
argument :id, ID, required: true
end

@@ -1,5 +1,7 @@
require "graphql"
require_relative "query_type"
# frozen_string_literal: true

require 'graphql'
require_relative 'query_type'

class Schema < GraphQL::Schema
query QueryType
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Post
attr_reader :id, :title

@@ -21,8 +23,8 @@ def self.find(id)

def self.all
@all ||= [
Post.new(1, "First post"),
Post.new(2, "Second post")
Post.new(1, 'First post'),
Post.new(2, 'Second post')
]
end
end
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.