summaryrefslogtreecommitdiff
path: root/lib/server.rb
blob: 600dce5dc02d47826674848b59f7a66bc0f64eea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'rack'
require 'json'
require 'graphql'

module Types
  class QueryType < GraphQL::Schema::Object
    field :me, String, null: false

    def me
      'mo'
    end
  end
end

class MySchema < GraphQL::Schema
  max_complexity 400
  query Types::QueryType
end

class Server
  def call(env)
    query = '{ me }'

    [
      200,
      { 'Content-Type' => 'application/graphql' },
      [MySchema.execute(query).to_json]
    ]
  end
end