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
Last synced: 10 months ago · JSON representation

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
Created over 1 year ago · Last pushed over 1 year ago
Metadata Files
Readme License

README.md

Build Status Coverage Status Documentation Status PyPI version PyPI pyversions Downloads

Lint Test Package

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

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

.github/workflows/ci.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
.github/workflows/lint.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
.github/workflows/publish.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • pypa/gh-action-pypi-publish release/v1 composite
docs/requirements.txt pypi
examples/django_mongoengine/requirements.txt pypi
  • 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
examples/falcon_mongoengine/requirements.txt pypi
  • falcon ==2.0.0
  • graphene-mongo *
  • mongoengine ==0.17.0
  • mongomock ==3.16.0
  • pytest ==4.6.3
  • waitress ==2.1.2
examples/flask_mongoengine/requirements.txt pypi
  • Flask >=1.0.0
  • Flask-GraphQL ==2.0.0
  • graphene-mongo *
  • mongomock ==3.14.0
pyproject.toml pypi
  • 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