Skip to content

Instantly share code, notes, and snippets.

@y310
y310 / schema.go
Last active September 22, 2018 13:40
package schema
import (
"log"
"github.com/graphql-go/graphql"
)
// User type
type User struct {
# https://github.com/rmosolgo/graphql-ruby/blob/v1.8.1/lib/graphql/execution/multiplex.rb#L46-L49
def run_all(schema, query_options, *args)
queries = query_options.map { |opts| GraphQL::Query.new(schema, nil, opts) }
run_queries(schema, queries, *args)
end
# https://github.com/rmosolgo/graphql-ruby/blob/v1.8.1/lib/graphql/schema/member/cached_graphql_definition.rb#L14-L16
def graphql_definition
@graphql_definition ||= to_graphql
end
class GraphqlExampleSchema < GraphQL::Schema
mutation(Types::MutationType)
query(Types::QueryType)
end
# Run "gem install graphql" before executing this file
require 'graphql'
# Dummy model class
class User
def self.find_by(id:)
OpenStruct.new(id: id, name: 'test user')
end
end
@y310
y310 / multiplex.rb
Last active June 17, 2018 04:22
lib/graphql/execution/multiplex.rb
# https://github.com/rmosolgo/graphql-ruby/blob/v1.8.1/lib/graphql/execution/multiplex.rb#L77-L98
def run_as_multiplex(multiplex)
queries = multiplex.queries
# Do as much eager evaluation of the query as possible
results = queries.map do |query|
begin_query(query)
end
# Then, work through lazy results in a breadth-first way
GraphQL::Execution::Execute::ExecutionFunctions.lazy_resolve_root_selection(results, { multiplex: multiplex })
@y310
y310 / gist:10244018
Last active August 29, 2015 13:58
potatotips #6

AutoFlight

〜簡単セットアップで自動ビルド〜

課題

Jenkinsによるビルド自動化とTestFlightアップロードはよくWeb上にも情報があるのですが、大概プロジェクトごとにジョブを作る必要があって煩雑でした。

なので、簡単なセットアップで任意のiOSプロジェクトでビルドできる仕組みを作りました!

@y310
y310 / autoflight.png
Last active August 29, 2015 13:58
Utilities for AutoFlight
autoflight.png
@y310
y310 / Usage.sh
Last active August 29, 2015 13:57
./ios_app_icon.rb project.xcodeproj Release | xargs -n 1 -IICON ./composite.sh ICON ribbon.png
./ios_app_icon.rb project.xcodeproj Release | xargs -n 1 -IICON ./replace.sh ICON beta.png
@y310
y310 / gist:9003262
Last active August 29, 2015 13:56
Obj-C pagination PoC
@implementation TableViewController1
- (void)viewDidLoad
{
BaseRequester *requester = [[BaseRequester alloc] initWithPath:@"/recipes"
params:@{@"fields":@"id,name"}
model:[Recipe class]]
self.paginator = [Paginator instantiateWithReuseidentifier:@"recipes"
requester:requester
perPage:10];
if (self.recipes.count == 0) {