mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-11 08:32:25 +03:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7d2af3104e | ||
|
0845aa95e4 | ||
|
aba771b2fc | ||
|
46bb1202e4 | ||
|
afa44e8a5f |
26
.github/workflows/deploy.yml
vendored
Normal file
26
.github/workflows/deploy.yml
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
name: 🚀 Deploy to PyPI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python 3.9
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: 3.9
|
||||||
|
- name: Build wheel and source tarball
|
||||||
|
run: |
|
||||||
|
pip install wheel
|
||||||
|
python setup.py sdist bdist_wheel
|
||||||
|
- name: Publish a Python distribution to PyPI
|
||||||
|
uses: pypa/gh-action-pypi-publish@v1.1.0
|
||||||
|
with:
|
||||||
|
user: __token__
|
||||||
|
password: ${{ secrets.pypi_password }}
|
26
.github/workflows/lint.yml
vendored
Normal file
26
.github/workflows/lint.yml
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
name: Lint
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python 3.9
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: 3.9
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install tox
|
||||||
|
- name: Run lint 💅
|
||||||
|
run: tox
|
||||||
|
env:
|
||||||
|
TOXENV: pre-commit
|
||||||
|
- name: Run mypy
|
||||||
|
run: tox
|
||||||
|
env:
|
||||||
|
TOXENV: mypy
|
26
.github/workflows/tests.yml
vendored
Normal file
26
.github/workflows/tests.yml
vendored
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
name: Tests
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
max-parallel: 4
|
||||||
|
matrix:
|
||||||
|
python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10-dev"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install tox tox-gh-actions
|
||||||
|
- name: Test with tox
|
||||||
|
run: tox
|
||||||
|
env:
|
||||||
|
TOXENV: ${{ matrix.toxenv }}
|
|
@ -18,11 +18,11 @@ repos:
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
- repo: https://github.com/ambv/black
|
- repo: https://github.com/ambv/black
|
||||||
rev: 18.9b0
|
rev: 21.6b0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
language_version: python3
|
language_version: python3
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 3.7.7
|
rev: 3.9.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
* @ekampf @dan98765 @projectcheshire @jkimbo
|
|
||||||
/docs/ @dvndrsn @phalt @changeling
|
|
||||||
/examples/ @dvndrsn @phalt @changeling
|
|
|
@ -43,7 +43,7 @@ from .utils.resolve_only_args import resolve_only_args
|
||||||
from .utils.module_loading import lazy_import
|
from .utils.module_loading import lazy_import
|
||||||
|
|
||||||
|
|
||||||
VERSION = (2, 1, 8, "final", 0)
|
VERSION = (2, 1, 9, "final", 0)
|
||||||
|
|
||||||
__version__ = get_version(VERSION)
|
__version__ = get_version(VERSION)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
import re
|
import re
|
||||||
from collections import Iterable, OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
try:
|
||||||
|
from collections.abc import Iterable
|
||||||
|
except ImportError:
|
||||||
|
from collections import Iterable
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from graphql_relay import connection_from_list
|
from graphql_relay import connection_from_list
|
||||||
|
|
|
@ -48,7 +48,7 @@ class GlobalID(Field):
|
||||||
|
|
||||||
|
|
||||||
class NodeField(Field):
|
class NodeField(Field):
|
||||||
def __init__(self, node, type=False, deprecation_reason=None, name=None, **kwargs):
|
def __init__(self, node, type=False, **kwargs):
|
||||||
assert issubclass(node, Node), "NodeField can only operate in Nodes"
|
assert issubclass(node, Node), "NodeField can only operate in Nodes"
|
||||||
self.node_type = node
|
self.node_type = node
|
||||||
self.field_type = type
|
self.field_type = type
|
||||||
|
@ -57,8 +57,8 @@ class NodeField(Field):
|
||||||
# If we don's specify a type, the field type will be the node
|
# If we don's specify a type, the field type will be the node
|
||||||
# interface
|
# interface
|
||||||
type or node,
|
type or node,
|
||||||
description="The ID of the object",
|
id=ID(required=True, description="The ID of the object"),
|
||||||
id=ID(required=True),
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_resolver(self, parent_resolver):
|
def get_resolver(self, parent_resolver):
|
||||||
|
|
|
@ -54,10 +54,10 @@ for i, letter in enumerate(letter_chars):
|
||||||
def edges(selected_letters):
|
def edges(selected_letters):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"node": {"id": base64("Letter:%s" % l.id), "letter": l.letter},
|
"node": {"id": base64("Letter:%s" % letter.id), "letter": letter.letter},
|
||||||
"cursor": base64("arrayconnection:%s" % l.id),
|
"cursor": base64("arrayconnection:%s" % letter.id),
|
||||||
}
|
}
|
||||||
for l in [letters[i] for i in selected_letters]
|
for letter in [letters[i] for i in selected_letters]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,17 @@ def test_node_field_custom():
|
||||||
assert node_field.node_type == Node
|
assert node_field.node_type == Node
|
||||||
|
|
||||||
|
|
||||||
|
def test_node_field_args():
|
||||||
|
field_args = {
|
||||||
|
"name": "my_custom_name",
|
||||||
|
"description": "my_custom_description",
|
||||||
|
"deprecation_reason": "my_custom_deprecation_reason",
|
||||||
|
}
|
||||||
|
node_field = Node.Field(**field_args)
|
||||||
|
for field_arg, value in field_args.items():
|
||||||
|
assert getattr(node_field, field_arg) == value
|
||||||
|
|
||||||
|
|
||||||
def test_node_field_only_type():
|
def test_node_field_only_type():
|
||||||
executed = schema.execute(
|
executed = schema.execute(
|
||||||
'{ onlyNode(id:"%s") { __typename, name } } ' % Node.to_global_id("MyNode", 1)
|
'{ onlyNode(id:"%s") { __typename, name } } ' % Node.to_global_id("MyNode", 1)
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
import inspect
|
import inspect
|
||||||
from collections import Mapping, OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
try:
|
||||||
|
from collections.abc import Mapping
|
||||||
|
except ImportError:
|
||||||
|
from collections import Mapping
|
||||||
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from .argument import Argument, to_arguments
|
from .argument import Argument, to_arguments
|
||||||
|
|
|
@ -135,7 +135,7 @@ class Mutation(ObjectType):
|
||||||
def Field(
|
def Field(
|
||||||
cls, name=None, description=None, deprecation_reason=None, required=False
|
cls, name=None, description=None, deprecation_reason=None, required=False
|
||||||
):
|
):
|
||||||
""" Mount instance of mutation Field. """
|
"""Mount instance of mutation Field."""
|
||||||
return Field(
|
return Field(
|
||||||
cls._meta.output,
|
cls._meta.output,
|
||||||
args=cls._meta.arguments,
|
args=cls._meta.arguments,
|
||||||
|
|
|
@ -399,7 +399,7 @@ def test_big_list_of_containers_multiple_fields_query_benchmark(benchmark):
|
||||||
|
|
||||||
|
|
||||||
def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark(
|
def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark(
|
||||||
benchmark
|
benchmark,
|
||||||
):
|
):
|
||||||
class Container(ObjectType):
|
class Container(ObjectType):
|
||||||
x = Int()
|
x = Int()
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
import json
|
import json
|
||||||
from collections import Mapping
|
|
||||||
|
try:
|
||||||
|
from collections.abc import Mapping
|
||||||
|
except ImportError:
|
||||||
|
from collections import Mapping
|
||||||
|
|
||||||
|
|
||||||
def to_key(value):
|
def to_key(value):
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
from collections import Mapping, OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
try:
|
||||||
|
from collections.abc import Mapping
|
||||||
|
except ImportError:
|
||||||
|
from collections import Mapping
|
||||||
|
|
||||||
|
|
||||||
def deflate(node, index=None, path=None):
|
def deflate(node, index=None, path=None):
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -49,6 +49,9 @@ tests_require = [
|
||||||
"pytest-benchmark",
|
"pytest-benchmark",
|
||||||
"pytest-cov",
|
"pytest-cov",
|
||||||
"pytest-mock",
|
"pytest-mock",
|
||||||
|
# pinning fastdiff dep (required by snapshottest) because later versions
|
||||||
|
# require wasmer 1.0.0 which is not compatible with Python 2.7
|
||||||
|
"fastdiff==0.2.0",
|
||||||
"snapshottest",
|
"snapshottest",
|
||||||
"coveralls",
|
"coveralls",
|
||||||
"promise",
|
"promise",
|
||||||
|
|
|
@ -56,10 +56,10 @@ for i, letter in enumerate(letter_chars):
|
||||||
def edges(selected_letters):
|
def edges(selected_letters):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"node": {"id": base64("Letter:%s" % l.id), "letter": l.letter},
|
"node": {"id": base64("Letter:%s" % letter.id), "letter": letter.letter},
|
||||||
"cursor": base64("arrayconnection:%s" % l.id),
|
"cursor": base64("arrayconnection:%s" % letter.id),
|
||||||
}
|
}
|
||||||
for l in [letters[i] for i in selected_letters]
|
for letter in [letters[i] for i in selected_letters]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
28
tox.ini
28
tox.ini
|
@ -1,20 +1,28 @@
|
||||||
[tox]
|
[tox]
|
||||||
envlist = flake8,py27,py34,py35,py36,py37,pre-commit,pypy,mypy
|
envlist = py{27,36,37,38,39,310},flake8,pre-commit,mypy
|
||||||
skipsdist = true
|
|
||||||
|
[gh-actions]
|
||||||
|
python =
|
||||||
|
2.7: py27
|
||||||
|
3.6: py36
|
||||||
|
3.7: py37
|
||||||
|
3.8: py38
|
||||||
|
3.9: py39
|
||||||
|
3.10-dev: py310
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
|
passenv = *
|
||||||
|
usedevelop = True
|
||||||
deps =
|
deps =
|
||||||
.[test]
|
-e.[test]
|
||||||
py{35,36,37}: pytest-asyncio
|
py{36,37,38,39,310}: pytest-asyncio
|
||||||
setenv =
|
setenv =
|
||||||
PYTHONPATH = .:{envdir}
|
PYTHONPATH = .:{envdir}
|
||||||
commands =
|
commands =
|
||||||
py{27,py}: py.test --cov=graphene graphene examples {posargs}
|
py{27}: py.test --cov=graphene graphene examples {posargs}
|
||||||
py{35}: py.test --cov=graphene graphene examples tests_asyncio {posargs}
|
py{36,37,38,39,310}: py.test --cov=graphene graphene examples tests_asyncio tests_py36 {posargs}
|
||||||
py{36,37}: py.test --cov=graphene graphene examples tests_asyncio tests_py36 {posargs}
|
|
||||||
|
|
||||||
[testenv:pre-commit]
|
[testenv:pre-commit]
|
||||||
basepython=python3.7
|
|
||||||
deps =
|
deps =
|
||||||
pre-commit>0.12.0
|
pre-commit>0.12.0
|
||||||
setenv =
|
setenv =
|
||||||
|
@ -23,9 +31,9 @@ commands =
|
||||||
pre-commit {posargs:run --all-files}
|
pre-commit {posargs:run --all-files}
|
||||||
|
|
||||||
[testenv:mypy]
|
[testenv:mypy]
|
||||||
basepython=python3.7
|
|
||||||
deps =
|
deps =
|
||||||
mypy
|
mypy
|
||||||
|
types-six
|
||||||
commands =
|
commands =
|
||||||
mypy graphene
|
mypy graphene
|
||||||
|
|
||||||
|
@ -34,5 +42,3 @@ deps = flake8
|
||||||
commands =
|
commands =
|
||||||
pip install -e .
|
pip install -e .
|
||||||
flake8 graphene
|
flake8 graphene
|
||||||
|
|
||||||
[pytest]
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user