Skip to content

Commit

Permalink
Merge pull request #11 from strollby/pagination-fix-v2
Browse files Browse the repository at this point in the history
Pagination fix v2
  • Loading branch information
abhinand-c authored Nov 21, 2023
2 parents 4c68df5 + 50642e9 commit ef5c9cc
Show file tree
Hide file tree
Showing 31 changed files with 1,070 additions and 802 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Lint with flake8
pip install ruff
- name: Lint with ruff
run: make lint
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ clean:
@find . -name "__pycache__" -delete

lint:
@flake8 graphene_mongo --count --show-source --statistics
@ruff check graphene_mongo
@ruff format . --check

test: clean
pytest graphene_mongo/tests --cov=graphene_mongo --cov-report=html --cov-report=term
Expand Down
20 changes: 8 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@
master_doc = "index"

# General information about the project.
project = u"Graphene Mongo"
copyright = u"Graphene 2018"
author = u"Abaw Chen"
project = "Graphene Mongo"
copyright = "Graphene 2018"
author = "Abaw Chen"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u"0.1"
version = "0.1"
# The full version, including alpha/beta/rc tags.
release = u"0.1.2"
release = "0.1.2"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down Expand Up @@ -275,9 +275,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, "Graphene.tex", u"Graphene Documentation", u"Syrus Akbary", "manual")
]
latex_documents = [(master_doc, "Graphene.tex", "Graphene Documentation", "Syrus Akbary", "manual")]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
Expand Down Expand Up @@ -316,9 +314,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, "graphene_django", u"Graphene Django Documentation", [author], 1)
]
man_pages = [(master_doc, "graphene_django", "Graphene Django Documentation", [author], 1)]

# If true, show URL addresses after external links.
#
Expand All @@ -334,7 +330,7 @@
(
master_doc,
"Graphene-Django",
u"Graphene Django Documentation",
"Graphene Django Documentation",
author,
"Graphene Django",
"One line description of project.",
Expand Down
4 changes: 1 addition & 3 deletions examples/django_mongoengine/bike/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
from graphene_django.views import GraphQLView

urlpatterns = [
path(
"graphql", csrf_exempt(GraphQLView.as_view(graphiql=True)), name="graphql-query"
)
path("graphql", csrf_exempt(GraphQLView.as_view(graphiql=True)), name="graphql-query")
]
4 changes: 1 addition & 3 deletions examples/django_mongoengine/bike_catalog/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
},
{"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
Expand Down
4 changes: 1 addition & 3 deletions examples/django_mongoengine/bike_catalog/settings_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from .settings import * # flake8: noqa

mongoengine.connect(
"graphene-mongo-test", host="mongomock://localhost", alias="default"
)
mongoengine.connect("graphene-mongo-test", host="mongomock://localhost", alias="default")
4 changes: 1 addition & 3 deletions examples/falcon_mongoengine/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
from .schema import schema


def set_graphql_allow_header(
req: falcon.Request, resp: falcon.Response, resource: object
):
def set_graphql_allow_header(req: falcon.Request, resp: falcon.Response, resource: object):
resp.set_header("Allow", "GET, POST, OPTIONS")


Expand Down
22 changes: 13 additions & 9 deletions examples/falcon_mongoengine/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import mongoengine
from graphene.test import Client

from examples.falcon_mongoengine.schema import schema
from .fixtures import fixtures_data

mongoengine.connect(
"graphene-mongo-test", host="mongomock://localhost", alias="default"
)
mongoengine.connect("graphene-mongo-test", host="mongomock://localhost", alias="default")


def test_category_last_1_item_query(fixtures_data):
Expand All @@ -23,7 +22,16 @@ def test_category_last_1_item_query(fixtures_data):

expected = {
"data": {
"categories": {"edges": [{"node": {"name": "Work", "color": "#1769ff"}}]}
"categories": {
"edges": [
{
"node": {
"name": "Work",
"color": "#1769ff",
}
}
]
}
}
}

Expand All @@ -45,11 +53,7 @@ def test_category_filter_item_query(fixtures_data):
}
}"""

expected = {
"data": {
"categories": {"edges": [{"node": {"name": "Work", "color": "#1769ff"}}]}
}
}
expected = {"data": {"categories": {"edges": [{"node": {"name": "Work", "color": "#1769ff"}}]}}}

client = Client(schema)
result = client.execute(query)
Expand Down
4 changes: 1 addition & 3 deletions examples/flask_mongoengine/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
}
}""".strip()

app.add_url_rule(
"/graphql", view_func=GraphQLView.as_view("graphql", schema=schema, graphiql=True)
)
app.add_url_rule("/graphql", view_func=GraphQLView.as_view("graphql", schema=schema, graphiql=True))

if __name__ == "__main__":
init_db()
Expand Down
4 changes: 0 additions & 4 deletions examples/flask_mongoengine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,21 @@


class Department(Document):

meta = {"collection": "department"}
name = StringField()


class Role(Document):

meta = {"collection": "role"}
name = StringField()


class Task(EmbeddedDocument):

name = StringField()
deadline = DateTimeField(default=datetime.now)


class Employee(Document):

meta = {"collection": "employee"}
name = StringField()
hired_on = DateTimeField(default=datetime.now)
Expand Down
13 changes: 10 additions & 3 deletions examples/flask_mongoengine/schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import graphene
from graphene.relay import Node
from graphene_mongo.tests.nodes import PlayerNode, ReporterNode

from graphene_mongo import MongoengineConnectionField, MongoengineObjectType
from .models import Department as DepartmentModel
Expand All @@ -20,7 +19,11 @@ class Meta:
model = RoleModel
interfaces = (Node,)
filter_fields = {
'name': ['exact', 'icontains', 'istartswith']
"name": [
"exact",
"icontains",
"istartswith",
]
}


Expand All @@ -35,7 +38,11 @@ class Meta:
model = EmployeeModel
interfaces = (Node,)
filter_fields = {
'name': ['exact', 'icontains', 'istartswith']
"name": [
"exact",
"icontains",
"istartswith",
]
}


Expand Down
2 changes: 1 addition & 1 deletion graphene_mongo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"MongoengineInputType",
"MongoengineInterfaceType",
"MongoengineConnectionField",
"AsyncMongoengineConnectionField"
"AsyncMongoengineConnectionField",
]
7 changes: 6 additions & 1 deletion graphene_mongo/advanced_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import base64

import graphene


Expand Down Expand Up @@ -65,5 +66,9 @@ class PolygonFieldType(_CoordinatesTypeField):

class MultiPolygonFieldType(_CoordinatesTypeField):
coordinates = graphene.List(
graphene.List(graphene.List(graphene.List(graphene.Float)))
graphene.List(
graphene.List(
graphene.List(graphene.Float),
)
)
)
Loading

0 comments on commit ef5c9cc

Please sign in to comment.