https://github.com/bigbuildbench/graphql-python_graphene-mongo
https://github.com/bigbuildbench/graphql-python_graphene-mongo
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.2%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: BigBuildBench
- License: mit
- Language: Python
- Default Branch: master
- Size: 104 KB
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Graphene-Mongo
A Mongoengine integration for Graphene.
Installation
For installing graphene-mongo, just run this command in your shell
pip install graphene-mongo
Examples
Here is a simple Mongoengine model as models.py:
```python from mongoengine import Document from mongoengine.fields import StringField
class User(Document): meta = {'collection': 'user'} firstname = StringField(required=True) lastname = StringField(required=True) ```
To create a GraphQL schema and sync executor; for it you simply have to write the following:
```python import graphene
from graphene_mongo import MongoengineObjectType
from .models import User as UserModel
class User(MongoengineObjectType): class Meta: model = UserModel
class Query(graphene.ObjectType): users = graphene.List(User)
def resolve_users(self, info):
return list(UserModel.objects.all())
schema = graphene.Schema(query=Query) ```
Then you can simply query the schema:
python
query = '''
query {
users {
firstName,
lastName
}
}
'''
result = await schema.execute(query)
To create a GraphQL schema and async executor; for it you simply have to write the following:
```python import graphene
from graphenemongo import AsyncMongoengineObjectType from graphenemongo.utils import synctoasync from concurrent.futures import ThreadPoolExecutor
from .models import User as UserModel
class User(AsyncMongoengineObjectType): class Meta: model = UserModel
class Query(graphene.ObjectType): users = graphene.List(User)
async def resolve_users(self, info):
return await sync_to_async(list, thread_sensitive=False,
executor=ThreadPoolExecutor())(UserModel.objects.all())
schema = graphene.Schema(query=Query) ```
Then you can simply query the schema:
python
query = '''
query {
users {
firstName,
lastName
}
}
'''
result = await schema.execute_async(query)
To learn more check out the following examples:
Contributing
After cloning this repo, ensure dependencies are installed by running:
sh
pip install -r requirements.txt
After developing, the full test suite can be evaluated by running:
sh
make test
Owner
- Name: BigBuildBench
- Login: BigBuildBench
- Kind: organization
- Repositories: 1
- Profile: https://github.com/BigBuildBench
abbr. B3, benchmarking the repo-level understanding capability of your LLMs by reconstructing project build-file.
GitHub Events
Total
- Create event: 4
Last Year
- Create event: 4
Dependencies
- actions/checkout v3 composite
- actions/setup-python v3 composite
- actions/checkout v3 composite
- actions/setup-python v3 composite
- actions/checkout v3 composite
- actions/setup-python v3 composite
- pypa/gh-action-pypi-publish release/v1 composite
- Django ==3.2.25
- graphene-django ==2.4.0
- graphene-mongo *
- mongoengine ==0.27.0
- mongomock ==3.16.0
- pytest ==4.6.3
- pytest-django ==3.5.1
- falcon ==2.0.0
- graphene-mongo *
- mongoengine ==0.17.0
- mongomock ==3.16.0
- pytest ==4.6.3
- waitress ==2.1.2
- Flask >=1.0.0
- Flask-GraphQL ==2.0.0
- graphene-mongo *
- mongomock ==3.14.0
- mock >=5.0.1 develop
- mongomock >=4.1.2 develop
- pytest * develop
- pytest-asyncio ^0.21.0 develop
- pytest-cov * develop
- ruff * develop
- setuptools ^69.0.2 develop
- python >=3.9,<4