Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am pmk1c on github.
  • I am pmk1c (https://keybase.io/pmk1c) on keybase.
  • I have a public key ASBzwIER0YJWXfyZ-IG0DVRzhgszuICTrO6OBa308Fhd3Qo

To claim this, I am signing this object:

View blog_prepend_i18n_path.rb
class BlogPrependI18nPath < Middleman::Extension
option :blog_name, 'blog'
def after_configuration
manipulator = Manipulator.new(@app, options)
@app.sitemap.register_resource_list_manipulator(:"fix_i18n_article_paths_#{options.blog_name}", manipulator)
end
class Manipulator
def initialize(app, options)
@pmk1c
pmk1c / relacs.json
Last active Apr 12, 2018
Lactose data
View relacs.json
[ {
"id": 1,
"title": "Buttermilch",
"lactose": 4
}, {
"id": 2,
"title": "Magermilch UHT",
"lactose": 4.7
}, {
"id": 3,
@pmk1c
pmk1c / post_resolver.ex
Created Jun 12, 2017
RestQL - create in PostResolver
View post_resolver.ex
defmodule Restql.Blog.PostResolver do
# ...
def create(args, _info) do
Restql.Blog.create_post(args)
end
# ...
end
@pmk1c
pmk1c / schema.ex
Created Jun 12, 2017
RestQL - CreatePost manipulation in GraphQL Schema
View schema.ex
defmodule Restql.Blog.Schema do
# ...
mutation name: "CreatePost" do
field :post, type: :post do
arg :title, non_null(:string)
arg :body, non_null(:string)
resolve &Restql.Blog.PostResolver.create/2
end
end
# ...
@pmk1c
pmk1c / post_controller.ex
Last active Jul 17, 2017
RestQL - create function in PostController with GraphQL
View post_controller.ex
defmodule Restql.Web.PostController do
# ...
def create(conn, %{"post" => post_params}) do
graphql conn, """
mutation CreatePost($title: String!, $body: String!) {
post(title: $title, body: $body) {
id
}
}
""", post_params
@pmk1c
pmk1c / post_resolver.ex
Last active Jun 12, 2017
RestQL - PostResolver
View post_resolver.ex
defmodule Restql.Blog.PostResolver do
def all(_args, _info) do
{:ok, Restql.Blog.list_posts |> Restql.Repo.preload(:author)}
end
end
@pmk1c
pmk1c / schema.ex
Created Jun 12, 2017
RestQL - GraphQL Schema
View schema.ex
defmodule Restql.Blog.Schema do
use Absinthe.Schema
import_types Restql.Blog.Schema.Types
query do
field :posts, list_of(:post) do
resolve &Restql.Blog.PostResolver.all/2
end
end
end
@pmk1c
pmk1c / types.ex
Last active Jun 12, 2017
RestQL - GraphQL Types
View types.ex
defmodule Restql.Blog.Schema.Types do
use Absinthe.Schema.Notation
object :post do
field :id, :id
field :title, :string
field :body, :string
field :author, :user
end
@pmk1c
pmk1c / post_controller.ex
Last active Jul 17, 2017
RestQL - PostController with GraphQL
View post_controller.ex
defmodule Restql.Web.PostController do
use Restql.Web, :controller
alias Restql.Blog
alias Restql.Blog.Post
def index(conn, _params) do
graphql conn, """
{
posts {
You can’t perform that action at this time.