Skip to content

Instantly share code, notes, and snippets.

@hash32bot
hash32bot / mutation.rb
Last active December 25, 2018 14:58
Mutation Root - [Post] GraphQL with Sinatra (Ruby) - Part 2- Mutations
require 'graphql'
require_relative 'mutations/create_speaker'
class MutationType < GraphQL::Schema::Object
description "The mutation root of this schema"
field :createSpeaker, mutation: Mutations::CreateSpeaker
end
@hash32bot
hash32bot / mutation.graphql
Last active December 25, 2018 15:23
New speaker mutation - [Post] GraphQL with Sinatra (Ruby) - Part 2- Mutations
mutation AddSpeaker($name:String, $talkTitle:String, $bio:String, $twitterHandle:String) {
createSpeaker(name: $name, talkTitle: $talkTitle, bio: $bio, twitterHandle: $twitterHandle) {
success
errors
}
}
@hash32bot
hash32bot / app_5.rb
Created December 25, 2018 13:30
app.rb changes - Graphql Sinatra - http://bit.ly/2V9p6OL
# Changes to file app.rb
# ...
require 'rack/contrib'
class ConferenceApp < Sinatra::Base
# ...
use Rack::PostBodyContentTypeParser
# ...
# ...
post '/graphql' do
result = ConferenceAppSchema.execute(
@hash32bot
hash32bot / response.json
Created December 25, 2018 13:34
Graphql Query response - Graphql Sinatra App - http://bit.ly/2V9p6OL
{
"data": {
"speakers": [
{
"name": "John",
"twitterHandle": "johnruby",
"bio": "This is John's bio"
},
{
"name": "Jacob",
@hash32bot
hash32bot / gist:14750b9eea739374ca69dc3182ca99a3
Created March 8, 2019 10:08 — forked from victorlhlam/gist:7019359
Rails 3.1+ force_ssl & HSTS problem

Rails 3.1 introduced force_ssl. You can add config.force_ssl = true in application.rb.

By enabling force_ssl, Rails send a HSTS (HTTP Strict Transport Security) header which will expired in a year.

So if you enabled force_ssl once, even you change the config value to false later, the browser you used to open you app before will still remember this website (using domain to identify) require to use HTTPS, and redirect you to HTTPS connection automatically. You may use chrome://net-internals/#hsts to check the domain list in Google Chrome.