tfoxy / graphene-django-optimizer

Optimize database access inside graphene queries
MIT License
428 stars 84 forks source link

Compatibility with graphene-django v2.6.0 #32

Closed dex4er closed 5 years ago

dex4er commented 5 years ago

Hi.

graphene-django-optimizer breaks with graphene-django v2.6.0 with the stack trace:

      ERROR:graphql.execution.utils:Traceback (most recent call last):
        File "/Users/dex4er/src/some-api/.venv/site-packages/promise/promise.py", line 487, in _resolve_from_executor
          executor(resolve, reject)
        File "/Users/dex4er/src/some-api/.venv/site-packages/promise/promise.py", line 754, in executor
          return resolve(f(*args, **kwargs))
        File "/Users/dex4er/src/some-api/.venv/site-packages/graphql/execution/middleware.py", line 75, in make_it_promise
          return next(*args, **kwargs)
        File "/Users/dex4er/src/some-api/some_api/schema.py", line 150, in resolve_some
          IpPoolType._meta.model.objects, info
        File "/Users/dex4er/src/some-api/.venv/site-packages/graphene_django_optimizer/query.py", line 41, in query
          return QueryOptimizer(info, **options).optimize(queryset)
        File "/Users/dex4er/src/some-api/.venv/site-packages/graphene_django_optimizer/query.py", line 58, in optimize
          info.field_asts[0],
        File "/Users/dex4er/src/some-api/.venv/site-packages/graphene_django_optimizer/query.py", line 165, in _optimize_gql_selections
          possible_type,
        File "/Users/dex4er/src/some-api/.venv/site-packages/graphene_django_optimizer/query.py", line 171, in _optimize_field
          store, model, selection, field_def)
        File "/Users/dex4er/src/some-api/.venv/site-packages/graphene_django_optimizer/query.py", line 179, in _optimize_field_by_name
          name = self._get_name_from_resolver(field_def.resolver)
        File "/Users/dex4er/src/some-api/.venv/site-packages/graphene_django_optimizer/query.py", line 276, in _get_name_from_resolver
          if resolver_fn.func == default_resolver:
      graphql.error.located_error.GraphQLLocatedError: type object 'SomeType' has no attribute 'func'
codecov-io commented 5 years ago

Codecov Report

Merging #32 into master will increase coverage by 0.34%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #32      +/-   ##
==========================================
+ Coverage   93.22%   93.56%   +0.34%     
==========================================
  Files           6        6              
  Lines         310      311       +1     
==========================================
+ Hits          289      291       +2     
+ Misses         21       20       -1
Impacted Files Coverage Δ
graphene_django_optimizer/query.py 92.12% <100%> (+0.42%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 48db2b2...da61d4d. Read the comment docs.