Skip to content

Commit

Permalink
Merge branch 'graphql-python:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
arun-sureshkumar authored Apr 9, 2023
2 parents b9a1f24 + 807ae70 commit ec1c7af
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 89 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Test Package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: Lint with flake8
run: |
python -m pip install flake8
make lint
- name: Install dependencies
run: |
python -m pip install poetry
poetry config virtualenvs.create false
poetry install --with dev
- name: Run Tests
run: make test
- name: Build Package
run: |
poetry build
27 changes: 27 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Lint

on: [push, pull_request]
permissions:
contents: read

jobs:
build:
strategy:
matrix:
python: ["3.11"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Lint with flake8
run: make lint
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ clean:
@find . -name "__pycache__" -delete

lint:
@flake8 graphene_mongo
@flake8 graphene_mongo --count --show-source --statistics

test: clean lint
test: clean
pytest graphene_mongo/tests --cov=graphene_mongo --cov-report=html --cov-report=term

register-pypitest:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[![Build Status](https://travis-ci.org/graphql-python/graphene-mongo.svg?branch=master)](https://travis-ci.org/graphql-python/graphene-mongo) [![Coverage Status](https://coveralls.io/repos/github/graphql-python/graphene-mongo/badge.svg?branch=master)](https://coveralls.io/github/graphql-python/graphene-mongo?branch=master) [![Documentation Status](https://readthedocs.org/projects/graphene-mongo/badge/?version=latest)](http://graphene-mongo.readthedocs.io/en/latest/?badge=latest) [![PyPI version](https://badge.fury.io/py/graphene-mongo.svg)](https://badge.fury.io/py/graphene-mongo) [![PyPI pyversions](https://img.shields.io/pypi/pyversions/graphene-mongo.svg)](https://pypi.python.org/pypi/graphene-mongo/) [![Downloads](https://pepy.tech/badge/graphene-mongo)](https://pepy.tech/project/graphene-mongo)

[![Lint](https://github.com/graphql-python/graphene-mongo/actions/workflows/lint.yml/badge.svg?branch=master)](https://github.com/graphql-python/graphene-mongo/actions/workflows/lint.yml) [![Test Package](https://github.com/graphql-python/graphene-mongo/actions/workflows/ci.yml/badge.svg)](https://github.com/graphql-python/graphene-mongo/actions/workflows/ci.yml)

# Graphene-Mongo

A [Mongoengine](https://mongoengine-odm.readthedocs.io/) integration for [Graphene](http://graphene-python.org/).
Expand Down
2 changes: 1 addition & 1 deletion graphene_mongo/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def default_resolver(self, _root, info, required_fields=None, resolved=None, **a
args_copy[key] = args_copy[key].value

if PYMONGO_VERSION >= (3, 7):
if hasattr(self.model,'_meta') and 'db_alias' in self.model._meta:
if hasattr(self.model, '_meta') and 'db_alias' in self.model._meta:
count = (mongoengine.get_db(self.model._meta['db_alias'])[self.model._get_collection_name()]).count_documents(args_copy)
else:
count = (mongoengine.get_db()[self.model._get_collection_name()]).count_documents(args_copy)
Expand Down
Loading

0 comments on commit ec1c7af

Please sign in to comment.