Sha256: 5f8e63043eabcdecb7b7c6fe704c86da6a360ef57f37e92d4953a0dd485a1691

Contents?: true

Size: 814 Bytes

Versions: 6

Compression:

Stored size: 814 Bytes

Contents

require "kanji/application"
require "schema"
require_relative "container"

module <%= config[:camel_cased_app_name] %>
  class Application < Kanji::Application
    configure do |config|
      config.container = Container
    end

    route do |r|
      r.is "graphiql" do
        render "graphiql.html"
      end

      r.post "api" do
        r.resolve "graph.query" do |query|
          payload = JSON.parse(request.body.read)
          result = query.call(
            schema: <%= config[:camel_cased_app_name] %>::Schema,
            query: payload["query"],
            variables: payload["variables"],
            context: {}
          )
          result.to_json
        end
      end
    end

    error do |e|
      self.class[:rack_monitor].instrument(:error, exception: e)
      raise e
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kanji-web-0.3.1 lib/kanji/templates/system/project/application.rb.tt
kanji-web-0.3.0 lib/kanji/templates/system/project/application.rb.tt
kanji-web-0.2.2 lib/kanji/templates/system/project/application.rb.tt
kanji-web-0.2.1 lib/kanji/templates/system/project/application.rb.tt
kanji-web-0.2.0 lib/kanji/templates/system/project/application.rb.tt
kanji-web-0.1.0 lib/kanji/templates/system/project/application.rb.tt