barseghyanartur / graphene-elastic

Graphene Elasticsearch/OpenSearch (DSL) integration
https://pypi.org/project/graphene-elastic/
71 stars 17 forks source link

When we build using graphene_federation build_schema instead of Graphene.Schema we get JSONString error #34

Closed dasaep closed 4 years ago

dasaep commented 4 years ago

When we define a schema with graphene-elastic types and try to load it using graphene_federation build_schema instead of Graphene.Schema we get a error

the JSON object must be str, bytes or bytearray, not dict Traceback (most recent call last): File "manage.py", line 12, in execute_from_command_line(sys.argv) File "/usr/local/lib/python3.8/site-packages/django/core/management/init.py", line 381, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.8/site-packages/django/core/management/init.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.8/site-packages/django/core/management/init.py", line 224, in fetch_command klass = load_command_class(app_name, subcommand) File "/usr/local/lib/python3.8/site-packages/django/core/management/init.py", line 36, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "/app/saleor/graphql/management/commands/get_graphql_elastic_schema.py", line 5, in from ...api_elastic import elastic_schema File "/app/saleor/graphql/api_elastic.py", line 32, in elastic_schema = build_schema(query=Query) File "/usr/local/lib/python3.8/site-packages/graphene_federation/main.py", line 20, in build_schema return graphene.Schema(query=_get_query(schema, query), **kwargs) File "/usr/local/lib/python3.8/site-packages/graphene/types/schema.py", line 78, in init self.build_typemap() File "/usr/local/lib/python3.8/site-packages/graphene/types/schema.py", line 167, in build_typemap self._type_map = TypeMap( File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 80, in init super(TypeMap, self).init(types) File "/usr/local/lib/python3.8/site-packages/graphql/type/typemap.py", line 28, in init self.update(reduce(self.reducer, types, OrderedDict())) # type: ignore File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 88, in reducer return self.graphene_reducer(map, type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 117, in graphene_reducer return GraphQLTypeMap.reducer(map, internal_type) File "/usr/local/lib/python3.8/site-packages/graphql/type/typemap.py", line 106, in reducer field_map = type.fields File "/usr/local/lib/python3.8/site-packages/graphql/pyutils/cached_property.py", line 22, in get value = obj.dict[self.func.name] = self.func(obj) File "/usr/local/lib/python3.8/site-packages/graphql/type/definition.py", line 226, in fields return define_field_map(self, self._fields) File "/usr/local/lib/python3.8/site-packages/graphql/type/definition.py", line 240, in define_field_map field_map = field_map() File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 275, in construct_fields_for_type map = self.reducer(map, field.type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 88, in reducer return self.graphene_reducer(map, type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 93, in graphene_reducer return self.reducer(map, type.of_type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 88, in reducer return self.graphene_reducer(map, type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 117, in graphene_reducer return GraphQLTypeMap.reducer(map, internal_type) File "/usr/local/lib/python3.8/site-packages/graphql/type/typemap.py", line 96, in reducer for t in type.types: File "/usr/local/lib/python3.8/site-packages/graphql/pyutils/cached_property.py", line 22, in get value = obj.dict[self.func.name] = self.func(obj) File "/usr/local/lib/python3.8/site-packages/graphql/type/definition.py", line 453, in types return define_types(self, self._types) File "/usr/local/lib/python3.8/site-packages/graphql/type/definition.py", line 464, in define_types types = types() File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 249, in types self.graphene_reducer(map, objecttype) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 117, in graphene_reducer return GraphQLTypeMap.reducer(map, internal_type) File "/usr/local/lib/python3.8/site-packages/graphql/type/typemap.py", line 106, in reducer field_map = type.fields File "/usr/local/lib/python3.8/site-packages/graphql/pyutils/cached_property.py", line 22, in get value = obj.dict[self.func.name] = self.func(obj) File "/usr/local/lib/python3.8/site-packages/graphql/type/definition.py", line 226, in fields return define_field_map(self, self._fields) File "/usr/local/lib/python3.8/site-packages/graphql/type/definition.py", line 240, in define_field_map field_map = field_map() File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 275, in construct_fields_for_type map = self.reducer(map, field.type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 88, in reducer return self.graphene_reducer(map, type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 93, in graphene_reducer return self.reducer(map, type.of_type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 88, in reducer return self.graphene_reducer(map, type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 117, in graphene_reducer return GraphQLTypeMap.reducer(map, internal_type) File "/usr/local/lib/python3.8/site-packages/graphql/type/typemap.py", line 106, in reducer field_map = type.fields File "/usr/local/lib/python3.8/site-packages/graphql/pyutils/cached_property.py", line 22, in get value = obj.dict[self.func.name] = self.func(obj) File "/usr/local/lib/python3.8/site-packages/graphql/type/definition.py", line 226, in fields return define_field_map(self, self._fields) File "/usr/local/lib/python3.8/site-packages/graphql/type/definition.py", line 240, in define_field_map field_map = field_map() File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 275, in construct_fields_for_type map = self.reducer(map, field.type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 88, in reducer return self.graphene_reducer(map, type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 93, in graphene_reducer return self.reducer(map, type.of_type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 88, in reducer return self.graphene_reducer(map, type) File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 97, in graphene_reducer assert _type.graphene_type == type, (

barseghyanartur commented 4 years ago

Pull request is merged. Thanks! A tiny remark, I don't think the problem was in this package. It's more proper to fix it on graphene federation part, as most likely every other package that would have JSONString would face similar issues. However, for making it easier for you (and the rest of the folks out there), here we go. I'll make a release shortly. Thank you for spending your time on this!

barseghyanartur commented 4 years ago

Released in 0.6.2.

dasaep commented 4 years ago

Thanks a ton Artur your package rocks and it’s very helpful and handy

On Tue, Jul 7, 2020 at 6:35 AM Artur Barseghyan notifications@github.com wrote:

Released in 0.6.2.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/barseghyanartur/graphene-elastic/issues/34#issuecomment-654762252, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMBP7W7X522GMBFLM6NTTN3R2L27LANCNFSM4OP7NETA .

-- Dasa Ponnappan Cell: (+1)925-339-5357 Twitter:@Dasarathy LinkedIn:https://www.linkedin.com/in/epdasa/