Skip to content

Instantly share code, notes, and snippets.

View skorth's full-sized avatar

Sascha Korth skorth

View GitHub Profile
@skorth
skorth / form_object.rb
Last active November 21, 2016 14:53
Building a FormObject by using dry-rb.org
class FooForm < Dry::Struct
constructor_type(:schema)
module Types
include Dry::Types.module
end
attribute :title, Types::Coercible::String
attribute :location, Types::Coercible::String
attribute :description, Types::Coercible::String
{
“data”: {
"user" : {
“id”: “3”
"name": “Chewbacca",
}
}
}
mutation {
user: createUser(name: “Chewbacca”) {
id,
name
}
}
query {
user(id: 123) {
name
}
}
{
__schema {
types {
kind
name
description
}
}
}
{
user(id: 123) {
name,
profilePicture(size: 200) {
width,
height,
url
}
}
}
type Query {
user: User
user(id: Int): User
}
type User {
name: String
profilePicture(size: Int = 50): ProfilePicture
}
{
"data": {
"user" : {
"name": "Luke Skywalker",
"friends": [
{ name: "Han Solo" },
{ name: "Leia Organa" }
]
}
}
{
user(id: 123) {
name,
friends {
name
}
}
}
@skorth
skorth / abstract_mysql_adapter.rb
Created January 12, 2016 08:28
Remove `DEFAULT NULL` for primary key column to support MySQL 5.7.3
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
end