-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can not have a field named type
with in
filter
#28
Comments
Can you provide stack trace? I added |
That's strange. This is the complete stack trace. File "/home/karicher/application/schema.py", line 92, in <module>
schema = graphene.Schema(query=Query, mutation=Mutation)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/schema.py", line 78, in __init__
self.build_typemap()
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/schema.py", line 168, in build_typemap
initial_types, auto_camelcase=self.auto_camelcase, schema=self
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 80, in __init__
super(TypeMap, self).__init__(types)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphql/type/typemap.py", line 31, in __init__
self.update(reduce(self.reducer, types, OrderedDict())) # type: ignore
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 88, in reducer
return self.graphene_reducer(map, type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 117, in graphene_reducer
return GraphQLTypeMap.reducer(map, internal_type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphql/type/typemap.py", line 109, in reducer
field_map = type_.fields
File "/home/karicher/venv/lib64/python3.6/site-packages/graphql/pyutils/cached_property.py", line 22, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphql/type/definition.py", line 198, in fields
return define_field_map(self, self._fields)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphql/type/definition.py", line 212, in define_field_map
field_map = field_map()
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 287, in construct_fields_for_type
map = self.reducer(map, arg.type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 88, in reducer
return self.graphene_reducer(map, type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 117, in graphene_reducer
return GraphQLTypeMap.reducer(map, internal_type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphql/type/typemap.py", line 109, in reducer
field_map = type_.fields
File "/home/karicher/venv/lib64/python3.6/site-packages/graphql/pyutils/cached_property.py", line 22, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphql/type/definition.py", line 641, in fields
return self._define_field_map()
File "/home/karicher/venv/lib64/python3.6/site-packages/graphql/type/definition.py", line 646, in _define_field_map
fields = self._fields()
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 275, in construct_fields_for_type
map = self.reducer(map, field.type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 88, in reducer
return self.graphene_reducer(map, type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 93, in graphene_reducer
return self.reducer(map, type.of_type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 88, in reducer
return self.graphene_reducer(map, type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 93, in graphene_reducer
return self.reducer(map, type.of_type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphene/types/typemap.py", line 89, in reducer
return GraphQLTypeMap.reducer(map, type)
File "/home/karicher/venv/lib64/python3.6/site-packages/graphql/type/typemap.py", line 87, in reducer
if type_.name in map_:
AttributeError: type object 'function' has no attribute 'name' I tried to replace class SampleFilter(FilterSet):
class Meta:
model = SampleModel
fields = {
'name': [...],
'type': ['eq', 'ne'],
} ... would work! but, class SampleFilter(FilterSet):
class Meta:
model = SampleModel
fields = {
'name': [...],
'type': ['in'], # or [...]
} wouldn't work. |
type
type
with in
filter
What version of graphene and graphene-sqlalchemy you are using? |
Sorry for the late reply. These are the versions in use:
|
I tested on your environment and found no errors. Looking at your stacktrace error occurs at the graphene level, but the message contains too little information... I don't know why you ran into this error. The only way I can help you is by checking a minimal example project that contains the same error. |
Ok, I have more problems now. 'eq' filter for 20200928 10:18:13 ERROR Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/promise/promise.py", line 489, in _resolve_from_executor
executor(resolve, reject)
File "/usr/lib/python3.6/site-packages/promise/promise.py", line 756, in executor
return resolve(f(*args, **kwargs))
File "/usr/lib/python3.6/site-packages/graphql/execution/middleware.py", line 75, in make_it_promise
return next(*args, **kwargs)
File "/home/karicher/venv/server/lib64/python3.6/site-packages/graphene_sqlalchemy/fields.py", line 78, in connection_resolver
return on_resolve(resolved)
File "/home/karicher/venv/server/lib64/python3.6/site-packages/graphene_sqlalchemy/fields.py", line 51, in resolve_connection
resolved = cls.get_query(model, info, **args)
File "/home/karicher/venv/server/lib64/python3.6/site-packages/graphene_sqlalchemy_filter/connection_field.py", line 88, in get_query
query = filter_set.filter(info, query, request_filters)
File "/home/karicher/venv/server/lib64/python3.6/site-packages/graphene_sqlalchemy_filter/filters.py", line 752, in filter
query, sqla_filters = cls._translate_many_filter(info, query, filters)
File "/home/karicher/venv/server/lib64/python3.6/site-packages/graphene_sqlalchemy_filter/filters.py", line 878, in _translate_many_filter
query, r = cls._translate_filter(info, query, k, v)
File "/home/karicher/venv/server/lib64/python3.6/site-packages/graphene_sqlalchemy_filter/filters.py", line 839, in _translate_filter
value = model_field_type.enum_class(value)
graphql.error.located_error.GraphQLLocatedError: 'NoneType' object is not callable Can you test by converting |
Yeah. I got a similar error. As far as I understand, the error rise only if custom graphene objects used (if not use SQLAlchemyObjectType). |
I've got the same problem with enum field. Model:
Schema:
|
@art1415926535 Can you take a look at this PR and see if we can fix this here ? |
I published a new release https://pypi.org/project/graphene-sqlalchemy-filter/1.12.2/ |
@art1415926535 That seems to have fixed it and I started using the latest version in production :) Good to close this issue from my side. |
I have a field named
type
and adding that in filterset fields give the following error to when creating the schema.eg:
The text was updated successfully, but these errors were encountered: