diff options
| author | mo khan <mo.khan@gmail.com> | 2020-12-21 16:55:59 -0700 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-12-21 16:55:59 -0700 |
| commit | 70e23f16e4d8f5c53ef8b6fede98e4b8dd4bc218 (patch) | |
| tree | 891e8532e58ebade6128367fa97335e3d8989923 /lib | |
| parent | 9d509199b72b79b3c0e600b3b59150c4f7a987f0 (diff) | |
feat: process first graphql query
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/server.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/server.rb b/lib/server.rb index 6b14bf7..600dce5 100644 --- a/lib/server.rb +++ b/lib/server.rb @@ -1,7 +1,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) - [200, {}, []] + query = '{ me }' + + [ + 200, + { 'Content-Type' => 'application/graphql' }, + [MySchema.execute(query).to_json] + ] end end |
