tfoxy / graphene-django-optimizer

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

Fix variable handling and null values #27

Closed NyanKiyoshi closed 5 years ago

NyanKiyoshi commented 5 years ago

This pull request fixes two issues:

1 – InputObject variables were not handled

When providing an object for an InputObject, as a variable instead of hard-coding it into the query, we would get:

AttributeError: 'AttributeFilterInput' object has no attribute 'value'

Query

query($filters: AttributeFilterInput) {  # <-- the type is not handled
  ...
        availableAttributes(first: 10, filter: $filters) {
          edges {
            node {
              name
            }
          }
        }
  ...
}

Variables

{
  "filters": {
    "search": "color"
  }
}

2 – Null values were not handled

When providing a null value, we would get:

AttributeError: 'NoneType' object has no attribute 'value'

Query

Same as above.

Variables

{}
codecov-io commented 5 years ago

Codecov Report

Merging #27 into master will decrease coverage by 0.3%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #27      +/-   ##
==========================================
- Coverage   97.07%   96.77%   -0.31%     
==========================================
  Files           6        6              
  Lines         308      310       +2     
==========================================
+ Hits          299      300       +1     
- Misses          9       10       +1
Impacted Files Coverage Δ
graphene_django_optimizer/query.py 96.04% <100%> (-0.37%) :arrow_down:

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 16894bc...055db7d. Read the comment docs.