mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-04-15 14:42:06 +03:00
Fixing pylint
This commit is contained in:
parent
d1f3c4d35a
commit
e75c584559
|
@ -1,6 +1,5 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from cookbook.ingredients.models import Category, Ingredient
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
@admin.register(Ingredient)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from cookbook.recipes.models import Recipe, RecipeIngredient
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
class RecipeIngredientInline(admin.TabularInline):
|
||||
|
|
|
@ -13,13 +13,7 @@ class Migration(migrations.Migration):
|
|||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='recipeingredient',
|
||||
old_name='recipes',
|
||||
new_name='recipe',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='recipeingredient',
|
||||
name='unit',
|
||||
field=models.CharField(choices=[(b'unit', b'Units'), (b'kg', b'Kilograms'), (b'l', b'Litres'), (b'st', b'Shots')], max_length=20),
|
||||
),
|
||||
]
|
||||
model_name='recipeingredient', old_name='recipes', new_name='recipe', ), migrations.AlterField(
|
||||
model_name='recipeingredient', name='unit', field=models.CharField(
|
||||
choices=[
|
||||
(b'unit', b'Units'), (b'kg', b'Kilograms'), (b'l', b'Litres'), (b'st', b'Shots')], max_length=20), ), ]
|
||||
|
|
|
@ -9,10 +9,5 @@ class Migration(migrations.Migration):
|
|||
('recipes', '0002_auto_20161104_0106'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='recipeingredient',
|
||||
name='unit',
|
||||
field=models.CharField(choices=[('unit', 'Units'), ('kg', 'Kilograms'), ('l', 'Litres'), ('st', 'Shots')], max_length=20),
|
||||
),
|
||||
]
|
||||
operations = [migrations.AlterField(model_name='recipeingredient', name='unit', field=models.CharField(
|
||||
choices=[('unit', 'Units'), ('kg', 'Kilograms'), ('l', 'Litres'), ('st', 'Shots')], max_length=20), ), ]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import cookbook.ingredients.schema
|
||||
import cookbook.recipes.schema
|
||||
import graphene
|
||||
|
||||
from graphene_django.debug import DjangoDebug
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
from django.urls import path
|
||||
from django.contrib import admin
|
||||
|
||||
from django.urls import path
|
||||
from graphene_django.views import GraphQLView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path("admin/", admin.site.urls),
|
||||
path("graphql/", GraphQLView.as_view(graphiql=True)),
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from cookbook.ingredients.models import Category, Ingredient
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
@admin.register(Ingredient)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from cookbook.recipes.models import Recipe, RecipeIngredient
|
||||
from django.contrib import admin
|
||||
|
||||
|
||||
class RecipeIngredientInline(admin.TabularInline):
|
||||
|
|
|
@ -13,13 +13,7 @@ class Migration(migrations.Migration):
|
|||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='recipeingredient',
|
||||
old_name='recipes',
|
||||
new_name='recipe',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='recipeingredient',
|
||||
name='unit',
|
||||
field=models.CharField(choices=[(b'unit', b'Units'), (b'kg', b'Kilograms'), (b'l', b'Litres'), (b'st', b'Shots')], max_length=20),
|
||||
),
|
||||
]
|
||||
model_name='recipeingredient', old_name='recipes', new_name='recipe', ), migrations.AlterField(
|
||||
model_name='recipeingredient', name='unit', field=models.CharField(
|
||||
choices=[
|
||||
(b'unit', b'Units'), (b'kg', b'Kilograms'), (b'l', b'Litres'), (b'st', b'Shots')], max_length=20), ), ]
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
from django.db import models
|
||||
|
||||
from cookbook.ingredients.models import Ingredient
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Recipe(models.Model):
|
||||
title = models.CharField(max_length=100)
|
||||
instructions = models.TextField()
|
||||
__unicode__ = lambda self: self.title
|
||||
|
||||
def __unicode__(self): return self.title
|
||||
|
||||
|
||||
class RecipeIngredient(models.Model):
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import cookbook.ingredients.schema
|
||||
import cookbook.recipes.schema
|
||||
import graphene
|
||||
|
||||
from graphene_django.debug import DjangoDebug
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
from django.conf.urls import url
|
||||
from django.contrib import admin
|
||||
|
||||
from graphene_django.views import GraphQLView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^admin/", admin.site.urls),
|
||||
url(r"^graphql$", GraphQLView.as_view(graphiql=True)),
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.module_loading import import_string
|
||||
|
||||
from graphene import (
|
||||
ID,
|
||||
UUID,
|
||||
Boolean,
|
||||
Date,
|
||||
DateTime,
|
||||
Dynamic,
|
||||
Enum,
|
||||
Field,
|
||||
|
@ -14,18 +17,15 @@ from graphene import (
|
|||
List,
|
||||
NonNull,
|
||||
String,
|
||||
UUID,
|
||||
DateTime,
|
||||
Date,
|
||||
Time,
|
||||
)
|
||||
from graphene.types.json import JSONString
|
||||
from graphene.utils.str_converters import to_camel_case, to_const
|
||||
from graphql import assert_valid_name
|
||||
|
||||
from .settings import graphene_settings
|
||||
from .compat import ArrayField, HStoreField, JSONField, RangeField
|
||||
from .fields import DjangoListField, DjangoConnectionField
|
||||
from .fields import DjangoConnectionField, DjangoListField
|
||||
from .settings import graphene_settings
|
||||
from .utils import import_single_dispatch
|
||||
|
||||
singledispatch = import_single_dispatch()
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from django.db import connections
|
||||
|
||||
from promise import Promise
|
||||
|
||||
from .sql.tracking import unwrap_cursor, wrap_cursor
|
||||
|
|
|
@ -6,6 +6,7 @@ from threading import local
|
|||
from time import time
|
||||
|
||||
import six
|
||||
|
||||
from django.utils.encoding import force_str
|
||||
|
||||
from .types import DjangoDebugSQL
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import pytest
|
||||
|
||||
import graphene
|
||||
import pytest
|
||||
from graphene.relay import Node
|
||||
from graphene_django import DjangoConnectionField, DjangoObjectType
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
from functools import partial, reduce
|
||||
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from graphene import NonNull
|
||||
from graphene.types import Field, List
|
||||
from graphene.relay import ConnectionField, PageInfo
|
||||
from graphene.types import Field, List
|
||||
from graphene.utils.get_unbound_function import get_unbound_function
|
||||
from graphql_relay.connection.arrayconnection import connection_from_list_slice
|
||||
from graphene_django.utils.utils import auth_resolver
|
||||
from graphql_relay.connection.arrayconnection import connection_from_list_slice
|
||||
from promise import Promise
|
||||
|
||||
from .settings import graphene_settings
|
||||
|
|
|
@ -2,6 +2,7 @@ from collections import OrderedDict
|
|||
from functools import partial
|
||||
|
||||
from graphene.types.argument import to_arguments
|
||||
|
||||
from ..fields import DjangoConnectionField
|
||||
from .utils import get_filtering_args_from_filterset, get_filterset_class
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import itertools
|
||||
|
||||
from django.db import models
|
||||
from django_filters import Filter, MultipleChoiceFilter, VERSION
|
||||
from django_filters.filterset import BaseFilterSet, FilterSet
|
||||
from django_filters.filterset import FILTER_FOR_DBFIELD_DEFAULTS
|
||||
|
||||
from django_filters import VERSION, Filter, MultipleChoiceFilter
|
||||
from django_filters.filterset import (
|
||||
FILTER_FOR_DBFIELD_DEFAULTS,
|
||||
BaseFilterSet,
|
||||
FilterSet,
|
||||
)
|
||||
from graphql_relay.node.node import from_global_id
|
||||
|
||||
from ..forms import GlobalIDFormField, GlobalIDMultipleChoiceField
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import django_filters
|
||||
from django_filters import OrderingFilter
|
||||
|
||||
from graphene_django.tests.models import Article, Pet, Reporter
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ from textwrap import dedent
|
|||
import pytest
|
||||
from django.db.models import TextField, Value
|
||||
from django.db.models.functions import Concat
|
||||
|
||||
from graphene import Argument, Boolean, Field, Float, ObjectType, Schema, String
|
||||
from graphene.relay import Node
|
||||
from graphene_django import DjangoObjectType
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import six
|
||||
|
||||
from django_filters.utils import get_model_field
|
||||
|
||||
from .filterset import custom_filterset_factory, setup_filterset
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,23 @@
|
|||
from django import forms
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from graphene import ID, Boolean, Float, Int, List, String, UUID, Date, DateTime, Time, Enum
|
||||
from graphene import (
|
||||
ID,
|
||||
UUID,
|
||||
Boolean,
|
||||
Date,
|
||||
DateTime,
|
||||
Enum,
|
||||
Float,
|
||||
Int,
|
||||
List,
|
||||
String,
|
||||
Time,
|
||||
)
|
||||
from graphene.utils.str_converters import to_camel_case
|
||||
|
||||
from graphene_django.converter import get_choices
|
||||
from .forms import GlobalIDFormField, GlobalIDMultipleChoiceField
|
||||
|
||||
from ..utils import import_single_dispatch
|
||||
from .forms import GlobalIDFormField, GlobalIDMultipleChoiceField
|
||||
|
||||
singledispatch = import_single_dispatch()
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import binascii
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.forms import CharField, Field, MultipleChoiceField
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from graphql_relay import from_global_id
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# from django import forms
|
||||
from collections import OrderedDict
|
||||
|
||||
import graphene
|
||||
from graphene import Field, InputField
|
||||
from graphene.relay.mutation import ClientIDMutation
|
||||
from graphene.types.mutation import MutationOptions
|
||||
|
||||
# from graphene.types.inputobjecttype import (
|
||||
# InputObjectTypeOptions,
|
||||
# InputObjectType,
|
||||
|
@ -22,8 +22,8 @@ def fields_for_form(form, only_fields, exclude_fields):
|
|||
for name, field in form.fields.items():
|
||||
is_not_in_only = only_fields and name not in only_fields
|
||||
is_excluded = (
|
||||
name
|
||||
in exclude_fields # or
|
||||
name
|
||||
in exclude_fields # or
|
||||
# name in already_created_fields
|
||||
)
|
||||
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
from django import forms
|
||||
from py.test import raises
|
||||
|
||||
from graphene import (
|
||||
String,
|
||||
Int,
|
||||
Boolean,
|
||||
Float,
|
||||
ID,
|
||||
UUID,
|
||||
Boolean,
|
||||
Date,
|
||||
DateTime,
|
||||
Enum,
|
||||
Float,
|
||||
Int,
|
||||
List,
|
||||
NonNull,
|
||||
DateTime,
|
||||
Date,
|
||||
String,
|
||||
Time,
|
||||
Enum,
|
||||
)
|
||||
from py.test import raises
|
||||
|
||||
from ..converter import convert_form_field, convert_form_field_with_choices
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
from django import forms
|
||||
from django.test import TestCase
|
||||
from django.core.exceptions import ValidationError
|
||||
from py.test import raises
|
||||
|
||||
from graphene import ObjectType, Schema, String, Field
|
||||
from django.test import TestCase
|
||||
from graphene import Field, ObjectType, Schema, String
|
||||
from graphene_django import DjangoObjectType
|
||||
from graphene_django.tests.models import Film, Pet
|
||||
from py.test import raises
|
||||
|
||||
from ...settings import graphene_settings
|
||||
from ..mutation import DjangoFormMutation, DjangoModelFormMutation
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import os
|
||||
import functools
|
||||
import importlib
|
||||
import json
|
||||
import functools
|
||||
import os
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.utils import autoreload
|
||||
|
||||
from graphql import print_schema
|
||||
from graphene_django.settings import graphene_settings
|
||||
from graphql import print_schema
|
||||
|
||||
|
||||
class CommandArguments(BaseCommand):
|
||||
|
@ -84,7 +83,7 @@ class Command(CommandArguments):
|
|||
def handle(self, *args, **options):
|
||||
options_schema = options.get("schema")
|
||||
|
||||
if options_schema and type(options_schema) is str:
|
||||
if options_schema and isinstance(options_schema, str):
|
||||
module_str, schema_name = options_schema.rsplit(".", 1)
|
||||
mod = importlib.import_module(module_str)
|
||||
schema = getattr(mod, schema_name)
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
from django.shortcuts import get_object_or_404
|
||||
from rest_framework import serializers
|
||||
|
||||
import graphene
|
||||
from django.shortcuts import get_object_or_404
|
||||
from graphene.relay.mutation import ClientIDMutation
|
||||
from graphene.types import Field, InputField
|
||||
from graphene.types.mutation import MutationOptions
|
||||
from graphene.types.objecttype import yank_fields_from_attrs
|
||||
from rest_framework import serializers
|
||||
|
||||
from ..types import ErrorType
|
||||
from .serializer_converter import convert_serializer_field
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import graphene
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from rest_framework import serializers
|
||||
|
||||
import graphene
|
||||
|
||||
from ..registry import get_global_registry
|
||||
from ..converter import convert_choices_to_named_enum_with_descriptions
|
||||
from ..registry import get_global_registry
|
||||
from ..utils import import_single_dispatch
|
||||
from .types import DictType
|
||||
|
||||
|
|
|
@ -2,10 +2,9 @@ import graphene
|
|||
import pytest
|
||||
from django.db import models
|
||||
from graphene import Schema
|
||||
from rest_framework import serializers
|
||||
|
||||
from graphene_django import DjangoObjectType
|
||||
from graphene_django.rest_framework.mutation import SerializerMutation
|
||||
from rest_framework import serializers
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import datetime
|
||||
|
||||
from py.test import mark, raises
|
||||
from rest_framework import serializers
|
||||
|
||||
from graphene import Field, ResolveInfo
|
||||
from graphene.types.inputobjecttype import InputObjectType
|
||||
from py.test import mark, raises
|
||||
from rest_framework import serializers
|
||||
|
||||
from ...settings import graphene_settings
|
||||
from ...types import DjangoObjectType
|
||||
from ..models import MyFakeModel, MyFakeModelWithPassword, MyFakeModelWithDate
|
||||
from ..models import MyFakeModel, MyFakeModelWithDate, MyFakeModelWithPassword
|
||||
from ..mutation import SerializerMutation
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ back to the defaults.
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import six
|
||||
|
||||
from django.conf import settings
|
||||
from django.test.signals import setting_changed
|
||||
|
||||
|
|
|
@ -2,20 +2,17 @@
|
|||
|
||||
import datetime
|
||||
|
||||
from django import forms
|
||||
|
||||
import graphene
|
||||
|
||||
from django import forms
|
||||
from graphene import Field, ResolveInfo
|
||||
from graphene.types.inputobjecttype import InputObjectType
|
||||
from py.test import raises
|
||||
from py.test import mark
|
||||
from py.test import mark, raises
|
||||
from rest_framework import serializers
|
||||
|
||||
from ...types import DjangoObjectType
|
||||
from ...forms.mutation import DjangoFormMutation
|
||||
from ...rest_framework.models import MyFakeModel
|
||||
from ...rest_framework.mutation import SerializerMutation
|
||||
from ...forms.mutation import DjangoFormMutation
|
||||
from ...types import DjangoObjectType
|
||||
|
||||
|
||||
class MyModelSerializer(serializers.ModelSerializer):
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
from textwrap import dedent
|
||||
|
||||
from django.core import management
|
||||
from mock import mock_open, patch
|
||||
from six import StringIO
|
||||
|
||||
from django.core import management
|
||||
from graphene import ObjectType, Schema, String
|
||||
from mock import mock_open, patch
|
||||
|
||||
|
||||
@patch("graphene_django.management.commands.graphql_schema.Command.save_json_file")
|
||||
|
|
|
@ -1,27 +1,26 @@
|
|||
import pytest
|
||||
from collections import namedtuple
|
||||
|
||||
import graphene
|
||||
import pytest
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from graphene import NonNull
|
||||
from graphene.relay import ConnectionField, Node
|
||||
from graphene.types.datetime import Date, DateTime, Time
|
||||
from graphene.types.json import JSONString
|
||||
from py.test import raises
|
||||
|
||||
import graphene
|
||||
from graphene.relay import ConnectionField, Node
|
||||
from graphene.types.datetime import DateTime, Date, Time
|
||||
from graphene.types.json import JSONString
|
||||
|
||||
from ..compat import JSONField, ArrayField, HStoreField, RangeField, MissingType
|
||||
from ..compat import ArrayField, HStoreField, JSONField, MissingType, RangeField
|
||||
from ..converter import (
|
||||
convert_django_field,
|
||||
convert_django_field_with_choices,
|
||||
generate_enum_name,
|
||||
)
|
||||
from ..registry import Registry
|
||||
from ..types import DjangoObjectType
|
||||
from ..settings import graphene_settings
|
||||
from ..types import DjangoObjectType
|
||||
from .models import Article, Film, FilmDetails, Reporter
|
||||
|
||||
|
||||
# from graphene.core.types.custom_scalars import DateTime, Time, JSONString
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import datetime
|
||||
from unittest import TestCase
|
||||
|
||||
import pytest
|
||||
|
||||
from graphene import List, NonNull, ObjectType, Schema, String
|
||||
from mock import mock
|
||||
from unittest import TestCase
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from graphene_django.fields import DjangoField, DataLoaderField
|
||||
from promise.dataloader import DataLoader
|
||||
from graphene import List, NonNull, ObjectType, Schema, String
|
||||
from graphene_django.fields import DataLoaderField, DjangoField
|
||||
from mock import mock
|
||||
from promise import Promise
|
||||
from promise.dataloader import DataLoader
|
||||
|
||||
from ..fields import DjangoListField
|
||||
from ..types import DjangoObjectType
|
||||
from .models import Article as ArticleModel
|
||||
|
|
|
@ -3,7 +3,6 @@ from py.test import raises
|
|||
|
||||
from ..forms import GlobalIDFormField, GlobalIDMultipleChoiceField
|
||||
|
||||
|
||||
# 'TXlUeXBlOmFiYw==' -> 'MyType', 'abc'
|
||||
|
||||
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
import base64
|
||||
import datetime
|
||||
|
||||
import graphene
|
||||
import pytest
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
from graphene.relay import Node
|
||||
from graphql_relay import to_global_id
|
||||
from py.test import raises
|
||||
|
||||
from django.db.models import Q
|
||||
|
||||
from graphql_relay import to_global_id
|
||||
import graphene
|
||||
from graphene.relay import Node
|
||||
|
||||
from ..utils import DJANGO_FILTER_INSTALLED
|
||||
from ..compat import MissingType, JSONField
|
||||
from ..compat import JSONField, MissingType
|
||||
from ..fields import DjangoConnectionField
|
||||
from ..types import DjangoObjectType
|
||||
from ..settings import graphene_settings
|
||||
from .models import Article, CNNReporter, Reporter, Film, FilmDetails
|
||||
from ..types import DjangoObjectType
|
||||
from ..utils import DJANGO_FILTER_INSTALLED
|
||||
from .models import Article, CNNReporter, Film, FilmDetails, Reporter
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
|
|
@ -3,10 +3,9 @@ from textwrap import dedent
|
|||
|
||||
import pytest
|
||||
from django.db import models
|
||||
from mock import patch
|
||||
|
||||
from graphene import Interface, ObjectType, Schema, Connection, String, Field
|
||||
from graphene import Connection, Field, Interface, ObjectType, Schema, String
|
||||
from graphene.relay import Node
|
||||
from mock import patch
|
||||
|
||||
from .. import registry
|
||||
from ..settings import graphene_settings
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.utils.translation import gettext_lazy
|
||||
|
||||
from graphene_django.utils.utils import has_permissions
|
||||
|
||||
from ..utils import camelize, get_model_fields
|
||||
from .models import Film, Reporter
|
||||
|
||||
|
|
|
@ -3,16 +3,16 @@ from collections import OrderedDict
|
|||
from functools import partial
|
||||
|
||||
import six
|
||||
import graphene
|
||||
|
||||
import graphene
|
||||
from django.db.models import Model
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
from graphene import Field, NonNull
|
||||
from graphene.relay import Connection, Node
|
||||
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
|
||||
from graphene.types.utils import yank_fields_from_attrs
|
||||
|
||||
from graphene_django.utils.utils import auth_resolver
|
||||
|
||||
from .converter import convert_django_field_with_choices
|
||||
from .registry import Registry, get_global_registry
|
||||
from .settings import graphene_settings
|
||||
|
@ -29,7 +29,7 @@ ALL_FIELDS = "__all__"
|
|||
|
||||
|
||||
def construct_fields(
|
||||
model, registry, only_fields, exclude_fields, convert_choices_to_enum
|
||||
model, registry, only_fields, exclude_fields, convert_choices_to_enum
|
||||
):
|
||||
_model_fields = get_model_fields(model)
|
||||
|
||||
|
@ -71,30 +71,16 @@ def validate_fields(type_, model, fields, only_fields, exclude_fields):
|
|||
|
||||
if hasattr(model, name):
|
||||
warnings.warn(
|
||||
(
|
||||
'Field name "{field_name}" matches an attribute on Django model "{app_label}.{object_name}" '
|
||||
"but it's not a model field so Graphene cannot determine what type it should be. "
|
||||
'Either define the type of the field on DjangoObjectType "{type_}" or remove it from the "fields" list.'
|
||||
).format(
|
||||
field_name=name,
|
||||
app_label=model._meta.app_label,
|
||||
object_name=model._meta.object_name,
|
||||
type_=type_,
|
||||
)
|
||||
)
|
||||
('Field name "{field_name}" matches an attribute on Django model "{app_label}.{object_name}" '
|
||||
"but it's not a model field so Graphene cannot determine what type it should be. "
|
||||
'Either define the type of the field on DjangoObjectType "{type_}" or remove it from the "fields" list.').format(
|
||||
field_name=name, app_label=model._meta.app_label, object_name=model._meta.object_name, type_=type_, ))
|
||||
|
||||
else:
|
||||
warnings.warn(
|
||||
(
|
||||
'Field name "{field_name}" doesn\'t exist on Django model "{app_label}.{object_name}". '
|
||||
'Consider removing the field from the "fields" list of DjangoObjectType "{type_}" because it has no effect.'
|
||||
).format(
|
||||
field_name=name,
|
||||
app_label=model._meta.app_label,
|
||||
object_name=model._meta.object_name,
|
||||
type_=type_,
|
||||
)
|
||||
)
|
||||
('Field name "{field_name}" doesn\'t exist on Django model "{app_label}.{object_name}". '
|
||||
'Consider removing the field from the "fields" list of DjangoObjectType "{type_}" because it has no effect.').format(
|
||||
field_name=name, app_label=model._meta.app_label, object_name=model._meta.object_name, type_=type_, ))
|
||||
|
||||
# Validate exclude fields
|
||||
for name in exclude_fields or ():
|
||||
|
@ -114,16 +100,9 @@ def validate_fields(type_, model, fields, only_fields, exclude_fields):
|
|||
else:
|
||||
if not hasattr(model, name):
|
||||
warnings.warn(
|
||||
(
|
||||
'Django model "{app_label}.{object_name}" does not have a field or attribute named "{field_name}". '
|
||||
'Consider removing the field from the "exclude" list of DjangoObjectType "{type_}" because it has no effect'
|
||||
).format(
|
||||
field_name=name,
|
||||
app_label=model._meta.app_label,
|
||||
object_name=model._meta.object_name,
|
||||
type_=type_,
|
||||
)
|
||||
)
|
||||
('Django model "{app_label}.{object_name}" does not have a field or attribute named "{field_name}". '
|
||||
'Consider removing the field from the "exclude" list of DjangoObjectType "{type_}" because it has no effect').format(
|
||||
field_name=name, app_label=model._meta.app_label, object_name=model._meta.object_name, type_=type_, ))
|
||||
|
||||
|
||||
def get_auth_resolver(name, permissions, resolver=None):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import json
|
||||
|
||||
from django.test import TestCase, Client
|
||||
from django.test import Client, TestCase
|
||||
|
||||
|
||||
class GraphQLTestCase(TestCase):
|
||||
|
@ -32,13 +32,13 @@ class GraphQLTestCase(TestCase):
|
|||
supply the op_name. For annon queries ("{ ... }"),
|
||||
should be None (default).
|
||||
input_data (dict) - If provided, the $input variable in GraphQL will be set
|
||||
to this value. If both ``input_data`` and ``variables``,
|
||||
to this value. If both ``input_data`` and ``variables``,
|
||||
are provided, the ``input`` field in the ``variables``
|
||||
dict will be overwritten with this value.
|
||||
variables (dict) - If provided, the "variables" field in GraphQL will be
|
||||
set to this value.
|
||||
headers (dict) - If provided, the headers in POST request to GRAPHQL_URL
|
||||
will be set to this value.
|
||||
will be set to this value.
|
||||
|
||||
Returns:
|
||||
Response object from client
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
import inspect
|
||||
|
||||
import six
|
||||
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.db import models
|
||||
from django.db.models.manager import Manager
|
||||
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.functional import Promise
|
||||
# from graphene.utils import LazyList
|
||||
from graphene.types.resolver import get_default_resolver
|
||||
from graphene.utils.get_unbound_function import get_unbound_function
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.functional import Promise
|
||||
|
||||
from graphene.utils.str_converters import to_camel_case
|
||||
|
||||
try:
|
||||
|
|
|
@ -3,16 +3,16 @@ import json
|
|||
import re
|
||||
|
||||
import six
|
||||
|
||||
from django.http import HttpResponse, HttpResponseNotAllowed
|
||||
from django.http.response import HttpResponseBadRequest
|
||||
from django.shortcuts import render
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.generic import View
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
|
||||
from django.views.generic import View
|
||||
from graphql import get_default_backend
|
||||
from graphql.error import format_error as format_graphql_error
|
||||
from graphql.error import GraphQLError
|
||||
from graphql.error import format_error as format_graphql_error
|
||||
from graphql.execution import ExecutionResult
|
||||
from graphql.type.schema import GraphQLSchema
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user