Class: Twenty::Servlet::GraphQL

Inherits:
Twenty::Servlet
  • Object
show all
Defined in:
lib/twenty-backend/servlet/graphql.rb

Instance Method Summary collapse

Methods included from ServerMixin

#server, #server_options

Instance Method Details

#do_POST(req, res) ⇒ Object

POST /servlet/graphql/



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/twenty-backend/servlet/graphql.rb', line 4

def do_POST(req, res)
  params = JSON.parse(req.body)
  result = Twenty::GraphQL::Schema.execute(
    params['query'],
    variables: params['variables'],
    context: {}
  )
  res['content_type'] = 'application/json'
  res.status = 200
  res.body = result.to_json
end