# GraphQL API
Framework for building a GraphQL API with Python
[](https://gitlab.com/parob/graphql-api/commits/master)
[](https://gitlab.com/parob/graphql-api/commits/master)
## Installation
##### Pip
```
pip install graphql-api
```
## Run the Unit Tests
To run the tests.
```
pip install pipenv
pipenv install --dev
pipenv run python -m pytest tests --cov=graphql_api
```
## Docs
The documentation is public, and is generated using Sphinx.
[GraphQL-API Documentation](http://parob.gitlab.io/graphql-api/)
##### Build documentation
To build a local static HTML version of the documentation.
```
pip install pipenv
pipenv install sphinx
pipenv run sphinx-build docs ./public -b html
```
## Simple Example
``` python
from graphql_api import GraphQLAPI
api = GraphQLAPI()
@api.type(is_root_type=True)
class MathService:
@api.field
def is_odd(self, number: int) -> str:
return "No" if (num % 2) else "Yes"
query = '''
query {
isOdd(number: 5)
}
'''
result = api.executor().execute(query)
print(result.data)
```
``` text
$ python example.py
>>> {'isOdd': 'No'}
```
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/parob/graphql-api",
"name": "graphql-api",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "GraphQL, GraphQL-API, GraphQLAPI, Server",
"author": "Robert Parker",
"author_email": "rob@parob.com",
"download_url": "https://files.pythonhosted.org/packages/e1/13/6dbf60fa060a79b9bdb46b35d99062b4cbb6698516b850367e0162965261/graphql_api-1.3.27.tar.gz",
"platform": null,
"description": "# GraphQL API\nFramework for building a GraphQL API with Python\n\n[](https://gitlab.com/parob/graphql-api/commits/master)\n\n[](https://gitlab.com/parob/graphql-api/commits/master)\n\n\n\n## Installation\n\n##### Pip\n```\npip install graphql-api\n```\n\n## Run the Unit Tests\nTo run the tests.\n```\npip install pipenv\npipenv install --dev\npipenv run python -m pytest tests --cov=graphql_api\n```\n\n## Docs\n\nThe documentation is public, and is generated using Sphinx.\n\n[GraphQL-API Documentation](http://parob.gitlab.io/graphql-api/)\n\n##### Build documentation\nTo build a local static HTML version of the documentation.\n```\npip install pipenv\npipenv install sphinx\npipenv run sphinx-build docs ./public -b html\n```\n\n## Simple Example\n``` python\nfrom graphql_api import GraphQLAPI\n\napi = GraphQLAPI()\n\n@api.type(is_root_type=True)\nclass MathService:\n\n @api.field\n def is_odd(self, number: int) -> str:\n return \"No\" if (num % 2) else \"Yes\"\n\n\nquery = '''\n query {\n isOdd(number: 5)\n }\n'''\n\nresult = api.executor().execute(query)\n\nprint(result.data)\n```\n\n``` text\n$ python example.py\n>>> {'isOdd': 'No'}\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A framework for building Python GraphQL APIs.",
"version": "1.3.27",
"project_urls": {
"Download": "https://gitlab.com/parob/graphql/-/archive/v1.3.27/graphql_api-v1.3.27.tar.gz",
"Homepage": "https://gitlab.com/parob/graphql-api"
},
"split_keywords": [
"graphql",
" graphql-api",
" graphqlapi",
" server"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e1136dbf60fa060a79b9bdb46b35d99062b4cbb6698516b850367e0162965261",
"md5": "77fe0107ad0908a252ec70f55a77e820",
"sha256": "953eac9dbf4942c934284cb91ae5527481c39dd63421145008f37014462f75a0"
},
"downloads": -1,
"filename": "graphql_api-1.3.27.tar.gz",
"has_sig": false,
"md5_digest": "77fe0107ad0908a252ec70f55a77e820",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 57337,
"upload_time": "2025-02-17T23:10:21",
"upload_time_iso_8601": "2025-02-17T23:10:21.303725Z",
"url": "https://files.pythonhosted.org/packages/e1/13/6dbf60fa060a79b9bdb46b35d99062b4cbb6698516b850367e0162965261/graphql_api-1.3.27.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-17 23:10:21",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "parob",
"gitlab_project": "graphql-api",
"lcname": "graphql-api"
}