Improved options

This commit is contained in:
Syrus Akbary 2016-06-04 19:10:18 -07:00
parent 2b676743ae
commit 31ea09ff30
6 changed files with 11 additions and 16 deletions

View File

@ -33,15 +33,14 @@ class GrapheneEnumType(GrapheneType, GraphQLEnumType):
class EnumTypeMeta(ClassTypeMeta):
def get_options(cls, meta):
options = cls.options_class(
return cls.options_class(
meta,
name=None,
description=None,
enum=None,
graphql_type=None,
abstract=False
)
options.valid_attrs = ['graphql_type', 'name', 'description', 'enum', 'abstract']
return options
def construct_graphql_type(cls, bases):
if not cls._meta.graphql_type and not cls._meta.abstract:

View File

@ -13,14 +13,13 @@ class GrapheneInputObjectType(GrapheneFieldsType, GraphQLInputObjectType):
class InputObjectTypeMeta(ClassTypeMeta):
def get_options(cls, meta):
options = cls.options_class(
return cls.options_class(
meta,
name=None,
description=None,
graphql_type=None,
abstract=False
)
options.valid_attrs = ['graphql_type', 'name', 'description', 'abstract']
return options
def construct_graphql_type(cls, bases):
if not cls._meta.graphql_type and not cls._meta.abstract:

View File

@ -11,14 +11,13 @@ class GrapheneInterfaceType(GrapheneFieldsType, GraphQLInterfaceType):
class InterfaceTypeMeta(ClassTypeMeta):
def get_options(cls, meta):
options = cls.options_class(
return cls.options_class(
meta,
name=None,
description=None,
graphql_type=None,
abstract=False
)
options.valid_attrs = ['graphql_type', 'name', 'description', 'abstract']
return options
def construct_graphql_type(cls, bases):
if not cls._meta.graphql_type and not cls._meta.abstract:

View File

@ -41,15 +41,14 @@ class GrapheneObjectType(GrapheneFieldsType, GraphQLObjectType):
class ObjectTypeMeta(ClassTypeMeta):
def get_options(cls, meta):
options = cls.options_class(
return cls.options_class(
meta,
name=None,
description=None,
graphql_type=None,
interfaces=[],
abstract=False
)
options.valid_attrs = ['graphql_type', 'name', 'description', 'interfaces', 'abstract']
return options
def construct_graphql_type(cls, bases):
if not cls._meta.graphql_type and not cls._meta.abstract:

View File

@ -6,7 +6,7 @@ class Options(object):
self.parent = None
for name, value in defaults.items():
setattr(self, name, value)
self.valid_attrs = []
self.valid_attrs = defaults.keys()
def contribute_to_class(self, cls, name):
cls._meta = self

View File

@ -50,14 +50,13 @@ class GrapheneScalarType(GrapheneType, GraphQLScalarType):
class ScalarTypeMeta(ClassTypeMeta):
def get_options(cls, meta):
options = cls.options_class(
return cls.options_class(
meta,
name=None,
description=None,
graphql_type=None,
abstract=False
)
options.valid_attrs = ['graphql_type', 'name', 'description', 'abstract']
return options
def construct_graphql_type(cls, bases):
if not cls._meta.graphql_type and not cls._meta.abstract: