Skip to content

Commit

Permalink
added graphql service
Browse files Browse the repository at this point in the history
Signed-off-by: Karma Dolkar <karmadolkar29@gmail.com>
  • Loading branch information
karmadolkar authored and mergify[bot] committed May 21, 2020
1 parent ec6a5da commit fe46499
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
34 changes: 34 additions & 0 deletions bodhi/server/services/graphql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright © 2020 Red Hat Inc., and others.
#
# This file is part of Bodhi.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""Defines API endpoints related to GraphQL objects."""
from cornice import Service

graphql = Service(name='graphql', path='/graphql', description='graphql service')


@graphql.get()
def graphql_get(request):
"""
Return "Hello World".
Args:
request (pyramid.Request): The current request.
Returns:
str: A string "Hello World".
"""
return "Hello World"
26 changes: 26 additions & 0 deletions bodhi/tests/server/services/test_graphql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright © 2020 Red Hat, Inc. and others.
#
# This file is part of Bodhi.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from bodhi.tests.server import base


class TestGraphQLService(base.BasePyTestCase):
"""This class contains tests for a /graphql endpoint"""
def test_get(self):
"""Ensure that "Hello World" is returned"""
res = self.app.get('/graphql')
assert res.body == b'"Hello World"'

0 comments on commit fe46499

Please sign in to comment.