Module: Twenty::Rack::GraphQL
- Defined in:
- lib/twenty/server/rack/graphql.rb
Instance Method Summary collapse
-
#call(env) ⇒ Array<Integer, Hash, #each>
Extends Server::Dir (a static file Rack application) with a /graphql endpoint.
Instance Method Details
#call(env) ⇒ Array<Integer, Hash, #each>
Extends Server::Dir (a static file Rack application) with a /graphql endpoint
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/twenty/server/rack/graphql.rb', line 14 def call(env) req = Rack::Request.new(env) if req.post? && req.path == "/graphql" params = JSON.parse(req.body.string) result = Twenty::GraphQL::Schema.execute( params["query"], variables: params["variables"], context: {} ) [200, {"content-type" => "application/json"}, [result.to_json]] else super(env) end end |